Python& openni2:在不同的进程中同时使用2个摄像头

时间:2017-05-30 13:49:26

标签: python opencv openni

我在xubuntu 16.04中使用了2个摄像头(Orbbec Astra Mini)和python3,opencv3.2和openNi2。

我可以阅读1个摄像头,我可以选择读取哪个(更改dev [0])

[[ 3  2]
 [ 2 13]]

问题在于,如果我开始另一个读取其他相机的过程,它会崩溃并说:

dev = openni2.Device.open_all()
    depth_stream = dev[0].create_depth_stream()
    depth_stream.start()
    depth_stream.set_video_mode(c_api.OniVideoMode(pixelFormat = c_api.OniPixelFormat.ONI_PIXEL_FORMAT_DEPTH_100_UM, resolutionX = 320, resolutionY = 240, fps = 30))

我试图将相机插入同一总线和不同的总线。现在,它们在usb3.0中插入一个,在usb2.0中插入另一个。

如果在单个进程中调用它们,当我启动第二个(具有不同设备索引的相同代码)时,它们都工作。第二个不起作用。

使用解决方案进行编辑: 我解决了在openni2.py中创建新函数的问题:

  File "/home/stark/.local/lib/python3.5/site-packages/primesense/openni2.py", line 230, in open_all
    return [cls(uri) for uri in cls.enumerate_uris()]
  File "/home/stark/.local/lib/python3.5/site-packages/primesense/openni2.py", line 230, in <listcomp>
    return [cls(uri) for uri in cls.enumerate_uris()]
  File "/home/stark/.local/lib/python3.5/site-packages/primesense/openni2.py", line 199, in __init__
    self._reopen()
  File "/home/stark/.local/lib/python3.5/site-packages/primesense/openni2.py", line 209, in _reopen
    c_api.oniDeviceOpen(self._orig_uri, ctypes.byref(self._handle))
  File "/home/stark/.local/lib/python3.5/site-packages/primesense/_openni2.py", line 2102, in wrapper
    raise OpenNIError(res, msg.strip(), logfile)
primesense.utils.OpenNIError: (OniStatus.ONI_STATUS_ERROR, b'Could not open "2bc5/0404@1/10": Failed to set USB interface!', None)

感谢:https://3dclub.orbbec3d.com/t/python-openni2-use-2-cameras-at-the-same-time-in-different-processes/935

0 个答案:

没有答案