Computer Vision


OpenCV and Python are being used to program a robot, with a Linux OS, to sense the distance to an object using stereovision. After calculating the distance to two beacons, the intersection of circles centered about the beacon's known locations with radii equal to the calculated distances will be used to localize the robot. Knowing the (x,y) coordinates of the robot within the constructed coordinate frame (constructed using the beacons), the position of the robot can be found and appropriate correction to keep the robot on course can be sent to the motors. This is essentially the programming aspect of the senior design capstone project for my Mechanical Engineering degree.

Here is a video of the Python software which finds a beacon (red and blue circles on paper) in the left and right camera, and outputs the difference in horizontal pixels. Take note that no calculations take place unless the beacon is properly oriented. This is a necessary feature to get rid of all of the detected blobs that are not beacons, i.e noise rejection.





To find the Hue values of the circles I printed out, I used the program pick_and_track.py found here. The color tracking algorithm I use is based on the multi_color_two_object.py example found in the same place. The circle intersection algorithm is based on analysis performed in this document:

It should also be noted that in the video, the left and right camera feeds are "warped" to get rid of lens distortion. This is accomplished by using camera calibration code and a calibration image which can be printed out here. I changed the calibration code a bit so that the first declarations are replaced with:

  1. board_w=8 # number of horizontal corners  
  2. board_h=5 # number of vertical corners  
  3. n_boards=20 #number of calibration images  
  4. board_n=board_w*board_h #number of total corners  
  5. board_sz=(board_w,board_h) #size of board  

This will wait for 20 successful calibration images and the board height and width is declared to work with the sample image I linked. The code was also augmented to calibrate two cameras simultaneously, using the same chessboard locations for the left and right images.


No comments:

Post a Comment