Debian Codegraph @

ad_hoc_tests/dvbuffer_controls.cxx

raw symbols SCIP
1 /*
2 This file is part of the CVD Library.
3
4 Copyright (C) 2005 The Authors
5
6 This library is free software, see LICENSE file for details
7 */
8 #include <iostream>
9 #include <sys/time.h>
10
11 #include <X11/keysym.h>
12
13 #include <cvd/Linux/dvbuffer.h>
14 #include <cvd/videodisplay.h>
15
16 #define DATA_TYPE GL_LUMINANCE
17 #define pix byte
18
19 using namespace CVD;
20 using namespace std;
21
22 double dbl_time()
23 {
24 struct timeval tv;
25 gettimeofday(&tv, 0);
26 return tv.tv_sec + 1e-6 * tv.tv_usec;
27 }
28
29 int main()
30 {
31 DVBuffer2<pix> vbuf(0, 3, 0, 0);
32 VideoDisplay vd(0, 0, vbuf.size().x, vbuf.size().y);
33
34 XEvent e;
35 vd.select_events(ButtonPressMask | KeyPressMask);
36
37 double new_time, old_time = dbl_time();
38
39 unsigned int shutter, iris, gain, exposure, brightness;
40 bool shut_on, iris_on, gain_on, exp_on, brt_on;
41 int n;
42
43 vbuf.set_exposure(400);
44 vbuf.set_brightness(304);
45
46 //Some kind of default values
47
48 shutter = 6;
49 iris = 4;
50 gain = 4;
51 exposure = 400;
52 brightness = 304;
53
54 shut_on = gain_on = iris_on = exp_on = brt_on = 0;
55
56 vbuf.set_shutter(shutter);
57 vbuf.set_iris(iris);
58 vbuf.set_gain(gain);
59 vbuf.set_exposure(exposure);
60 vbuf.set_brightness(brightness);
61
62 for(n = 0;; n++)
63 {
64 new_time = dbl_time();
65
66 /*shutter = vbuf.get_shutter();
67 iris = vbuf.get_iris();
68 gain = vbuf.get_iris();
69 exposure = vbuf.get_exposure();
70 brightness = vbuf.get_brightness();*/
71
72 if(n % 50 == 0)
73 printf("------------------------------------------------\n"
74 "%8s%8s%8s%8s%8s%8s\n",
75 "fps", "shut", "iris", "gain", "expos", "bright");
76
77 printf("%8.3f", 1 / (new_time - old_time));
78
79 if(!shut_on)
80 printf("%8i", shutter);
81 else
82 printf(" * ");
83 if(!iris_on)
84 printf("%8i", iris);
85 else
86 printf(" * ");
87 if(!gain_on)
88 printf("%8i", gain);
89 else
90 printf(" * ");
91
92 if(!exp_on)
93 printf("%8i", exposure);
94 else
95 printf(" *%4i", exposure);
96 if(!brt_on)
97 printf("%8i", brightness);
98 else
99 printf(" * ");
100
101 //printf("%8i%8i%8i%8i%8i\n", shutter, iris, gain, exposure, brightness);
102 printf("\n");
103
104 old_time = new_time;
105
106 while(vd.pending())
107 {
108 vd.get_event(&e);
109 if(e.type == KeyPress)
110 {
111 KeySym k;
112 XLookupString((XKeyEvent*)&e, 0, 0, &k, 0);
113
114 if(k == XK_1)
115 shutter++;
116 else if(k == XK_q)
117 shutter--;
118 else if(k == XK_a)
119 shut_on = !shut_on;
120 else if(k == XK_2)
121 iris++;
122 else if(k == XK_w)
123 iris--;
124 else if(k == XK_s)
125 iris_on = !iris_on;
126 else if(k == XK_3)
127 gain++;
128 else if(k == XK_e)
129 gain--;
130 else if(k == XK_d)
131 gain_on = !gain_on;
132 else if(k == XK_4)
133 exposure++;
134 else if(k == XK_r)
135 exposure--;
136 else if(k == XK_f)
137 exp_on = !exp_on;
138 else if(k == XK_5)
139 brightness++;
140 else if(k == XK_t)
141 brightness--;
142 else if(k == XK_g)
143 brt_on = !brt_on;
144 else if(k == XK_Escape)
145 return 0;
146 }
147 else if(e.type == ButtonPress)
148 return 0;
149
150 vbuf.set_shutter(shutter);
151 vbuf.set_iris(iris);
152 vbuf.set_gain(gain);
153 vbuf.set_exposure(exposure);
154 vbuf.set_brightness(brightness);
155
156 dc1394_auto_on_off(vbuf.handle(), vbuf.node(), FEATURE_SHUTTER, shut_on);
157 dc1394_auto_on_off(vbuf.handle(), vbuf.node(), FEATURE_IRIS, iris_on);
158 dc1394_auto_on_off(vbuf.handle(), vbuf.node(), FEATURE_GAIN, gain_on);
159 dc1394_auto_on_off(vbuf.handle(), vbuf.node(), FEATURE_EXPOSURE, exp_on);
160 dc1394_auto_on_off(vbuf.handle(), vbuf.node(), FEATURE_BRIGHTNESS, brt_on);
161 }
162
163 VideoFrame<pix>* vf = vbuf.get_frame();
164
165 glDrawPixels(vf->size().x, vf->size().y, DATA_TYPE, GL_UNSIGNED_BYTE, vf->data());
166 vbuf.put_frame(vf);
167 }
168 }