为了账号安全,请及时绑定邮箱和手机立即绑定

Raspi 摄像头模块无法在单独的进程中工作

Raspi 摄像头模块无法在单独的进程中工作

扬帆大鱼 2021-09-02 16:05:41
我正在尝试构建一个可以在 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)任何见解?
查看完整描述

1 回答

  • 1 回答
  • 0 关注
  • 142 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号