OpenCV-Python cv2.CV_CAP_PROP_POS_FRAMES error

别来无恙 提交于 2019-12-08 19:53:28

问题


Currently, I am using opencv 3.1.0, and I encountered the following error when executing the following code:

post_frame = cap.get(cv2.CV_CAP_PROP_POS_FRAMES)

I got the following error Message:

File "videoOperation.py", line 37, in pos_frame = cap.get(cv2.CV_CAP_PROP_POS_FRAMES) AttributeError: 'module' object has no attribute 'CV_CAP_PROP_POS_FRAMES'

The code should be written in the following format when using OpenCV 2.x:

post_frame = cap.get(cv2.cv.CV_CAP_PROP_POS_FRAMES)

From opencv 3.0.0-dev python bindings not working properly, I know that

the cv2.cv submodule got removed in opencv3.0, also some constants were changed

But the cv2.CV_CAP_PROP_POS_FRAMES didn't work for me, So what am I supposed to do?


回答1:


Try typing this instead:

post_frame = cap.get(1) #CAP_PROP_POS_FRAMES = 1

If you type help('cv2') in the Python shell you will find some modifications to the syntax. These are not all the Data. Just an illustration.

CAP_PROP_PAN = 33
CAP_PROP_POS_AVI_RATIO = 2
CAP_PROP_POS_FRAMES = 1
CAP_PROP_POS_MSEC = 0
CAP_PROP_PVAPI_BINNINGX = 304
CAP_PROP_PVAPI_BINNINGY = 305
CAP_PROP_PVAPI_DECIMATIONHORIZONTAL = 302



回答2:


You're looking for this:

post_frame = cap.get(cv2.CAP_PROP_POS_FRAMES)



回答3:


Should search for CV_CAP_PROP_POS_FRAMES in /usr/include/opencv2 or /usr/local/include etc. ,whichever is in your makefile include path . It would be in videoio/videoio_c.h or /videoio/legacy/constants_c.h . Use this in your include path #include . This is the right way .



来源:https://stackoverflow.com/questions/38563079/opencv-python-cv2-cv-cap-prop-pos-frames-error

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!