I am trying to use CvConnectedComp
which is an output from cvFloodFill
.
CvConnectedComp comp;
cvFloodFill(imgInput,seedPoint,
cvScalarAll(0),cvScalarAll(.1),cvScalarAll(1.),
&comp,CV_FLOODFILL_MASK_ONLY,imgMask);
I am able to use comp.rect
for drawing the component, but comp.contour
is NULL
.I want to use it for further processing. I tried without mask also, but still it is same result.
Any idea will be appreciated.
Note: The deprecated OpenCV C API should only be used for the support of legacy code. New code should use the C++ API.
Looking at the code for OpenCV 3.0.0,
cvFloodFill
does not populatecomp.contour
; the only members it sets are.rect
,.area
, and.value
. I don't know if it was always this way, but here's what's happening:First, look at the signature for the C++
cv::floodFill
:Notice that there is no connected component structure here, only a
Rect
. The return value is the area of the region that is floodfilled.This is the method that is called by
cvFloodFill
. The code passes&comp->rect
to the C++ method where it is populated, uses the return value forcomp->area
an copiesnewVal
intocomp->value
.