English 中文(简体)
如何捕获“OpenCV Error”
原标题:How to catch "OpenCV Error" in Python

如果我收到开放式护照,则:......

开放式低地轨道后用两字来抓获吗? 我能赶上下面的 c子,但我会如何赶上?

EDIT:

I don t get it... is the answer obvious? Am I being unclear?

<EDIT 2

我可以在不同的计算机上照搬它。

OpenCV 错误: 反对。 一些阵列

cv.error: 这是另一个错误:

I m 能够捕捉 c器,但不能捕捉露天焚烧场。

try:
    # do a thing
except (cv.error, OpenCV Error):
    print "Can t do the thing"
    sys.exit(1)
最佳回答

Try cv2.error

try:
    ...
except cv2.error as e:
    ...

这里是文件上的页,但只供C/C++接口使用——我找不到任何关于露天CV处理中的“灰色”错误之处(我发现关于“灰色”接口的文件令人悲伤。

问题回答

你们可以很容易地检查错误物体,就像你一样。

fvs = imutils.video.FileVideoStream(args.input).start()

while fvs.more():

  frame = fvs.read()

  try:
    
    grayframe = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)

  except cv2.error as e:
    
    # inspect error object
    print(e)
    for k in dir(e):
      if k[0:2] != "__":
        print("e.%s = %s" % (k, getattr(e, k)))

    # handle error: empty frame
    if e.err == "!_src.empty()":
      break # break the while loop




相关问题
Can Django models use MySQL functions?

Is there a way to force Django models to pass a field to a MySQL function every time the model data is read or loaded? To clarify what I mean in SQL, I want the Django model to produce something like ...

An enterprise scheduler for python (like quartz)

I am looking for an enterprise tasks scheduler for python, like quartz is for Java. Requirements: Persistent: if the process restarts or the machine restarts, then all the jobs must stay there and ...

How to remove unique, then duplicate dictionaries in a list?

Given the following list that contains some duplicate and some unique dictionaries, what is the best method to remove unique dictionaries first, then reduce the duplicate dictionaries to single ...

What is suggested seed value to use with random.seed()?

Simple enough question: I m using python random module to generate random integers. I want to know what is the suggested value to use with the random.seed() function? Currently I am letting this ...

How can I make the PyDev editor selectively ignore errors?

I m using PyDev under Eclipse to write some Jython code. I ve got numerous instances where I need to do something like this: import com.work.project.component.client.Interface.ISubInterface as ...

How do I profile `paster serve` s startup time?

Python s paster serve app.ini is taking longer than I would like to be ready for the first request. I know how to profile requests with middleware, but how do I profile the initialization time? I ...

Pragmatically adding give-aways/freebies to an online store

Our business currently has an online store and recently we ve been offering free specials to our customers. Right now, we simply display the special and give the buyer a notice stating we will add the ...

Converting Dictionary to List? [duplicate]

I m trying to convert a Python dictionary into a Python list, in order to perform some calculations. #My dictionary dict = {} dict[ Capital ]="London" dict[ Food ]="Fish&Chips" dict[ 2012 ]="...

热门标签