Ask Your Question
0

connectedComponentsWithStats crashes randomly

asked 2017-01-30 11:50:31 -0600

jhowell gravatar image

updated 2017-01-30 15:33:38 -0600

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);
edit retag flag offensive close merge delete

Comments

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

LBerger gravatar imageLBerger ( 2017-01-30 11:58:51 -0600 )edit

Added OpenCV version. Will work on getting sample image.

jhowell gravatar imagejhowell ( 2017-01-30 15:34:15 -0600 )edit

What is error message when it crashes?

LBerger gravatar imageLBerger ( 2017-01-30 18:24:54 -0600 )edit
1

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.

jhowell gravatar imagejhowell ( 2017-01-31 12:12:00 -0600 )edit

1 answer

Sort by ยป oldest newest most voted
0

answered 2017-02-02 15:01:47 -0600

jhowell gravatar image

I figured this out, I was passing the wrong Mat by mistake as the input. I was passing in the full color mat as opposed to my binary mat.

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2017-01-30 11:50:31 -0600

Seen: 837 times

Last updated: Feb 02 '17