Ask Your Question
3

cv::findContours, unable to find contours

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

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 -0600 )edit

1 answer

Sort by ยป oldest newest most voted
4

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

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

Question Tools

1 follower

Stats

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

Seen: 1,478 times

Last updated: Dec 28 '12