zivid / zivid-python

Official Python package for Zivid 3D cameras
BSD 3-Clause "New" or "Revised" License
40 stars 14 forks source link

How to connect to a camera by specifying IP? #199

Closed apockill closed 1 year ago

apockill commented 1 year ago

Hi, I'm having a difficult time figuring out how to properly connect and use two zivid cameras.

I've got 2 cameras on a network switch connected to a computer. I'm able to show that both cameras can be found, as shown in the following two commands:

root@e9a72ea8f82b:/robot# ZividNetworkCameraConfigurator get-config 172.28.60.5
Successfully connected to 172.28.60.5.
Current network settings:
    Network Mode: Static IP
    Hostname: zivid-21490C72
    IP Address: 172.28.60.5
    Subnet Mask: 255.255.255.0
    Gateway: 172.28.60.1
    DNS Server: 172.28.60.1
root@e9a72ea8f82b:/robot# ZividNetworkCameraConfigurator get-config 172.28.60.6
Successfully connected to 172.28.60.6.
Current network settings:
    Network Mode: Static IP
    Hostname: zivid-2232E60B
    IP Address: 172.28.60.6
    Subnet Mask: 255.255.255.0
    Gateway: 172.28.60.1
    DNS Server: 172.28.60.1

However, concerningly when I run ZividListCameras I only find one camera:

root@e9a72ea8f82b:/robot# ZividListCameras
Found 1 camera(s).
{ Camera info: { Model: zividTwo, Model Name: Zivid Two, Serial Number: 21490C72, Hardware Revision: 4.2, Firmware Version: 1.6.0+152047fc, USB Path: , Network Path: 172.28.60.5, Internal camera id: 4C4BF9800BFB, Projector firmware tag:  } }

This is also causing issues using the Zivid Python API, because when I do Application().cameras() I only get a single camera.

How do I correctly use two cameras with this SDK? Thank you for all your help.

nedrebo commented 1 year ago

Which SDK version are you using?

Can you try to update to SDK 2.8.1 and flash the firmware of each camera?

Then it should handle this case better by default. If you made a Cameras.yml file, you should try to delete it again once you upgraded to 2.8.1.

Now ZividListCameras and Application().cameras() (which is basically the same thing) should list both cameras.

apockill commented 1 year ago

I've gone ahead and updated the to the python sdk version zivid="2.7.0.2.8.1", and updated the cameras individually as well. Here's what I'm currently seeing:

ZividListCameras can still only see one of the cameras

root@f35dedae72ac:/robot# ZividListCameras
Found 1 camera(s).
{ Camera info: { Model: zividTwo, Model Name: Zivid Two, Serial Number: 21490C72, Hardware Revision: 4.2, Firmware Version: 1.9.6+4a37e6a1, USB Path: , Network Path: 172.28.60.5, Internal camera id: 4C4BF9800BFB, Projector firmware tag:  } }

But I can still access them as expected by using ZividNetworkCameraConfigurator and specifying the exact IP.

root@f35dedae72ac:/robot# ZividNetworkCameraConfigurator get-config 172.28.60.5
Successfully connected to 172.28.60.5.
Current network settings:
    Network Mode: Static IP
    Hostname: zivid-21490C72
    IP Address: 172.28.60.5
    Subnet Mask: 255.255.255.0
    Gateway: 172.28.60.1
    DNS Server: 172.28.60.1
root@f35dedae72ac:/robot# ZividNetworkCameraConfigurator get-config 172.28.60.6
Successfully connected to 172.28.60.6.
Current network settings:
    Network Mode: Static IP
    Hostname: zivid-2232E60B
    IP Address: 172.28.60.6
    Subnet Mask: 255.255.255.0
    Gateway: 172.28.60.1
    DNS Server: 172.28.60.1

Here's the info for both cameras:

root@f35dedae72ac:/robot# ZividNetworkCameraConfigurator info 172.28.60.5
Successfully connected to 172.28.60.5.
Information:
    Model Name: Zivid Two
    Serial Number: 21490C72
    MAC Address: 4C4BF9800BFB
    Firmware Version: 1.9.6+4a37e6a1
root@f35dedae72ac:/robot# ZividNetworkCameraConfigurator info 172.28.60.6
Successfully connected to 172.28.60.6.
Information:
    Model Name: Zivid Two
    Serial Number: 2232E60B
    MAC Address: 4C4BF98000CF
    Firmware Version: 1.9.6+4a37e6a1

When running Application.cameras() it is currently still finding just 1 of the 2 cameras.

apockill commented 1 year ago

I haven't made a Cameras.yml file, maybe that's the problem? Could you point me to the documentation showing where to put this file? Thank you!

eskaur commented 1 year ago

This may be useful: https://support.zivid.com/en/latest/getting-started/software-installation/zivid-two-network-configuration.html

apockill commented 1 year ago

Fantastic, that worked. Is there any way to customize the location of the Cameras.yml, maybe via an environment variable?

anordal commented 1 year ago

There are $XDG_CONFIG_HOME on Linux and %LOCALAPPDATA% on Windows (open the pulldown Cameras.yml and how Zivid SDK discovers cameras on that page).

NB: You probably don't want to set these globally, because these are conventions that most applications follow, but you can always make wrapper scripts.

apockill commented 1 year ago

That's great. We're currently running our full stack in docker, and none of the software we're using relies on XDG_CONFIG_HOME being set, so it's safe to use I think. Thanks again for the information.

Do you think running in docker might be the reason udp-multicast isn't working? (Assuming that's how zivids currently find eachother on the network)

apockill commented 1 year ago

For future viewers of this issue- the reason that the Zivid library and tools weren't able to find cameras not on the default IP is because the default docker network configuration wasn't allowing udp discovery to work. By setting network_mode: host, the cameras were all suddenly discoverable.