Ask Your Question
0

Crop image based on largest quadrilateral contour OpenCV

asked Mar 19 '14

Luek gravatar image

updated Mar 19 '14

berak gravatar image

I am in high school and I am working on a project to build an iOS app that lets users scan business cards, currently I am working on edge detection on the card. I believe I have it working correctly and it is drawing the outline of the card and some other shadows ect.

Here is a sample image I got back while scanning, I should probably convert to grayscale which I'll do as well.

How can I find the largest quadrilateral and crop my image to included only the card? All of my contours are stored in a vector<vector<cv::Point> > The green line seems to be the one I'd be interested in.

enter image description here

Preview: (hide)

Comments

1

1 answer

Sort by » oldest newest most voted
0

answered Mar 19 '14

Will Stewart gravatar image

findContours has a parameter 'mode' that can be set to CV_RETR_EXTERNAL to retrieve only the outermost contour.

http://docs.opencv.org/modules/imgproc/doc/structural_analysis_and_shape_descriptors.html#findcontours

Preview: (hide)

Question Tools

Stats

Asked: Mar 19 '14

Seen: 5,766 times

Last updated: Mar 19 '14