Rose-Hulman Robotics Team

Changeset 673

Show
Ignore:
Timestamp:
02/17/10 21:55:37 (2 years ago)
Author:
mosttw
Message:

Preliminary presentation and ground plane rectification script

Location:
branches/2010-image-rec
Files:
2 added
2 modified

Legend:

Unmodified
Added
Removed
  • branches/2010-image-rec/docs/Makefile

    r645 r673  
    55project-plan.pdf: figures/cam-000080-hsv-sobel-h.png figures/hist-test.tex figures/pygments-declarations.tex 
    66 
    7 all: lit-review.pdf project-plan.pdf 
     7all: lit-review.pdf project-plan.pdf report 
    88 
    99%.pdf: %.tex 
     
    1414        rm -f $*.aux $*.bbl $*.blg $*.brf $*.log $*.out $*.tex~ 
    1515 
     16## Figures 
    1617 
     18REPORT_FIGURES := \ 
     19        figures/ground-lab_undistorted.png \ 
     20        figures/ground-lab-calib_undistorted.png \ 
     21        figures/ground-lab_rectified.png \ 
     22        figures/ground-lab-calib_rectified.png 
     23 
     24report: $(REPORT_FIGURES) 
     25 
     26%_undistorted.png: %.jpg 
     27        ../undistort.py $< 
     28%_rectified.png: %.jpg 
     29        ../rectifyground.py $< 
  • branches/2010-image-rec/proj3d.py

    r672 r673  
    108108        [   0.0,        0.0,        1.0    ], 
    109109]) 
    110 #camera_intrinsic = np.array([ 
    111 #       [2200, 0, 2592 / 2], 
    112 #       [0, 2200, 1936 / 2], 
    113 #       [0, 0, 1], 
    114 #]) 
    115110 
    116111## Extrinsic camera parameters 
     
    131126ground_box += camera_target 
    132127 
    133 points = np.array([ 
     128rectangle = np.array([ 
    134129        [0,  10,  25, 1], 
    135130        [0,  10, -25, 1], 
     
    138133        [0,  10,  25, 1], 
    139134]) 
    140 points[:,0:3] = np.dot(points[:,0:3], rot_y(1.5)) 
    141 points += np.array([50, 0, 50 * 2.54, 0]) 
     135rectangle[:,0:3] = np.dot(rectangle[:,0:3], rot_y(1.5)) 
     136rectangle += np.array([50, 0, 50 * 2.54, 0]) 
    142137 
    143 camera_rotation = rot_y(np.arctan2(camera_target[2], camera_location[0])) 
     138up_rect = np.array([ 
     139        [ 20, 50,  25 + 100, 1], 
     140        [ 20, 50, -25 + 100, 1], 
     141        [-20, 50, -25 + 100, 1], 
     142        [-20, 50,  25 + 100, 1], 
     143        [ 20, 50,  25 + 100, 1], 
     144]) 
     145 
     146camera_rotation = rot_y(np.arctan2(camera_location[0], camera_target[2])) 
    144147 
    145148# External camera matrix --- transforms the camera to be at (0, 0, 0) 
     
    147150camera_external[:, :3] = camera_rotation 
    148151camera_external[:, 3] = np.dot(-camera_rotation, camera_location[0:3]) 
     152P = np.dot(camera_intrinsic, camera_external) 
    149153 
     154## 3D Plot 
    150155ax3d = plot_scene_3d(camera_location, camera_target, camera_rotation, camera_external) 
    151156 
     
    158163 
    159164# Plot objects in the scene in original and transformed positions 
    160 points_max = plot_polygon_3d(ax3d, points, camera_external, 'blue', 'red') 
     165rectangle_max  = plot_polygon_3d(ax3d, rectangle, camera_external, 'blue', 'red') 
    161166ground_box_max = plot_polygon_3d(ax3d, ground_box, camera_external, 'blue', 'red') 
     167up_rect_max    = plot_polygon_3d(ax3d, up_rect,    camera_external, 'blue', 'red') 
    162168 
    163169set_axes_3d(ax3d, max( 
    164         points_max, ground_box_max, 
     170        rectangle_max, ground_box_max, 
    165171        np.max(camera_location), 
    166172        np.max(camera_target) 
    167173)) 
    168174 
    169 P = np.dot(camera_intrinsic, camera_external) 
    170 points_2d = np.dot(P, points.T).T 
    171 homogenize(points_2d) 
    172 ground_box_2d = np.dot(P, ground_box.T).T 
    173 homogenize(ground_box_2d) 
     175 
     176## 2D Plot 
     177def plot_2d(P, points): 
     178        points_2d = np.dot(P, points.T).T 
     179        homogenize(points_2d) 
     180        pyplot.plot(points_2d[:,1], points_2d[:,0]) 
    174181 
    175182figure = pyplot.figure() 
    176 pyplot.plot(points_2d[:,1], points_2d[:,0]) 
    177 pyplot.plot(ground_box_2d[:,1], ground_box_2d[:,0]) 
     183plot_2d(P, rectangle) 
     184plot_2d(P, ground_box) 
     185plot_2d(P, up_rect) 
    178186pyplot.axis((0, 2592, 0, 1936)) 
    179187pyplot.xlabel('x')