cvFindContours()异常?
我正在创建实时软件,因此经常在全黑蒙版上调用 cvFindContours。如果这种情况,cvFindContours 会抛出异常,并且程序崩溃。
如果 cvFindContours 无法找到轮廓,我该如何做到这一点,而不是程序崩溃,程序只是移动到下一行代码(只是简单地继续)?
谢谢
PS:我想过自动保持一个像素始终为白色,以防止 cvFindContours 无法找到轮廓,但这对我来说很不方便。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
为什么不尝试如下操作:
这是使用 C++ 接口,但您应该能够使用
cvSum
来完成同样的事情。因此,如果图像全黑,则意味着图像仅包含零。因此,当它是黑色掩模时,总和将为零。Why don't you try something as follows:
This is using the C++ interface, but you should be able to use
cvSum
to 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.