~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

Linux Cross Reference
Tina4/src/tools/edge/epi_mouse.c

Version: ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 /**@(#)
  2 **/
  3 #include <tina/sys.h>
  4 #include <tina/math.h>
  5 #include <tina/mathfuncs.h>
  6 #include <tina/vision.h>
  7 #include <tina/visionfuncs.h>
  8 #include <tina/tv.h>
  9 #include <tina/tvfuncs.h>
 10 #include <tina/toolsfuncs.h>
 11 
 12 
 13 static Parcam *pcam;
 14 static Vec2 left1 = {Vec2_id};
 15 static Vec2 left2 = {Vec2_id};
 16 static Vec2 right1 = {Vec2_id};
 17 static Vec2 right2 = {Vec2_id};
 18 static Tv *tvl;
 19 static Tv *tvr;
 20 
 21 void    new_epipolars(Vec2 p)
 22 {
 23     Vec2    q = {Vec2_id};
 24     Vec2    v = {Vec2_id};
 25     Imrect *im;
 26     float   width;
 27 
 28     pcam = pcam_get();
 29     q = p;
 30     v = vec2(1.0, 0.0);         /* along the x axis of pcam */
 31     im = left_image();
 32     width = (im == NULL) ? tvl->width : im->width;
 33     rectify_pos_and_dir(pcam->derect1, &q, &v);
 34     left1 = vec2_sum(q, vec2_times((0 - vec2_x(q)) / vec2_x(v), v));
 35     left2 = vec2_sum(q, vec2_times((width - vec2_x(q)) / vec2_x(v), v));
 36     q = p;
 37     im = right_image();
 38     v = vec2(1.0, 0.0);         /* along the x axis of pcam */
 39     width = (im == NULL) ? tvr->width : im->width;
 40     rectify_pos_and_dir(pcam->derect2, &q, &v);
 41     right1 = vec2_sum(q, vec2_times((0 - vec2_x(q)) / vec2_x(v), v));
 42     right2 = vec2_sum(q, vec2_times((width - vec2_x(q)) / vec2_x(v), v));
 43 }
 44 
 45 static void new_rasters(Vec2 p)
 46 {
 47     Ipos    pos = {Ipos_id};
 48 
 49     pos = tv_proj2(tvl, p);
 50     ipos_x(pos) = 0;
 51     left1 = tv_backproj2(tvl, pos);
 52     ipos_x(pos) = tvl->width;
 53     left2 = tv_backproj2(tvl, pos);
 54     pos = tv_proj2(tvr, p);
 55     ipos_x(pos) = 0;
 56     right1 = tv_backproj2(tvr, pos);
 57     ipos_x(pos) = tvr->width;
 58     right2 = tv_backproj2(tvr, pos);
 59 }
 60 
 61 static void epi_left_down(Tv * tv, Ipos pos)
 62 {
 63     pcam = pcam_get();
 64     tvl = tv;
 65     tvr = right_tv();
 66 
 67     if (pcam == NULL)
 68         return;
 69 
 70     new_epipolars(rectify_pos(pcam->rect1, tv_backproj2(tv, pos)));
 71     tv_set_overlay(tvl);        /* also calls tv_save_draw */
 72     tv_set_overlay(tvr);        /* also calls tv_save_draw */
 73     tv_line2(tvl, left1, left2);
 74     tv_line2(tvr, right1, right2);
 75 }
 76 
 77 static void epi_left_drag(Tv * tv, Ipos pos)
 78 {
 79     if (pcam == NULL)
 80         return;
 81 
 82     tv_line2(tvl, left1, left2);
 83     tv_line2(tvr, right1, right2);
 84     new_epipolars(rectify_pos(pcam->rect1, tv_backproj2(tv, pos)));
 85     tv_line2(tvl, left1, left2);
 86     tv_line2(tvr, right1, right2);
 87 }
 88 
 89 static void epi_left_up(Tv * tv, Ipos pos)
 90 {
 91     if (pcam == NULL)
 92         return;
 93 
 94     tv_line2(tvl, left1, left2);
 95     tv_line2(tvr, right1, right2);
 96     new_epipolars(rectify_pos(pcam->rect1, tv_backproj2(tv, pos)));
 97     tv_reset_draw(tvl);
 98     tv_reset_draw(tvr);
 99     tv_set_color(tvl, cyan);
100     tv_set_color(tvr, cyan);
101     tv_line2(tvl, left1, left2);
102     tv_line2(tvr, right1, right2);
103 }
104 
105 static void epi_right_down(Tv * tv, Ipos pos)
106 {
107     pcam = pcam_get();
108     tvl = left_tv();
109     tvr = tv;
110 
111     if (pcam == NULL)
112         return;
113 
114     new_epipolars(rectify_pos(pcam->rect2, tv_backproj2(tv, pos)));
115     tv_set_overlay(tvl);        /* also calls tv_save_draw */
116     tv_set_overlay(tvr);        /* also calls tv_save_draw */
117     tv_line2(tvl, left1, left2);
118     tv_line2(tvr, right1, right2);
119 }
120 
121 static void epi_right_drag(Tv * tv, Ipos pos)
122 {
123     if (pcam == NULL)
124         return;
125 
126     tv_line2(tvl, left1, left2);
127     tv_line2(tvr, right1, right2);
128     new_epipolars(rectify_pos(pcam->rect2, tv_backproj2(tv, pos)));
129     tv_line2(tvl, left1, left2);
130     tv_line2(tvr, right1, right2);
131 }
132 
133 static void epi_right_up(Tv * tv, Ipos pos)
134 {
135     if (pcam == NULL)
136         return;
137 
138     tv_line2(tvl, left1, left2);
139     tv_line2(tvr, right1, right2);
140     new_epipolars(rectify_pos(pcam->rect2, tv_backproj2(tv, pos)));
141     tv_reset_draw(tvl);
142     tv_reset_draw(tvr);
143     tv_set_color(tvl, cyan);
144     tv_set_color(tvr, cyan);
145     tv_line2(tvl, left1, left2);
146     tv_line2(tvr, right1, right2);
147 }
148 
149 Tv_mouse left_epi_mouse(void)
150 {
151     return (mouse_define(LEFT_DOWN, epi_left_down,
152                          LEFT_DRAG, epi_left_drag,
153                          LEFT_UP, epi_left_up, NULL));
154 }
155 
156 Tv_mouse right_epi_mouse(void)
157 {
158     return (mouse_define(LEFT_DOWN, epi_right_down,
159                          LEFT_DRAG, epi_right_drag,
160                          LEFT_UP, epi_right_up, NULL));
161 }
162 
163 static void raster_left_down(Tv * tv, Ipos pos)
164 {
165     pcam = pcam_get();
166     tvl = tv;
167     tvr = right_tv();
168 
169     if (pcam == NULL)
170         return;
171 
172     new_rasters(tv_backproj2(tv, pos));
173     tv_set_overlay(tvl);        /* also calls tv_save_draw */
174     tv_set_overlay(tvr);        /* also calls tv_save_draw */
175     tv_line2(tvl, left1, left2);
176     tv_line2(tvr, right1, right2);
177 }
178 
179 static void raster_left_drag(Tv * tv, Ipos pos)
180 {
181     if (pcam == NULL)
182         return;
183 
184     tv_line2(tvl, left1, left2);
185     tv_line2(tvr, right1, right2);
186     new_rasters(tv_backproj2(tv, pos));
187     tv_line2(tvl, left1, left2);
188     tv_line2(tvr, right1, right2);
189 }
190 
191 static void raster_left_up(Tv * tv, Ipos pos)
192 {
193     if (pcam == NULL)
194         return;
195 
196     tv_line2(tvl, left1, left2);
197     tv_line2(tvr, right1, right2);
198     new_rasters(tv_backproj2(tv, pos));
199     tv_reset_draw(tvl);
200     tv_reset_draw(tvr);
201     tv_set_color(tvl, cyan);
202     tv_set_color(tvr, cyan);
203     tv_line2(tvl, left1, left2);
204     tv_line2(tvr, right1, right2);
205 }
206 
207 static void raster_right_down(Tv * tv, Ipos pos)
208 {
209     pcam = pcam_get();
210     tvl = left_tv();
211     tvr = tv;
212 
213     if (pcam == NULL)
214         return;
215 
216     new_rasters(tv_backproj2(tv, pos));
217     tv_set_overlay(tvl);        /* also calls tv_save_draw */
218     tv_set_overlay(tvr);        /* also calls tv_save_draw */
219     tv_line2(tvl, left1, left2);
220     tv_line2(tvr, right1, right2);
221 }
222 
223 static void raster_right_drag(Tv * tv, Ipos pos)
224 {
225     if (pcam == NULL)
226         return;
227 
228     tv_line2(tvl, left1, left2);
229     tv_line2(tvr, right1, right2);
230     new_rasters(tv_backproj2(tv, pos));
231     tv_line2(tvl, left1, left2);
232     tv_line2(tvr, right1, right2);
233 }
234 
235 static void raster_right_up(Tv * tv, Ipos pos)
236 {
237     if (pcam == NULL)
238         return;
239 
240     tv_line2(tvl, left1, left2);
241     tv_line2(tvr, right1, right2);
242     new_rasters(tv_backproj2(tv, pos));
243     tv_reset_draw(tvl);
244     tv_reset_draw(tvr);
245     tv_set_color(tvl, cyan);
246     tv_set_color(tvr, cyan);
247     tv_line2(tvl, left1, left2);
248     tv_line2(tvr, right1, right2);
249 }
250 
251 Tv_mouse left_raster_mouse(void)
252 {
253     return (mouse_define(LEFT_DOWN, raster_left_down,
254                          LEFT_DRAG, raster_left_drag,
255                          LEFT_UP, raster_left_up, NULL));
256 }
257 
258 Tv_mouse right_raster_mouse(void)
259 {
260     return (mouse_define(LEFT_DOWN, raster_right_down,
261                          LEFT_DRAG, raster_right_drag,
262                          LEFT_UP, raster_right_up, NULL));
263 }
264 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

This page was automatically generated by the LXR engine.
Visit the LXR main site for more information.