Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how to specify IP address of OAK-D Pro #26

Open
stephanschulz opened this issue Aug 13, 2022 · 7 comments
Open

how to specify IP address of OAK-D Pro #26

stephanschulz opened this issue Aug 13, 2022 · 7 comments

Comments

@stephanschulz
Copy link

I know this might be a question for the depthai github account but their examples do not seem to use your code structure.

I have multiple OAK-D pros connected to the same network, each with their own fixed IP address.
I am hoping to define in the code which device to connect to.

But doing this does not work:

        device_info = dai.DeviceInfo("10.100.0.21")
        self.device = dai.Device(device_info)

https://github.com/geaxgx/depthai_blazepose/blob/main/BlazeposeDepthaiEdge.py#L104

But in their example they are using a structure that does not seem to match the way you write your code:

device_info = dai.DeviceInfo("169.254.1.222")
# device_info = depthai.DeviceInfo("14442C108144F1D000") # MXID
# device_info = depthai.DeviceInfo("3.3.3") # USB port name

with dai.Device(pipeline, device_info) as device:
    qRgb = device.getOutputQueue(name="rgb", maxSize=4, blocking=False)
    while True:
        cv2.imshow("rgb", qRgb.get().getCvFrame())
        if cv2.waitKey(1) == ord('q'):
            break
``
https://docs.luxonis.com/projects/hardware/en/latest/pages/guides/getting-started-with-poe.html#manually-specify-device-ip

Thanks again for any advice.
@geaxgx
Copy link
Owner

geaxgx commented Aug 13, 2022

I don't have any POE device to test and I am realizing that my scripts don't work on POE devices without modification of the scripts.
What error message do you get when doing

        device_info = dai.DeviceInfo("10.100.0.21")
        self.device = dai.Device(device_info)

?
Can you try with an empty pipeline ?

        device_info = dai.DeviceInfo("10.100.0.21")
        self.device = dai.Device(dai.Pipeline(), device_info)

If you don't any get error with empty pipeline, can you in addition replace:

        usb_speed = self.device.getUsbSpeed()
        self.device.startPipeline(self.create_pipeline())

by:

      self.device.startPipeline(self.create_pipeline(), device_info)

?

@stephanschulz
Copy link
Author

for reference here is my current project which runs fine on the OAK-D pro POE and sends out the landmark data over OSC.

https://github.com/stephanschulz/depthai_blazepose/tree/main/depthai_osc
Screen Shot 2022-08-13 at 9 43 02 AM

adding

 device_info = dai.DeviceInfo("10.100.0.21")
 self.device = dai.Device(dai.Pipeline(), device_info)

produces this error

Traceback (most recent call last):
  File "demo_osc.py", line 56, in <module>
    tracker = BlazeposeDepthai(input_src=args.input, 
  File "/Users/stephanschulz/Documents/depthai-python-2/depthai_blazepose/depthai_osc/BlazeposeDepthaiEdge_osc.py", line 198, in __init__
    self.device.startPipeline(self.create_pipeline())
RuntimeError: Pipeline is already running

adding:

#        usb_speed = self.device.getUsbSpeed()
#        self.device.startPipeline(self.create_pipeline())
#        print(f"Pipeline started - USB speed: {str(usb_speed).split('.')[-1]}")
        device_info = dai.DeviceInfo("10.100.0.21")
        self.device.startPipeline(self.create_pipeline(), device_info)

causes this error message

stephanschulz@Komputer depthai_osc % python3.8 demo_osc.py -e -v --oscIP 10.100.0.101 --oscPort 12345
Pose detection blob file : /Users/stephanschulz/Documents/depthai-python-2/depthai_blazepose/depthai_osc/models/pose_detection_sh4.blob
Landmarks using blob file : /Users/stephanschulz/Documents/depthai-python-2/depthai_blazepose/depthai_osc/models/pose_landmark_full_sh4.blob
amount of getAllAvailableDevices 1
18443010C121C61200 XLinkDeviceState.X_LINK_BOOTLOADER
Internal camera FPS set to: 20
Internal camera image size: 800 x 450 - pad_h: 175
Creating pipeline...
setIrFloodLightBrightness None
setIrLaserDotProjectorBrightness None
Creating Color Camera...
Creating Pose Detection pre processing image manip...
Creating Pose Detection Neural Network...
Creating Pose Detection post processing Neural Network...
Creating Landmark pre processing image manip...
Creating DiveideBy255 Neural Network...
Creating Landmark Neural Network...
Pipeline created.
Traceback (most recent call last):
  File "demo_osc.py", line 56, in <module>
    tracker = BlazeposeDepthai(input_src=args.input, 
  File "/Users/stephanschulz/Documents/depthai-python-2/depthai_blazepose/depthai_osc/BlazeposeDepthaiEdge_osc.py", line 201, in __init__
    self.device.startPipeline(self.create_pipeline(), device_info)
TypeError: startPipeline(): incompatible function arguments. The following argument types are supported:
    1. (self: depthai.DeviceBase) -> None
    2. (self: depthai.DeviceBase, arg0: depthai.Pipeline) -> bool

Invoked with: <depthai.Device object at 0x7ff98e80a130>, <depthai.Pipeline object at 0x7ff98d7d6970>, DeviceInfo(name=10.100.0.21, mxid=, X_LINK_ANY_STATE, X_LINK_ANY_PROTOCOL, X_LINK_ANY_PLATFORM, X_LINK_SUCCESS)

@stephanschulz
Copy link
Author

What error message do you get when doing

    device_info = dai.DeviceInfo("10.100.0.21")
    self.device = dai.Device(device_info)

?

stephanschulz@Komputer depthai_osc % python3.8 demo_osc.py -e -v --oscIP 10.100.0.101 --oscPort 12345
Pose detection blob file : /Users/stephanschulz/Documents/depthai-python-2/depthai_blazepose/depthai_osc/models/pose_detection_sh4.blob
Landmarks using blob file : /Users/stephanschulz/Documents/depthai-python-2/depthai_blazepose/depthai_osc/models/pose_landmark_full_sh4.blob
amount of getAllAvailableDevices 1
18443010C121C61200 XLinkDeviceState.X_LINK_BOOTLOADER
Traceback (most recent call last):
  File "demo_osc.py", line 56, in <module>
    tracker = BlazeposeDepthai(input_src=args.input, 
  File "/Users/stephanschulz/Documents/depthai-python-2/depthai_blazepose/depthai_osc/BlazeposeDepthaiEdge_osc.py", line 115, in __init__
    self.device = dai.Device(device_info)
TypeError: __init__(): incompatible constructor arguments. The following argument types are supported:
    1. depthai.Device(pipeline: depthai.Pipeline)
    2. depthai.Device(pipeline: depthai.Pipeline, usb2Mode: bool)
    3. depthai.Device(pipeline: depthai.Pipeline, maxUsbSpeed: depthai.UsbSpeed)
    4. depthai.Device(pipeline: depthai.Pipeline, pathToCmd: Path)
    5. depthai.Device(pipeline: depthai.Pipeline, devInfo: depthai.DeviceInfo, usb2Mode: bool = False)
    6. depthai.Device(pipeline: depthai.Pipeline, deviceInfo: depthai.DeviceInfo, maxUsbSpeed: depthai.UsbSpeed)
    7. depthai.Device(pipeline: depthai.Pipeline, devInfo: depthai.DeviceInfo, pathToCmd: Path)
    8. depthai.Device(version: depthai.OpenVINO.Version = <Version.???: 6>)
    9. depthai.Device(version: depthai.OpenVINO.Version, usb2Mode: bool = False)
    10. depthai.Device(version: depthai.OpenVINO.Version, maxUsbSpeed: depthai.UsbSpeed)
    11. depthai.Device(version: depthai.OpenVINO.Version, pathToCmd: Path)
    12. depthai.Device(version: depthai.OpenVINO.Version, deviceInfo: depthai.DeviceInfo, usb2Mode: bool = False)
    13. depthai.Device(version: depthai.OpenVINO.Version, deviceInfo: depthai.DeviceInfo, maxUsbSpeed: depthai.UsbSpeed)
    14. depthai.Device(version: depthai.OpenVINO.Version, deviceDesc: depthai.DeviceInfo, pathToCmd: Path)
    15. depthai.Device(config: depthai.Device.Config)
    16. depthai.Device(config: depthai.Device.Config, deviceInfo: depthai.DeviceInfo)

Invoked with: DeviceInfo(name=10.100.0.21, mxid=, X_LINK_ANY_STATE, X_LINK_ANY_PROTOCOL, X_LINK_ANY_PLATFORM, X_LINK_SUCCESS)

@stephanschulz
Copy link
Author

stephanschulz commented Aug 13, 2022

here in this test branch i try to first create a pipleline
then start the device with the device_info
https://github.com/stephanschulz/depthai_blazepose/blob/test_pipeline/depthai_osc/BlazeposeDepthaiEdge_osc.py#L109

        self.pipeline = dai.Pipeline()
        device_info = dai.DeviceInfo("10.100.0.21")
        self.device = dai.Device(self.pipeline, device_info)

I had to modify the create_pipeline function to not 'create pipeline' but rather set related values.
But now i get this error:
RuntimeError: Queue for stream name 'cam_out' doesn't exist

Connected cameras: [<CameraBoardSocket.RGB: 0>, <CameraBoardSocket.LEFT: 1>, <CameraBoardSocket.RIGHT: 2>]
Traceback (most recent call last):
  File "demo_osc.py", line 56, in <module>
    tracker = BlazeposeDepthai(input_src=args.input, 
  File "/Users/stephanschulz/Documents/depthai-python-2/depthai_blazepose/depthai_osc/BlazeposeDepthaiEdge_osc.py", line 220, in __init__
    self.q_video = self.device.getOutputQueue(name="cam_out", maxSize=1, blocking=False)
RuntimeError: Queue for stream name 'cam_out' doesn't exist

Probably 'cam_out' is not seen because it was added too late?

@geaxgx
Copy link
Owner

geaxgx commented Aug 14, 2022

Actually, in my code, I separated the

self.device = dai.Device()

from the:
self.device.startPipeline(self.create_pipeline())

because between the 2 lines, I wanted to check if I the device of the user had 2 mono cameras in case he used the '-xyz' argument. it is a bit superfluous test (you can do without it). So I propose in your case to regroup the 2 commands and remove the test.
In practice:

  • suppress line 104,
  • replace lines between 111 and 116 with : self.xyz = True
  • replace lines 179 and 180 with:
        device_info = dai.DeviceInfo("10.100.0.21")
        self.device = dai.Device(self.create_pipeline(), device_info)

@stephanschulz
Copy link
Author

stephanschulz commented Aug 14, 2022

Thank you very much.

In addition i also had to comment out these lines inside def create_pipeline(self): because they references self.device which at this point does not exists.

calib_data = self.device.readCalibration()
https://gist.github.com/stephanschulz/81d95799ac90484c055136dd70cd55d8#file-blazeposedepthaiedge-py-L240

Since these lines are needed for lens calibration i wonder if they should be added somewhere else ?
After that all this the device_info thing works :)

@geaxgx
Copy link
Owner

geaxgx commented Aug 15, 2022

The reason of these lines is that when you want to use aligned color and depth frames, you should keep the focus constant (autofocus disabled) and more precisely set the focus value to the same value used during the camera calibration. This value is stored in eeprom with other calibration data. This value does not change, let's say it is 130. In your case, you can hardcode the value and just keep the line:
cam.initialControl.setManualFocus(130)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants