Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cv.approxPolyDP maxContour. #25

Open
TomAtRichfords opened this issue Mar 8, 2024 · 2 comments
Open

cv.approxPolyDP maxContour. #25

TomAtRichfords opened this issue Mar 8, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@TomAtRichfords
Copy link

During testing, I encountered a case where the top-right of my page was incorrectly evaluated as being near the top-left, resulting in a near triangular poly from getCornerPoints(contour). What seems to have happened is that there was a point in the contour that was just right of the centre, yet had a bigger distance than the right-hand corner of the page (although the page was at an almost 45 degree angle in the frame, which would be unusual).
Recommend applying a cv.approxPolyDP to the maxContour prior to getCornerPoints(contour) to reduce occurrences.

      return this.getApproxPoly(maxContour);
    }

    /** refines a contour to get approximate poly
     * @param {*} contour contour to refine
     */
    getApproxPoly(contour) {
      const peri = cv.arcLength(contour, true);
      const approx = new cv.Mat();
      cv.arcLength(contour, true) * 0.02
      cv.approxPolyDP(contour, approx, 0.1 * peri, true);
      return approx;
    }
@ColonelParrot
Copy link
Member

Interesting, thanks for letting me know! Could you provide the image so I can test it?

@ColonelParrot ColonelParrot added the bug Something isn't working label Mar 8, 2024
@TomAtRichfords
Copy link
Author

TomAtRichfords commented Mar 11, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants