mirror of
https://github.com/PhotonVision/photonvision
synced 2026-06-27 02:01:40 +00:00
Equal only by usb paths (#1481)
This bug would only appear when there are cameras with the same naming. Old config matching would also match using the by-id this was problematic. When one camera is disconnected it would assign the by-id path to the other camera with the same name. When the camera is replugged in it would not be reassigned the by-id path and would fail the camerainfo equals check.
This commit is contained in:
@@ -95,7 +95,7 @@ public class CameraInfo extends UsbCameraInfo {
|
||||
|
||||
if (!path.equals(other.path)) return false;
|
||||
if (!name.equals(other.name)) return false;
|
||||
if (!Arrays.asList(this.otherPaths).containsAll(Arrays.asList(other.otherPaths))) return false;
|
||||
if (!Arrays.asList(this.getUSBPath()).contains(other.getUSBPath())) return false;
|
||||
if (vendorId != other.vendorId) return false;
|
||||
if (productId != other.productId) return false;
|
||||
|
||||
|
||||
@@ -521,8 +521,11 @@ public class VisionSourceManagerTest {
|
||||
"/dev/video0",
|
||||
"Arducam OV2311 USB Camera",
|
||||
new String[] {
|
||||
"/dev/v4l/by-id/usb-Arducam_Technology_Co.__Ltd._Arducam_OV2311_USB_Camera_UC621-video-index0",
|
||||
"/dev/v4l/by-path/platform-fc800000.usb-usb-0:1:1.0-video-index0"
|
||||
"/dev/v4l/by-path/platform-fc800000.usb-usb-0:1:1.0-video-index0" // V4l doesnt assign
|
||||
// by-id paths that
|
||||
// are identical to
|
||||
// two different
|
||||
// cameras
|
||||
},
|
||||
3141,
|
||||
25446);
|
||||
@@ -576,8 +579,11 @@ public class VisionSourceManagerTest {
|
||||
"/dev/video0",
|
||||
"Arducam OV2311 USB Camera",
|
||||
new String[] {
|
||||
"/dev/v4l/by-id/usb-Arducam_Technology_Co.__Ltd._Arducam_OV2311_USB_Camera_UC621-video-index0",
|
||||
"/dev/v4l/by-path/platform-fc800000.usb-usb-0:1:1.0-video-index0"
|
||||
"/dev/v4l/by-path/platform-fc800000.usb-usb-0:1:1.0-video-index0" // V4l doesnt assign
|
||||
// by-id paths that
|
||||
// are identical to
|
||||
// two different
|
||||
// cameras
|
||||
},
|
||||
3141,
|
||||
25446);
|
||||
@@ -602,5 +608,44 @@ public class VisionSourceManagerTest {
|
||||
assertTrue(inst.knownCameras.contains(info1_dup));
|
||||
assertTrue(inst.knownCameras.contains(info2_dup));
|
||||
assertEquals(2, inst.knownCameras.size());
|
||||
|
||||
// duplciate cameras this simulates unplugging one and plugging the other in where v4l assigns
|
||||
// the same by-id path to the other camera
|
||||
var duplicateCameraInfos1 = new ArrayList<CameraInfo>();
|
||||
CameraInfo info3_dup =
|
||||
new CameraInfo(
|
||||
0,
|
||||
"/dev/video0",
|
||||
"Arducam OV2311 USB Camera",
|
||||
new String[] {
|
||||
"/dev/v4l/by-id/usb-Arducam_Technology_Co.__Ltd._Arducam_OV2311_USB_Camera_UC621-video-index0",
|
||||
"/dev/v4l/by-path/platform-fc800000.usb-usb-0:1:1.0-video-index0"
|
||||
},
|
||||
3141,
|
||||
25446);
|
||||
CameraInfo info4_dup =
|
||||
new CameraInfo(
|
||||
0,
|
||||
"/dev/video2",
|
||||
"Arducam OV2311 USB Camera",
|
||||
new String[] {
|
||||
"/dev/v4l/by-path/platform-fc880000.usb-usb-0:1:1.0-video-index0" // V4l doesnt assign
|
||||
// by-id paths that
|
||||
// are identical to
|
||||
// two different
|
||||
// cameras
|
||||
},
|
||||
3141,
|
||||
25446);
|
||||
|
||||
duplicateCameraInfos1.add(info3_dup);
|
||||
duplicateCameraInfos1.add(info4_dup);
|
||||
|
||||
inst.tryMatchCamImpl(duplicateCameraInfos);
|
||||
|
||||
// Our cameras should be "known", and we should only "know" two cameras still
|
||||
assertTrue(inst.knownCameras.contains(info3_dup));
|
||||
assertTrue(inst.knownCameras.contains(info4_dup));
|
||||
assertEquals(2, inst.knownCameras.size());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user