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

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

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

  1 /**@(#)
  2 **/
  3 #include <tina/sys.h>
  4 #include <tina/sysfuncs.h>
  5 #include <tina/math.h>
  6 #include <tina/mathfuncs.h>
  7 #include <tina/vision.h>
  8 #include <tina/visionfuncs.h>
  9 
 10 Vec2    radial_distort(Vec2 w, double *a)
 11 {
 12     Vec2    v = {Vec2_id};
 13     double  radsq;
 14 
 15     radsq = w.el[0] * w.el[0] + w.el[1] * w.el[1];
 16     v.el[0] = (float)((1.0 - a[1] * radsq) * w.el[0]);
 17     v.el[1] = (float)((1.0 - a[1] * radsq) * w.el[1]);
 18     return (v);
 19 }
 20 
 21 Vec2    radial_correct(Vec2 w, double *a)
 22 {
 23     Vec2    v = {Vec2_id};
 24     double  radsq;
 25 
 26     v.el[0] = w.el[0];
 27     v.el[1] = w.el[1];
 28 
 29     radsq = v.el[0] * v.el[0] + v.el[1] * v.el[1];
 30     v.el[0] = (float)((1.0 + a[1] * radsq) * w.el[0]);
 31     v.el[1] = (float)((1.0 + a[1] * radsq) * w.el[1]);
 32 
 33     radsq = v.el[0] * v.el[0] + v.el[1] * v.el[1];
 34     v.el[0] = (float)((1.0 + a[1] * radsq) * w.el[0]);
 35     v.el[1] = (float)((1.0 + a[1] * radsq) * w.el[1]);
 36     return (v);
 37 }
 38 
 39 Vec2    cam_correct(Vec2 u, Camera * cam)
 40 
 41 
 42 
 43 /* this routine cannot be called with a NULL cam pointer */
 44 {
 45     if ((cam->correct_func != NULL) && (cam->distort_params != NULL))
 46     {
 47         /* change from image to unit camera coordinates */
 48         u = rectify_pos(cam->im_to_cam, u);
 49         /** allow for optical distortion **/
 50         u = cam->correct_func(u, cam->distort_params);
 51         /** change back to image coordinates **/
 52         u = rectify_pos(cam->cam_to_im, u);
 53     }
 54     return (u);
 55 }
 56 
 57 void   *cam_distort_copy(double *b)
 58 {
 59     int     i, n;
 60     double *a;
 61 
 62     n = (int) (b[0] + 0.5);
 63     a = (double *) ralloc((unsigned) (sizeof(double) * (n + 1)));
 64     for (i = 0; i < n + 1; i++)
 65         a[i] = b[i];
 66     return(a);
 67 }
 68 
 69 /* ARGSUSED quieten lint */
 70 void    edge_apply_corr(Edgel * edge, int type, Camera * cam)
 71 
 72 /* unused */
 73 
 74 {
 75     if (edge == NULL || cam == NULL || cam->correct_func == NULL || cam->distort_params == NULL)
 76         return;
 77     edge->type &= EDGE_SET_CORR_MASK;
 78     edge->type |= EDGE_CORRECTED;
 79     edge->pos = cam_correct(edge->pos, cam);
 80 }
 81 
 82 /* ARGSUSED quieten lint */
 83 void    edge_add_corr_prop(Edgel * edge, int type, Camera * cam)
 84 {
 85     Vec2   *r;
 86 
 87     if (edge == NULL || cam == NULL || cam->correct_func == NULL || cam->distort_params == NULL)
 88         return;
 89     r = vec2_alloc();
 90 
 91     *r = cam_correct(edge->pos, cam);
 92     edge->props = proplist_addifnp(edge->props, (void *) r, CORRPOS, vec2_free, true);
 93 }
 94 
 95 void    er_add_corrpos_prop(Imrect * er, Camera * cam)
 96 {
 97     er_apply_to_all_edges(er, edge_add_corr_prop, (void *) cam);
 98 }
 99 
100 void    er_correct(Imrect * er, Camera * cam)
101 {
102     er_apply_to_all_edges(er, edge_apply_corr, (void *) cam);
103 }
104 

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