如何捕获"OpenCV错误"?在Python中 [英] How to catch "OpenCV Error" in Python
问题描述
如果出现OpenCV错误:...
If I get OpenCV Error: ...
由于OpenCV Error使用两个词,捕获它的语法是什么?我可以捕获以下cv.error,但是我将如何捕获呢?
what's the syntax to catch it since OpenCV Error uses two words? I'm able to catch the following cv.error but how would I catch this?
我不明白...答案很明显吗?我不清楚吗?
I don't get it... is the answer obvious? Am I being unclear?
编辑2
我无法在其他计算机上复制它,但它看起来类似于:
I can't reproduce it b/c I'm on a different computer but it looked similar to:
OpenCV Error: Bad argument. Something something array
cv.error: This is another error
我能够通过以下命令捕获cv.error但不能捕获OpenCV错误:
I'm able to catch cv.error but not OpenCV Error with the following:
try:
# do a thing
except (cv.error, OpenCV Error):
print "Can't do the thing"
sys.exit(1)
推荐答案
尝试cv2.error
.
try:
...
except cv2.error as e:
...
这是文档中的页面,但这是仅适用于C/C ++接口-在OpenCV的Python错误处理中找不到任何内容(可悲的是,我找不到Python接口的文档).
Here's the page from the documentation but it's only for the C/C++ interface -- I can't find anything on the Python error handling for OpenCV (I find the documentation for the Python interface to be sadly lacking).
这篇关于如何捕获"OpenCV错误"?在Python中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!