树莓派摄像头资源占用, 运行别的程序报错: VIDIOC_STREAMON: Invalid argument解决资源占用
场景:
树莓派3B+
摄像头是官方的:
我先使用摄像头识别颜色, 接着用摄像头识别二维码,
颜色可以识别完成, 再调用函数识别二维码时, 报错
报错如下:
mmal: mmal_vc_port_enable: failed to enable port vc.null_sink:in:0(OPQV): ENOSPC
mmal: mmal_port_enable: failed to enable connected port (vc.null_sink:in:0(OPQV))0x16b90b0 (ENOSPC)
mmal: mmal_connection_enable: output port couldn't be enabled
Traceback (most recent call last):
File "main.py", line 91, in <module>
color_temp = recog_color()
File "/home/pi/Desktop/GO/recog_color.py", line 35, in recog_color
camera = PiCamera()
File "/usr/lib/python2.7/dist-packages/picamera/camera.py", line 433, in __init__
self._init_preview()
File "/usr/lib/python2.7/dist-packages/picamera/camera.py", line 513, in _init_preview
self, self._camera.outputs[self.CAMERA_PREVIEW_PORT])
File "/usr/lib/python2.7/dist-packages/picamera/renderers.py", line 558, in __init__
self.renderer.inputs[0].connect(source).enable()
File "/usr/lib/python2.7/dist-packages/picamera/mmalobj.py", line 2212, in enable
prefix="Failed to enable connection")
File "/usr/lib/python2.7/dist-packages/picamera/exc.py", line 184, in mmal_check
raise PiCameraMMALError(status, prefix)
picamera.exc.PiCameraMMALError: Failed to enable connection: Out of resources
pi@raspberrypi:~/Desktop/GO $ python main.py
/usr/lib/python2.7/dist-packages/picamera/encoders.py:544: PiCameraResolutionRounded: frame size rounded up from 150x150 to 160x160
width, height, fwidth, fheight)))
[[array([ 35, 128, 46]), array([ 77, 255, 255]), 2], [array([100, 40, 40]), array([140, 255, 255]), 3]]
[[array([100, 40, 40]), array([140, 255, 255]), 3]]
[]
VIDIOC_STREAMON: Invalid argument
摄像头的问题
None
Traceback (most recent call last):
File "main.py", line 116, in <module>
print_SPI(QRcode_str)
File "/home/pi/Desktop/GO/print_SPI.py", line 64, in print_SPI
draw.text((15, 96), str[0], fill = x2color_dict[ str[0] ], font = font)
TypeError: 'NoneType' object has no attribute '__getitem__'
主要还是 VIDIOC_STREAMON: Invalid argument 的问题,
是不是得手动释放摄像头资源啊???求解决, 或者, 如何手动释放摄像头资源??
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我知道了, 是我搞软件的不会搞硬件, 大家可以查查SPI接线 的接法。。。。。
一个参数错误,一个类型错误,先看下文档解决这两个问题再搞其他的。