Ask Your Question
0

Crop image based on largest quadrilateral contour OpenCV

asked 2014-03-18 19:39:24 -0500

Luek gravatar image

updated 2014-03-19 07:38:23 -0500

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

edit retag flag offensive close merge delete

Comments

1

1 answer

Sort by ยป oldest newest most voted
0

answered 2014-03-19 13:31:53 -0500

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

edit flag offensive delete link more

Question Tools

Stats

Asked: 2014-03-18 19:39:24 -0500

Seen: 4,924 times

Last updated: Mar 19 '14