1 /*
2 * 1394-Based Digital Camera Control Library
3 * Basler Smart Feature Framework specific extensions
4 * Copyright (C) 2006 Mikael Olenfalk, Tobii Technology AB, Stockholm Sweden
5 *
6 * Written by Mikael Olenfalk <mikael _DOT_ olenfalk _AT_ tobii _DOT_ com>
7 * Version : 16/02/2005
8 *
9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public
11 * License as published by the Free Software Foundation; either
12 * version 2.1 of the License, or (at your option) any later version.
13 *
14 * This library is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Lesser General Public License for more details.
18 *
19 * You should have received a copy of the GNU Lesser General Public
20 * License along with this library; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 */
23
24 #include <stdio.h>
25 #include <stdlib.h>
26 #include <stdint.h>
27 #include <string.h>
28 #include <inttypes.h>
29
30 #include <dc1394/dc1394.h>
31 #include <dc1394/vendor/basler.h>
32
list_cameras(dc1394_t * d,dc1394camera_list_t * list)33 int list_cameras (dc1394_t * d, dc1394camera_list_t * list)
34 {
35 uint32_t i;
36 dc1394bool_t sff_available;
37 dc1394camera_t * camera;
38
39 for (i = 0; i < list->num; i++) {
40 sff_available = DC1394_FALSE;
41 camera = dc1394_camera_new (d, list->ids[i].guid);
42 dc1394_basler_sff_is_available (camera, &sff_available);
43
44 printf ("%02d:0x%"PRIx64":%s:%s:%s\n", i, camera->guid,
45 camera->vendor, camera->model, sff_available ? "SFF" : "NO SFF");
46 dc1394_camera_free (camera);
47 }
48 return 0;
49 }
50
print_usage()51 int print_usage ()
52 {
53 printf ("usage: basler_sff_info [--list-cameras|[--guid GUID]]\n");
54 return 1;
55 }
56
main(int argc,char ** argv)57 int main (int argc, char **argv)
58 {
59 dc1394camera_t *camera = NULL;
60 uint64_t guid = 0x0LL;
61 dc1394_t * d;
62 dc1394camera_list_t * list;
63 dc1394error_t err;
64
65 d = dc1394_new ();
66 if (!d)
67 return 1;
68 err=dc1394_camera_enumerate (d, &list);
69 DC1394_ERR_RTN(err,"Failed to enumerate cameras");
70
71 if (list->num == 0) {
72 dc1394_log_error("No cameras found");
73 return 1;
74 }
75
76 /* parse arguments */
77 if (argc == 2) {
78 if (!strcmp (argv[1], "--list-cameras"))
79 list_cameras (d, list);
80 else
81 print_usage();
82 dc1394_camera_free_list (list);
83 dc1394_free (d);
84 return 0;
85 } else if (argc == 3) {
86 if (!strcmp (argv[1], "--guid")) {
87 if (sscanf (argv[2], "0x%"PRIx64, &guid) == 1) {
88 } else {
89 dc1394_camera_free_list (list);
90 dc1394_free (d);
91 return print_usage();
92 }
93 }
94 } else if (argc != 1) {
95 dc1394_camera_free_list (list);
96 dc1394_free (d);
97 return print_usage();
98 }
99
100 if (guid == 0x0LL) {
101 printf ("I: found %d camera%s, working with camera 0\n", list->num,
102 list->num == 1 ? "" : "s");
103 camera = dc1394_camera_new (d, list->ids[0].guid);
104 } else {
105 camera = dc1394_camera_new (d, guid);
106 if (camera == NULL) {
107 dc1394_log_error("no camera with guid 0x%"PRIx64" found", guid);
108 return 1;
109 }
110
111 printf ("I: found camera with guid 0x%"PRIx64"\n", guid);
112 }
113
114 dc1394_camera_print_info (camera, stdout);
115 printf ("\nSFF feature info:\n");
116 dc1394_basler_sff_feature_print_all (camera, stdout);
117 dc1394_camera_free (camera);
118 dc1394_camera_free_list (list);
119 dc1394_free (d);
120 return 0;
121 }
122