DETECT the Edge of a Document in iPhoneSDK

Ajay Sharma picture Ajay Sharma · Jan 19, 2012 · Viewed 10.8k times · Source

I am looking something like attached image, How can I implement this in iPhoneSDK.

Can anybody suggest me some open source API or Algorithm Code to detect the corners of captured image of a document.

Some How, I got an open source API called OpenCV which recognize the Human Face very well. I want to use the same API if possible.Now the problem Is how can I make the changes in those static libraries according to my requirement to Scan the Document edges. Alternatively,

how to detect for the square/rectangle object in the captured image ?

enter image description here

Answer

Marcus Gründler picture Marcus Gründler · Jan 19, 2012

When you are already using openCV you might know the Reference Manual:

http://www.sciweavers.org/books/opencv-open-source-computer-vision-reference-manual

On page 10-6 there is a reference to the set of contour detection functions:

CvContourScanner cvStartFindContours(IplImage* img, 
                                     CvMemStorage* storage, 
                                     int headerSize, 
                                     CvContourRetrievalMode mode, 
                                     CvChainApproxMethod method );

int cvFindContours( IplImage* img, 
                    CvMemStorage* storage,
                    CvSeq** firstContour, 
                    int headerSize=sizeof(CvContour),
                    CvContourRetrievalMode mode=CV_RETR_LIST,
                    CvChainApproxMethod method=CV_CHAIN_APPROX_SIMPLE );

I hope that helps.

When the target of your question was, how to use OpenCV on ios/iPhone then you can have a look at the following Sites. Ready made XCode project files for use in an iOS project:

http://www.eosgarden.com/en/opensource/opencv-ios/overview/

Another StackOverflow post with very valuable information can be found here:

iPhone and OpenCV