簡體   English   中英

py2exe上的網絡攝像頭無法正常工作

[英]webcam on py2exe doesn't work correctly

嗨,我編寫了一個使用網絡攝像頭的程序,但是當我通過py2exe使它成為exe時 ,由於該錯誤而崩潰。

錯誤:

這是我的代碼

import pygame.camera
import pygame.image
import sys
pygame.camera.init()
cameras = pygame.camera.list_cameras()


webcam = pygame.camera.Camera(cameras[0])

webcam.start()

 # grab first frame
img = webcam.get_image()

WIDTH = img.get_width()
HEIGHT = img.get_height()

screen = pygame.display.set_mode( ( WIDTH, HEIGHT ) )
pygame.display.set_caption("pyGame Camera View")

while True :
    for e in pygame.event.get() :
        if e.type == pygame.QUIT :
            sys.exit()

     # draw frame
    screen.blit(img, (0,0))
    pygame.display.flip()
     # grab next frame    
    img = webcam.get_image()

謝謝 :)

不知道這是否行得通(我無法在計算機上運行python代碼),但是您是否嘗試過pyinstaller而不是Py2Exe( http://pyinstaller.org )?

嗨,大家好,我終於可以使用cx_freeze制作一個可執行文件,該文件可以與相機一起使用,解決方案是將vidcapture.pyd復制到具有程序的文件中

這張照片是我的文件,其中包含vidcapture.pyd

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM