Search code examples
pythonpython-3.xopenniorbbec

Get the serial number of a camera - Openni2 python


I'm using python3 and openni2.

When I open the communication with a camera (in this case I'm using an Orbbec Astra), is it possible to read the serial number of the camera?

This is how I open the communication:

    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))

My goal is to find everytime the same camera even if I change the usb port and I've more orrbec connected.

Thank you


Solution

  • I don't know exactly about the python version, but in the old OpenNI C++ library, you were able to query the device id with something similar to following:

    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";
     }
    

    Most probably there could be a python class wrapping the underlying DeviceInfo class and its capabilities, so you can ask for the Uri.