简体   繁体   中英

Raspberry pi 3 opencv python and pyinstaller

I have used this OpenCV code to capture Raspberry picamera stream over TCP and this code is working properly but when I made executable using pyinstaller using this link

the executable isn't working windows disappears here is my code:

 #!/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 

I think this answer will help you. Summary of this answer is pyinstaller is not perfect and Sometimes you need to manually add libraries. https://stackoverflow.com/a/38987705/10373782

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM