connectedComponentsWithStats crashes randomly
I am getting a random crash with connectedComponentsWithStats in OpenCV 3.1.
This is what I'm doing in a nutshell:
1 - Capturing from video feed and converting to HSV
2 - Looking for certain HSV ranges within the image, and then masking out the rest.
3 - Using connectedComponentsWithStats to get blobs from the image and analyze them (to weed out the noise).
But sometimes connectedComponentsWithStats works fine and then occasionally it just crashes.
Here's a snippet of my code.
Mat labelsYAxis, statsYAxis, centroidsYAxis;
Mat labelsXAxis, statsXAxis, centroidsXAxis;
Mat labelsBase, statsBase, centroidsBase;
int nYAxisLabels = connectedComponentsWithStats(yAxisBlobs, labelsYAxis, statsYAxis, centroidsYAxis, 8, CV_32S);
int nXAxisLabels = connectedComponentsWithStats(xAxisBlobs, labelsXAxis, statsXAxis, centroidsXAxis, 8, CV_32S);
int nBaseLabels = connectedComponentsWithStats(baseBlobs, labelsBase, statsBase, centroidsBase, 8, CV_32S);
help us to help you. First opencv version and platfform are needed. second can you saved image before crashed ? If yes can you save this image and try to reproduce exception. Connected component need a binary image
Added OpenCV version. Will work on getting sample image.
What is error message when it crashes?
I have figured this out but can't post an answer yet. I was passing in the wrong Mat, I passed in the color Mat instead of my binary mask Mat.