PhotonVision two of the same camera

We are running the latest version of PhotonVision on our orange pi 5. We were testing multiple cameras, but it didn’t work. One camera works fine, and two different cameras works, but two of the same camera model does not work, probably it is reading both as the same camera. We are using Microsoft web cameras.

yeah IIRC there’s no way for photon to tell these cameras apart and I’ve just been told to use different cameras or cameras that can be renamed in software (I think arducams can do this with their app)

take this with a grain of salt I’m just saying what I remember off the top of my head from a bit of research

1 Like

From Supported Hardware:

The following cameras / setups are known to not work:

  • Using two of the same USB cameras does not currently work because it is hard to identify the two different cameras.

Correct. Someone was working on debugging this, but I forget where they got with this. Anyone else is free to take a swing at it, if I remember correctly, it took them ~10-30min of actual debugging to find the source of the issue, so I don’t think it would be too hard to fix (said every programmer ever).

2 Likes

Do you have any idea where the camera recognition is located in Github? It’s a huge project though, so I get if it’s lost.

Probably VisionSourceManager. More information here in our discord. Discord

as far as I know, unless those specific microsoft cameras provide a serial number with their UVC attributes, there is no way for the operating system, not just photonvision, to identify the cameras apart. they will have identical manufacturer IDs, model IDs, and device names. something like udev could be used to to rename devices if this was available

Linux at least provides a way to disambiguate devices by their physical connection path (e.g. chain of USB hubs/port numbers) in addition to their name. /dev/v4l/by-path/.... The WPILib cscore library provides functionality to discover these alternate paths (both by-id and by-path) and can open cameras using them instead of by /dev/videoN. In the WPILibPi image, these are exposed via drop-downs in the UI to select alternates for each camera, so I would think PhotonVision could do something very similar.

For what it’s worth, I was able to sort out this issue on an Orange Pi (not with PhotonVision, but just in linux generally) by setting up custom udev rules. The KERNELS parameter was the key, which is used here to specify a particular port, so the camera plugged into that port is always symlinked to the same unique name. You can see this rule supports a couple different camera models on each port.

udev rule file contents
SUBSYSTEM=="video4linux", KERNELS=="2-1", ATTRS{idVendor}=="0c45", ATTRS{idProduct}=="6366", ATTR{index}=="0", MODE="0664", GROUP="video", SYMLINK+="cameras/video-left"
SUBSYSTEM=="video4linux", KERNELS=="2-1", ATTRS{idVendor}=="045e", ATTRS{idProduct}=="0810", ATTR{index}=="0", MODE="0664", GROUP="video", SYMLINK+="cameras/video-left"
SUBSYSTEM=="video4linux", KERNELS=="2-1", ATTRS{idVendor}=="045e", ATTRS{idProduct}=="0779", ATTR{index}=="0", MODE="0664", GROUP="video", SYMLINK+="cameras/video-left"

SUBSYSTEM=="video4linux", KERNELS=="1-1", ATTRS{idVendor}=="0c45", ATTRS{idProduct}=="6366", ATTR{index}=="0", MODE="0664", GROUP="video", SYMLINK+="cameras/video-right"
SUBSYSTEM=="video4linux", KERNELS=="1-1", ATTRS{idVendor}=="045e", ATTRS{idProduct}=="0810", ATTR{index}=="0", MODE="0664", GROUP="video", SYMLINK+="cameras/video-right"
SUBSYSTEM=="video4linux", KERNELS=="1-1", ATTRS{idVendor}=="045e", ATTRS{idProduct}=="0779", ATTR{index}=="0", MODE="0664", GROUP="video", SYMLINK+="cameras/video-right"

SUBSYSTEM=="video4linux", KERNELS=="7-1", ATTRS{idVendor}=="0c45", ATTRS{idProduct}=="6366", ATTR{index}=="0", MODE="0664", GROUP="video", SYMLINK+="cameras/video-center"
SUBSYSTEM=="video4linux", KERNELS=="7-1", ATTRS{idVendor}=="045e", ATTRS{idProduct}=="0810", ATTR{index}=="0", MODE="0664", GROUP="video", SYMLINK+="cameras/video-center"
SUBSYSTEM=="video4linux", KERNELS=="7-1", ATTRS{idVendor}=="045e", ATTRS{idProduct}=="0779", ATTR{index}=="0", MODE="0664", GROUP="video", SYMLINK+="cameras/video-center"
2 Likes

That’s an interesting idea. We were thinking of using a usb splitter (still debating how many cameras we will need vs. performance). I’ll take a look at that tonight, thank you!
Is it possible for you to explain what each value does though?

This creates a situation where switching USB ports switches the cameras, and I can see how that can ruin your day if you don’t take the necessary precautions. I’m not saying that there’s a better way, but if this is implemented I think a warning pop-up is needed.

Some camera manufacturers have a renaming tool that allows you to rename the device, so that you can differentiate between identical cameras. Arducam is one such manufacturer.

1 Like

Colored tape on the USB ports, matching colored tape on the cameras, no mixups, problem solved

1 Like

Still, in order for that to happen you have to alert the teams that are susceptible to this

What did you name your custom rule file? How do you make it persistent?

Anything following the format will do, 50-cameras.rules would work. You can follow this StackOverflow’s instructions.

1 Like

One more question, what cameras did you support here? Also, which three go to which port? If I were to have a different camera model, where do I get the information?

The cameras “supported” would just be whatever cameras you put in with their Vendor ID and Product ID to the udev rule. A simple lsusb will reveal this information for your setup.

1 Like

Thank you!

So, I have the rules up and running with my cameras. Is there any way I could apply this to photonvision to get it to recognize the different symlinks?