Ask Your Question
2

cv::findContours, unable to find contours

asked 2012-12-27 14:54:16 -0500

this post is marked as community wiki

This post is a wiki. Anyone with karma >50 is welcome to improve it.

Hello,

Below is the image that i'm able to capture through the video camera. But when i process this image withcv:: findcontours method in ios, it is unable to detect the contours in the image.

Can anyone help me with this issue.

image description

edit retag flag offensive close merge delete

Comments

Try to find contours after thresholding this image. If it has no effect, try to do dilate, after thresholding.

Daniil Osokin gravatar imageDaniil Osokin ( 2012-12-27 23:47:49 -0500 )edit

1 answer

Sort by ยป oldest newest most voted
3

answered 2012-12-28 02:34:08 -0500

Michael Burdinov gravatar image

findContours detects contours in binary image. So it checks which pixels of image are equal to zero, and which pixels are not. Natural image like the one you provided most likely don't have any pixels that equal to zero. So you have to turn it into binary image. For example you can threshold the image like Daniil suggested. A naive way to do so:

Mat binaryImage = (image > mean(image));
findContours( binaryImage, contours, CV_RETR_LIST, CV_CHAIN_APPROX_SIMPLE);
edit flag offensive delete link more
Login/Signup to Answer

Question Tools

2 followers

Stats

Asked: 2012-12-27 14:54:16 -0500

Seen: 1,009 times

Last updated: Dec 28 '12