• DepthAI-v2
  • Problem finding camera when using the IP address

Hi!

I have configured the Oak Camera to use static IP and when running the following code it seems to work fine:

import depthai as dai

device_infos = dai.DeviceBootloader.getAllAvailableDevices()

device_infos:

[DeviceInfo(name=192.168.10.92, mxid=18334010B…, X_LINK_BOOTLOADER, X_LINK_TCP_IP, X_LINK_MYRIAD_X, X_LINK_SUCCESS)]*

However, when trying to access the device using the IP, it does not work:

device = dai.DeviceInfo(r'192.168.10.92')

device:

DeviceInfo(name=192.168.10.92, mxid=, X_LINK_ANY_STATE, X_LINK_ANY_PROTOCOL, X_LINK_ANY_PLATFORM, X_LINK_SUCCESS*)

Mxid is blank. This worked perfectly two days ago, but it has suddenly stopped working. I have tried to clear the static ip configuration and set it again, but it gave the same result.

What caused this and how do I solve it? I need to be able to connect to the cameras using static IP.

Thanks!

    Hi Kristoffer
    I think the device needs to bootup first before you get the whole DeviceInfo filled out.
    If you run the device info inside the with open loop, you should get the same info as in your first example.

    Or does the device not connect at all?

    Thanks,
    Jaka

    dai.DeviceInfo(IP) should be able to lookup the device info before bootup of the camera (at least that was its behavior a couple of days ago). getAllAvailableDevices() does not boot the camera first either.

    It is like it can't find the camera anymore when using dai.DeviceInfo(IP), so when using the incomplete data as in "with dai.Device(device_info) as device" it may connect or it may not.

      Hi Kristoffer
      IIRC getAllAvailableDevices() looks for connected devices while dai.DeviceInfo just serves as a holder for information and does not actively look for devices.

      What is the error you are getting when connecting to a device?

      My attempt:

      info = dai.DeviceInfo("192.168.2.173")
      print(info)
      
      # Connect to device and start pipeline
      with dai.Device(pipeline, devInfo=info) as device:
          deviceInfo = device.getDeviceInfo()
          print("Device info: ")
          print(deviceInfo)
          # Print out usb speed
          print('Usb speed:', device.getUsbSpeed().name)

      terminal output:

      DeviceInfo(name=192.168.2.173, mxid=, X_LINK_ANY_STATE, X_LINK_ANY_PROTOCOL, X_LINK_ANY_PLATFORM, X_LINK_SUCCESS)
      /Users/jaka/Desktop/depthai-python/examples/ColorCamera/rgb_preview.py:26: DeprecationWarning: Use constructor taking 'UsbSpeed' instead
        with dai.Device(pipeline, devInfo=info) as device:
      Device info: 
      DeviceInfo(name=192.168.2.173, mxid=1844301011ACFB0F00, X_LINK_BOOTED, X_LINK_TCP_IP, X_LINK_MYRIAD_X, X_LINK_SUCCESS)
      Usb speed: UNKNOWN

      Hope this helps,
      Jaka

      HI!

      I see, thanks for the clarification! I had some issues when reconnecting to a PoE device too fast as it could not find the device. I read a forum post to check for state X_LINK_BOOTLOADER, but that is not possible using your solution.

      I have now replaced it with a proper try except RuntimeError and retrying the connection in 5 seconds. This seems to solve the problem. I also had problems with race conditions (XLink) when creating pipelines too fast when using multiple cameras. This is "solved" using time.sleep(1) before creating the pipeline.

      Thanks for the help!

        Hi Kristoffer
        Yes the code I posted would not work for state checking. You would need getAllAvailableDevices() to check that.

        Thanks,
        Jaka