我正在嘗試構建一個可以在 Raspberry Pi 上運行的多進程應用程序。其中一個進程應該從 rpi 相機獲取一幀并將其保存到磁盤以供其他進程之一使用。但是,pythonmultiprocessing.Process類處理 rpi 相機模塊的方式有些奇怪?;旧?,如果我嘗試在 a 中運行 rpi 相機模塊Process,它會for frame in self.camera.capture_continuous在線路上凍結。下面是一些示例代碼:主文件from multiprocessing import Processimport camera as cimport time, atexit, shdef cleanUp(): print("Killed the following processes:\n{}".format( sh.grep(sh.ps("aux", _piped=True), "python3"))) sh.pkill("python3")# Used to keep any of the processes from being orphanedatexit.register(cleanUp)proc = Process(target=c.run)proc.start()while True: time.sleep(1) print("main")相機.pyfrom picamera.array import PiRGBArrayfrom picamera import PiCameraimport cv2camera = PiCamera()camera.resolution = (1280, 720)camera.framerate = 30rawCapture = PiRGBArray(camera, size=(1280, 720))def run(): print("run function started") for frame in camera.capture_continuous(rawCapture, format="bgr", use_video_port=True): print("this never runs") cv2.imwrite('frame.jpg', frame.array) rawCapture.truncate(0)任何見解?
添加回答
舉報
0/150
提交
取消