OpenCV / Array should be CvMat or IplImage / Releasing a capture object

匿名 (未验证) 提交于 2019-12-03 02:29:01

问题:

Edit : Array should be CvMat or IplImage is not an error message specific to this issue, that's the only most relevant error message i got.


I'm trying to make an *.exe out of an application using opencv.

I'm using Python 2.6 and openCV 2.1.

I can run part of the *.exe, i'm having a menu from where i can choose to process some pictures from 2 differents sources my webcam & a static image. The static image part works but when i'm chosing the webcam here is the output:

OpenCV Error: Bad argument (Array should be CvMat or IplImage) in unknown function, file ..\..\..\..\ocv\opencv\src\cxcore\cxarray.cpp,  line 1233 Traceback (most recent call last):   File "_ctypes/callbacks.c", line 295, in 'calling callback function'   File "game_ar\build\pyi.win32\game_ar\outPYZ1.pyz/pyglet.window.win32", line 849, in _wnd_proc   File "game_ar\build\pyi.win32\game_ar\outPYZ1.pyz/pyglet.window.win32", line 918, in _event_key   File "game_ar\build\pyi.win32\game_ar\outPYZ1.pyz/pyglet.window", line 1219, in dispatch_event   File "game_ar\build\pyi.win32\game_ar\outPYZ1.pyz/pyglet.event", line 340, in dispatch_event   File "", line 502, in on_key_press   File "", line 461, in dostart   File "", line 482, in getpoints   File "D:\Prog\Python\AugmentedR\src\pyar.py", line 40, in get_points     pilimage = Image.fromstring("RGB", cv.GetSize(image), image.tostring()) cv.error: Array should be CvMat or IplImage Traceback (most recent call last):   File "", line 616, in    File "game_ar\build\pyi.win32\game_ar\outPYZ1.pyz/pyglet.app", line 264, in run   File "game_ar\build\pyi.win32\game_ar\outPYZ1.pyz/pyglet.app.win32", line 63, in run   File "game_ar\build\pyi.win32\game_ar\outPYZ1.pyz/pyglet.app.win32", line 84, in _timer_func   File "game_ar\build\pyi.win32\game_ar\outPYZ1.pyz/pyglet.app", line 193, in idle   File "game_ar\build\pyi.win32\game_ar\outPYZ1.pyz/pyglet.window", line 1219, in dispatch_event   File "game_ar\build\pyi.win32\game_ar\outPYZ1.pyz/pyglet.event", line 340, in dispatch_event   File "", line 546, in on_draw AttributeError: Game instance has no attribute 'bg' 

My pyar.py file.

Building the *.exe with py2exe gave me this output :

 The following modules appear to be missing ['ICCProfile', '_imaging_gif', '_scproxy'] 

I don't get it, this is working with my sources. I tried to pack my application with py2exe & pyinstaller, but the output is the same.

I guess the *.exe is missing something but i don't know what neither how to debug it.

回答1:

It was not related to the packagers.

The problem was that I wasn't closing the webcam capture, several processes of my app were actually running in the background.

The doc is talking about ReleaseCapture but this function is apparently not in the python bindings, calling :

del(self.cam)

did the job just well, self.cam being my CvCapture object.



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