int main (int argc, char **argv) { opts_t opts = OPTS_INIT; dc1394_t *dc1394_cxt = NULL; dc1394camera_list_t *cam_list = NULL; dc1394error_t err; if (argc < 2) { show_help (); return EXIT_SUCCESS; } parse_opts (&opts, argc, argv); dc1394_cxt = dc1394_new (); if (dc1394_cxt == NULL) { printf ("error: dc1394_new() failed.\n"); return EXIT_FAILURE; } err = dc1394_camera_enumerate (dc1394_cxt, &cam_list); if (err != DC1394_SUCCESS || cam_list == NULL) { printf ("error: dc1394_camera_enumerate() failed.\n"); dc1394_free (dc1394_cxt); return EXIT_FAILURE; } /* reset specified buses */ if (opts.show_list == 0) { reset_bus (&opts, dc1394_cxt, cam_list); } else /* show the list of detected cameras */ { list_cameras (dc1394_cxt, cam_list); } dc1394_camera_free_list (cam_list); dc1394_free (dc1394_cxt); return EXIT_SUCCESS; }
int main (int argc, char **argv) { dc1394camera_t *camera = NULL; uint64_t guid = 0x0LL; dc1394_t * d; dc1394camera_list_t * list; dc1394error_t err; d = dc1394_new (); if (!d) return 1; err=dc1394_camera_enumerate (d, &list); DC1394_ERR_RTN(err,"Failed to enumerate cameras"); if (list->num == 0) { dc1394_log_error("No cameras found"); return 1; } /* parse arguments */ if (argc == 2) { if (!strcmp (argv[1], "--list-cameras")) list_cameras (d, list); else print_usage(); dc1394_camera_free_list (list); dc1394_free (d); return 0; } else if (argc == 3) { if (!strcmp (argv[1], "--guid")) { if (sscanf (argv[2], "0x%"PRIx64, &guid) == 1) { } else { dc1394_camera_free_list (list); dc1394_free (d); return print_usage(); } } } else if (argc != 1) { dc1394_camera_free_list (list); dc1394_free (d); return print_usage(); } if (guid == 0x0LL) { printf ("I: found %d camera%s, working with camera 0\n", list->num, list->num == 1 ? "" : "s"); camera = dc1394_camera_new (d, list->ids[0].guid); } else { camera = dc1394_camera_new (d, guid); if (camera == NULL) { dc1394_log_error("no camera with guid 0x%"PRIx64" found", guid); return 1; } printf ("I: found camera with guid 0x%"PRIx64"\n", guid); } dc1394_camera_print_info (camera, stdout); printf ("\nSFF feature info:\n"); dc1394_basler_sff_feature_print_all (camera, stdout); dc1394_camera_free (camera); dc1394_camera_free_list (list); dc1394_free (d); return 0; }