I am creating real time software, so often cvFindContours is called on a completely black mask. If this case, cvFindContours throws an exception, and the program crashes.
How would I make it so that if cvFindContours is unable to find contours, instead of the program crashing, the program just moves onto the next line of code (just simple continues)?
Thanks
PS: I thought about keeping one pixel automatically always white to prevent cvFindContours from not being able to find an contour, but this would be inconvenient to me.
Why don’t you try something as follows:
This is using the C++ interface, but you should be able to use
cvSumto accomplish the same thing. So, if the image is all black, that means the image contains only zeros. Therefore, the sum will be zero when it is a black mask.