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

Linux Cross Reference
Tina4/src/vision/camera/rect.c

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

  1 /**@(#)
  2 **/
  3 /**
  4 rect.c:
  5 general rectification function
  6 **/
  7 
  8 #include <math.h>
  9 #include <tina/sys.h>
 10 #include <tina/sysfuncs.h>
 11 #include <tina/math.h>
 12 #include <tina/mathfuncs.h>
 13 #include <tina/vision.h>
 14 #include <tina/visionfuncs.h>
 15 
 16 Vec2    rectify_pos(Mat3 rect, Vec2 p)
 17 {
 18     Vec3    w = {Vec3_id};
 19 
 20     w = proj3_of_vec2(p);
 21     w = mat3_vprod(rect, w);
 22     return (proj2_of_vec3(w));
 23 }
 24 
 25 double  rectify_orient(Mat3 rect, Vec2 p, double or)
 26 
 27 /* position */
 28 /* orientation in radians */
 29 {
 30     Vec2    md = {Vec2_id};
 31     Vec2    pd = {Vec2_id};     /* pos minus delta and plus delta */
 32     float   s = (float)sin(or), c = (float)cos(or);
 33 
 34     pd = rectify_pos(rect, vec2(vec2_x(p) + c, vec2_y(p) + s));
 35     md = rectify_pos(rect, vec2(vec2_x(p) - c, vec2_y(p) - s));
 36 
 37     p = vec2_diff(pd, md);
 38     return (atan2(vec2_y(p), vec2_x(p)));
 39 }
 40 
 41 void    rectify_pos_and_dir(Mat3 rect, Vec2 * p, Vec2 * v)
 42 
 43 /* position and direction */
 44 {
 45     Vec2    q = {Vec2_id};
 46 
 47     q = vec2_sum(*p, *v);
 48     *p = rectify_pos(rect, *p);
 49     q = rectify_pos(rect, q);
 50     *v = vec2_unit(vec2_diff(q, *p));
 51 }
 52 
 53 /* ARGSUSED quieten lint */
 54 void    edge_apply_rect(Edgel * edge, int type, Mat3 * rect)
 55 
 56 /* unused */
 57 
 58 {
 59     if (edge == NULL || rect == NULL)
 60         return;
 61 
 62     edge->type &= EDGE_SET_RECT_MASK;
 63     edge->type |= EDGE_RECTIFIED;
 64     edge->pos = rectify_pos(*rect, edge->pos);
 65     edge->orient = (float)rectify_orient(*rect, edge->pos, edge->orient);
 66 }
 67 
 68 /* ARGSUSED quieten lint */
 69 void    edge_apply_derect(Edgel * edge, int type, Mat3 * rect)
 70 
 71 /* unused */
 72 
 73 {
 74     if (edge == NULL || rect == NULL)
 75         return;
 76 
 77     edge->type &= EDGE_SET_RECT_MASK;
 78     edge->type |= EDGE_NOT_RECTIFIED;
 79     edge->pos = rectify_pos(*rect, edge->pos);
 80     edge->orient = (float)rectify_orient(*rect, edge->pos, edge->orient);
 81 }
 82 
 83 /* ARGSUSED quieten lint */
 84 void    edge_add_rect_prop(Edgel * edge, int type, Mat3 * rect)
 85 
 86 /* unused */
 87 
 88 {
 89     Vec2   *r;
 90 
 91     if (edge == NULL)
 92         return;
 93 
 94     r = vec2_alloc();
 95     *r = rectify_pos(*rect, edge->pos);
 96     edge->props = proplist_addifnp(edge->props, (void *) r, RECTPOS, vec2_free, true);
 97 }
 98 
 99 void    er_add_rectpos_prop(Imrect * er, Mat3 rect)
100 {
101     er_apply_to_all_edges(er, edge_add_rect_prop, (void *) &rect);
102 }
103 
104 void    er_rectify(Imrect * er, Mat3 rect)
105 {
106     er_apply_to_all_edges(er, edge_apply_rect, (void *) &rect);
107 }
108 
109 void    er_derectify(Imrect * er, Mat3 rect)
110 {
111     er_apply_to_all_edges(er, edge_apply_derect, (void *) &rect);
112 }
113 

~ [ 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.