【发布时间】:2015-07-13 00:48:57
【问题描述】:
我正在编写一个简单的安全摄像头程序。
我使用该代码访问相机:
import cv
camera = cv.CaptureFromCAM(0)
我尝试了 .py 文件。有效。但是,当我编译并运行 exe 文件时,我无法访问相机。程序没有反应。在 .py 文件中,我可以从标题为“视频源”的窗口中选择相机。
我认为这个关于访问权限的问题。
之后,我通过 Visual Studio 2010 的“调试”功能打开了 exe 文件。我收到了警告:
Unhandled exception at 0x02691fcb in security_camera.exe: 0xC0000005: Access violation writing location 0x00000000.
顺便说一句,我从“输出”选项卡中得到了这些输出:
'security_camera.exe': Loaded '[file_path(C:\Users\........)]', Binary was not built with debug information.
'security_camera.exe': Loaded 'C:\Windows\System32\ntdll.dll', Cannot find or open the PDB file
'security_camera.exe': Loaded 'C:\Windows\System32\kernel32.dll', Cannot find or open the PDB file
'security_camera.exe': Loaded 'C:\Windows\System32\KernelBase.dll', Cannot find or open the PDB file
'security_camera.exe': Loaded 'C:\Windows\System32\user32.dll', Cannot find or open the PDB file
'security_camera.exe': Loaded 'C:\Windows\System32\gdi32.dll', Cannot find or open the PDB file
'security_camera.exe': Loaded 'C:\Windows\System32\lpk.dll', Cannot find or open the PDB file
'security_camera.exe': Loaded 'C:\Windows\System32\usp10.dll', Cannot find or open the PDB file
'security_camera.exe': Loaded 'C:\Windows\System32\msvcrt.dll', Cannot find or open the PDB file
'security_camera.exe': Loaded 'C:\Windows\winsxs\x86_microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.30729.6161_none_50934f2ebcb7eb57\msvcr90.dll', Cannot find or open the PDB file
'security_camera.exe': Loaded 'C:\Windows\System32\imm32.dll', Cannot find or open the PDB file
'security_camera.exe': Loaded 'C:\Windows\System32\msctf.dll', Cannot find or open the PDB file
'security_camera.exe': Loaded 'C:\Windows\System32\nvinit.dll', Cannot find or open the PDB file
'security_camera.exe': Loaded 'C:\Windows\System32\advapi32.dll', Cannot find or open the PDB file
'security_camera.exe': Loaded 'C:\Windows\System32\sechost.dll', Cannot find or open the PDB file
'security_camera.exe': Loaded 'C:\Windows\System32\rpcrt4.dll', Cannot find or open the PDB file
'security_camera.exe': Loaded 'C:\Windows\System32\guard32.dll', Cannot find or open the PDB file
'security_camera.exe': Loaded 'C:\Windows\System32\version.dll', Cannot find or open the PDB file
'security_camera.exe': Loaded 'C:\Windows\System32\psapi.dll', Cannot find or open the PDB file
'security_camera.exe': Loaded 'C:\Windows\System32\fltLib.dll', Cannot find or open the PDB file
'security_camera.exe': Loaded 'C:\Windows\System32\shell32.dll', Cannot find or open the PDB file
'security_camera.exe': Loaded 'C:\Windows\System32\shlwapi.dll', Cannot find or open the PDB file
'security_camera.exe': Loaded 'C:\Windows\System32\winmm.dll', Cannot find or open the PDB file
'security_camera.exe': Loaded 'C:\Windows\System32\ole32.dll', Cannot find or open the PDB file
'security_camera.exe': Loaded 'C:\Windows\winsxs\x86_microsoft.windows.common-controls_6595b64144ccf1df_5.82.7601.18201_none_ec80f00e8593ece5\comctl32.dll', Cannot find or open the PDB file
'security_camera.exe': Loaded 'C:\Windows\System32\oleaut32.dll', Cannot find or open the PDB file
'security_camera.exe': Loaded 'C:\Windows\System32\cryptsp.dll', Cannot find or open the PDB file
'security_camera.exe': Loaded 'C:\Windows\System32\rsaenh.dll', Cannot find or open the PDB file
'security_camera.exe': Loaded 'C:\Windows\System32\cryptbase.dll', Cannot find or open the PDB file
'security_camera.exe': Loaded 'C:\Windows\System32\ws2_32.dll', Cannot find or open the PDB file
'security_camera.exe': Loaded 'C:\Windows\System32\nsi.dll', Cannot find or open the PDB file
'security_camera.exe': Loaded 'C:\Windows\System32\comdlg32.dll', Cannot find or open the PDB file
First-chance exception at 0x02691fcb in security_camera.exe: 0xC0000005: Access violation writing location 0x00000000.
Unhandled exception at 0x02691fcb in security_camera.exe: 0xC0000005: Access violation writing location 0x00000000.
First-chance exception at 0x02691fcb in security_camera.exe: 0xC0000005: Access violation writing location 0x00000000.
Unhandled exception at 0x02691fcb in security_camera.exe: 0xC0000005: Access violation writing location 0x00000000.
First-chance exception at 0x02691fcb in security_camera.exe: 0xC0000005: Access violation writing location 0x00000000.
Unhandled exception at 0x02691fcb in security_camera.exe: 0xC0000005: Access violation writing location 0x00000000.
First-chance exception at 0x02691fcb in security_camera.exe: 0xC0000005: Access violation writing location 0x00000000.
Unhandled exception at 0x02691fcb in security_camera.exe: 0xC0000005: Access violation writing location 0x00000000.
First-chance exception at 0x02691fcb in security_camera.exe: 0xC0000005: Access violation writing location 0x00000000.
Unhandled exception at 0x02691fcb in security_camera.exe: 0xC0000005: Access violation writing location 0x00000000.
First-chance exception at 0x02691fcb in security_camera.exe: 0xC0000005: Access violation writing location 0x00000000.
Unhandled exception at 0x02691fcb in security_camera.exe: 0xC0000005: Access violation writing location 0x00000000.
First-chance exception at 0x02691fcb in security_camera.exe: 0xC0000005: Access violation writing location 0x00000000.
Unhandled exception at 0x02691fcb in security_camera.exe: 0xC0000005: Access violation writing location 0x00000000.
First-chance exception at 0x02691fcb in security_camera.exe: 0xC0000005: Access violation writing location 0x00000000.
Unhandled exception at 0x02691fcb in security_camera.exe: 0xC0000005: Access violation writing location 0x00000000.
First-chance exception at 0x02691fcb in security_camera.exe: 0xC0000005: Access violation writing location 0x00000000.
Unhandled exception at 0x02691fcb in security_camera.exe: 0xC0000005: Access violation writing location 0x00000000.
First-chance exception at 0x02691fcb in security_camera.exe: 0xC0000005: Access violation writing location 0x00000000.
Unhandled exception at 0x02691fcb in security_camera.exe: 0xC0000005: Access violation writing location 0x00000000.
First-chance exception at 0x02691fcb in security_camera.exe: 0xC0000005: Access violation writing location 0x00000000.
Unhandled exception at 0x02691fcb in security_camera.exe: 0xC0000005: Access violation writing location 0x00000000.
The program '[8604] security_camera.exe: Native' has exited with code -1073741819 (0xc0000005).
顺便说一句,当我打开 exe 文件(程序)时,它会在 3-4 秒内关闭。
我该如何解决?谢谢。
注意: 我的python版本:2.7.3
我使用的是 Windows 7(32 位)
编辑:
我通过py2exe构建了exe文件。
我的 setup.py 是这样的:
from distutils.core import setup
import py2exe, sys, os
sys.argv.append('py2exe')
setup(
options = {'py2exe': {'bundle_files': 1, 'compressed': True, 'includes': 'numpy'}},
windows = [{'script': "security_camera.py"}],
zipfile = None,
)
【问题讨论】:
-
我是用 py2exe 构建的。我的设置文件是: from distutils.core import setup import py2exe, sys, os sys.argv.append('py2exe') setup( options = {'py2exe': {'bundle_files': 1, 'compressed': True, 'includes': 'numpy'}}, windows = [{'script': "security_camera.py"}], zipfile = None, )
-
不相关,但您应该使用 cv2 而不是已弃用的 cv 模块
-
但是,我使用了来自互联网的代码。我是从互联网上找到它们的。在来自互联网的代码中,程序员(编写这些代码)使用了 cv 模块。 cv的用法和cv2的用法不一样,不知道怎么把这些代码转成cv2。
-
只知道,这个api在opencv3.0中被删除了。
标签: python opencv camera py2exe pyinstaller