覆盆子pi 3 opencv python和pyinstaller

问题描述 投票:0回答:1

我已经使用这个OpenCV代码通过TCP捕获Raspberry picamera流,这段代码工作正常但是当我使用pyinstaller使用这个link创建可执行文件时

可执行文件不工作窗口消失在这里是我的代码:

#!/usr/bin/python

import cv2
import threading
import numpy as np
import socket
import sys
import pickle
import struct

cam1_ip = "tcp://192.168.7.14:9002"
cam2_ip = "tcp://192.168.7.10:9002"
cam3_ip = "tcp://192.168.7.12:9002"

class pvcameraThread(threading.Thread):
    def __init__(self, previewName, camSource):
        threading.Thread.__init__(self)
        self.previewName = previewName
        self.camSource = camSource
    def run(self):
        print ("Starting " + self.previewName)
        camPreview(self.previewName, self.camSource)

def camPreview(previewName, camSource):
    cv2.namedWindow(previewName)
    cam = cv2.VideoCapture(camSource)
    if cam.isOpened():  
        rval, frame = cam.read()
    else:
        rval = False

    while rval:
       # cv2.resizeWindow(previewName, 607,507)
        cv2.imshow(previewName, frame)
        rval, frame = cam.read()
        key = cv2.waitKey(1)
        if key == 113:  
            break
    cv2.destroyWindow(previewName)

if __name__ == '__main__':

    # Create two threads as follows
    cam1_previewthread = pvcameraThread("CAM1_Preview", cam1_ip)
    cam2_previewthread = pvcameraThread("CAM2_Preview", cam2_ip)
    cam3_previewthread = pvcameraThread("CAM3_Preview", cam3_ip)
    cam1_previewthread.start()
    cam2_previewthread.start()
    cam3_previewthread.start()
	
	
i
python opencv tcp video-streaming executable
1个回答
-1
投票

我认为这个答案会对你有所帮助。这个答案的总结是pyinstaller并不完美,有时你需要手动添加库。 https://stackoverflow.com/a/38987705/10373782

© www.soinside.com 2019 - 2024. All rights reserved.