Ask Your Question

Revision history [back]

connectedComponentsWithStats using problem

hi all :

I recently used the function to detecting object by using "connectedComponentsWithStats" operator with binary image. I found a problem in that operator.

Here is my code:

//create an all white binary image
cv::Mat binTest = cv::Mat(1000 , 2000 , CV_8UC1) ;
std::memset(binTest.data , 255 , 1000 * 2000) ;
//find out connected component
cv::Mat _dstImg , __stat , _centroid ;
int cc = cv::connectedComponentsWithStats( binTest , _dstImg , __stat , _centroid, 8 , CV_32S , cv::ConnectedComponentsAlgorithmsTypes::CCL_GRANA) ;

It will return 2 objects, and get INT_MAX,INT_MAX,2,2,0 stat at first object. At the second object, it will return full image object.(right object)

So, i wanna ask : 1. What's problem in my code? 2. Is that operator must ignore the first detected object?

My testing environment as follow: Operating System: Windows 10 Compiler: VS 2012 x64(VC11.0) OpenCV Version: 3.2 & 3.4.0