[robocup-small] SSLVision camera sort patch
Andre R.
andre at ryll.cc
Thu Jan 2 10:07:55 EST 2014
Dear SSLVision-Maintainers,
I have created a patch which sorts the firewire cameras by their GUID.
As some of you might know, we are using 4 cams in our lab (with single
vision instance) and experienced changing camera IDs after a restart of
the vision computer. It looks like the enumaration of the cameras is
somewhat random. This can also happen with 2 cameras, but much less
frequently. The patch just sorts cameras by their unique GUID.
After applying the patch it might happen that your camera IDs change
once, because they were not listed in GUID order, but afterwards they
are fixed.
It would be nice if one of the maintainers could apply this patch to the
trunk and also merge it to the 4cam branch.
Best regards and happy new year,
Andre Ryll
Tigers Mannheim
-------------- next part --------------
Index: src/shared/capture/capturedc1394v2.h
===================================================================
--- src/shared/capture/capturedc1394v2.h (Revision 228)
+++ src/shared/capture/capturedc1394v2.h (Arbeitskopie)
@@ -249,6 +249,19 @@
}
}
+static int compareCameraGUID(const void* a, const void* b) {
+ dc1394camera_id_t* cam1 = (dc1394camera_id_t*)a;
+ dc1394camera_id_t* cam2 = (dc1394camera_id_t*)b;
+
+ if(cam1->guid == cam2->guid)
+ return 0;
+
+ if(cam1->guid > cam2->guid)
+ return 1;
+ else
+ return -1;
+}
+
enum CaptureMode {
CAPTURE_MODE_AUTO, //auto will attempt native first, then format_7_mode_0, then give up.
CAPTURE_MODE_NATIVE,
Index: src/shared/capture/capturedc1394v2.cpp
===================================================================
--- src/shared/capture/capturedc1394v2.cpp (Revision 228)
+++ src/shared/capture/capturedc1394v2.cpp (Arbeitskopie)
@@ -1036,6 +1036,8 @@
return false;
}
+ qsort(cam_list->ids, cam_list->num, sizeof(dc1394camera_id_t), &compareCameraGUID);
+
if (cam_list==0) {
fprintf(stderr,"CaptureDC1394v2 Error: Camera List was a null pointer");
#ifndef VDATA_NO_QT
More information about the robocup-small
mailing list