next up previous contents
Next: TINA Development Strategy Up: Examples from Edge Tool Previous: Geom2 Callback   Contents

Rectification

The rectify callback function has the following form

Static void rectify_edges_proc(void)
{
    Imrect *left_er;
    Imrect *right_er;
    Camera *lcam;
    Camera *rcam;
    Parcam *pcam;
    Vec2    cleft = {Vec2_id};
    Vec2    cright = {Vec2_id};

    if (!stereo_images)
    {
        error("edge tool: not in stereo mode", warning);
        return;
    }
    if (edges_rectified == true)
    {
        error("edge tool: edges already rectified", warning);
        return;
    }
    left_er = left_edges_get();
    right_er = right_edges_get();
    lcam = left_camera();
    rcam = right_camera();

    if (left_er == NULL || right_er == NULL)
    {
        error("no edges", warning);
        return;
    }
    if (lcam == NULL || rcam == NULL)
    {
        error("no camera data", warning);
        return;
    }
    update_pcam();
    pcam = pcam_get();
    (void) ralloc_start_blocked(block_label);
    er_apply_to_all_edges(left_er, edge_save_pos_prop, (void *) IMPOS);
    er_apply_to_all_edges(right_er, edge_save_pos_prop, (void *) IMPOS);
    if (lcam->correct_func != NULL)
        er_correct(left_er, lcam);
    if (rcam->correct_func != NULL)
        er_correct(right_er, rcam);
    er_rectify(left_er, pcam->rect1);
    er_rectify(right_er, pcam->rect2);
    (void) ralloc_end_blocked();
    cleft = rectify_pos(pcam->rect1, vec2(lcam->cx, lcam->cy));
    cright = rectify_pos(pcam->rect2, vec2(rcam->cx, rcam->cy));
    Disp = vec2_x(cright) - vec2_x(cleft);
    edges_rectified = true;
}

After obtaining the required pointers to global data structures the existence of left and right edges and cameras is verified. A new parallel camera geometry derived from left and right cameras using update_pcam() and pcam = pcam_get(). Then begins the process of rectification. First the current edge location is saved on the property list of the edge (useful for display purposes) using the type definition IMPOS (IMage POSition) by applying the funtion edge_save_pos_prop() to all edges in the left and right imrects using er_apply_to_all_edges(). The function er_rectify applies the rectification matrix (projective transform) to all edges of the edgerect and changes their type to indicate rectified locations. Finally the gross disparity that results from rectification of the left and right image centres is computed and saved in Disp. This value is used in conjunction with disparity ranges supplied by the user to provide initial ranges of disparity To the stereo process.

The process of derectification is similar to rectification except that rectified edge locations are not saved, and the function er_derectify is used to perform the rectification process. This is identical to er_rectify except for the effect on the rectification component of the type field of the edges.


next up previous contents
Next: TINA Development Strategy Up: Examples from Edge Tool Previous: Geom2 Callback   Contents
root 2017-09-20