我使用的是python3和openni2。
当我打开与相机的通信时(在本例中我使用的是Orbbec Astra),是否可以读取相机的序列号?
这是我打开通信的方式:
dev = openni2.Device.open_any()
depth_stream = dev.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))我的目标是每次都能找到相同的摄像头,即使我更换了usb端口,而且我有更多的orrbec连接。
谢谢
发布于 2017-07-12 20:43:36
我不知道python的确切版本,但在旧的OpenNI C++库中,您可以使用类似于以下内容的内容来查询设备id:
openni::Array deviceList;
openni::OpenNI::enumerateDevices(&deviceList);
for(int i = 0; i != deviceList.getSize(); i++) {
const openni::DeviceInfo& info = deviceList[i];
std::string uri = info.getUri();
cout << "URI " << i << ": " << uri << "\n";
}很可能存在一个包装底层DeviceInfo类及其功能的python类,因此您可以请求Uri。
发布于 2018-08-08 20:57:39
import ctypes
from primesense import openni2 # , nite2
from primesense import _openni2 as c_api
serial_number = str(dev.get_property(c_api.ONI_DEVICE_PROPERTY_SERIAL_NUMBER, (ctypes.c_char * 100)).value)你可能想清理一下你得到的字符串。(在orbbec astra上测试)。
我使用以下链接找到了答案:
https://github.com/OpenNI/OpenNI2/blob/master/Include/OniProperties.h http://docs.ros.org/api/openni2_camera/html/openni2__device__manager_8cpp_source.html
https://stackoverflow.com/questions/45057526
复制相似问题