Difference between revisions of "Vision-based Cannon"

From Mech
Jump to navigationJump to search
Line 38: Line 38:


==Mechanics==
==Mechanics==


==Results==

==Future Work==

Revision as of 02:22, 18 March 2009

Overview

The goal of this project was to use computer vision algorithms to identify targets and direct a Nerf gun to fire at them.


Vision Overview

The vision system was implemented in Matlab to take advantage of their image acquisition and image processing toolboxes.

Target Extraction

Targets were cut from colored foam and attached to a black background. Raw images were captured in RGB format, which takes the form of an [m,n,3] matrix. [1]. While targets could be identified in such an image, it is much faster to work with binary matrices. [2] To do this some scalar threshold is needed, such that any pixel in the raw image having a value greater than the threshold becomes 1 in the binary image and anything less becomes 0. Rather than a static threshold which would be affected by room lighting, a dynamic threshold based on the median image brightness is used.

-capture raw image

-create brightness threshold

-create binary image based on threshold

-create a label matrix (identifies regions of interconnected pixels)

-remove small objects (pixel threshold)

-create list of targets: fill data structure with pertinent target properties (area, centroid, perimeter,shape,color,binary mask)

-classify target shapes

Servo Calibration

Since the camera and the Nerf gun are not coaxial a method of mapping servo angles to pixel positions in the image needs to be implemented. This is done by removing all targets from the background so that a laser on the pan/tilt assembly is easily visible. By moving the servos through various angles and finding the centroid of the laser on the background a lookup table can be created. Interpolation can then be used to determine the appropriate servo angles for a given pixel position of a target.

Electronics

The electrical system for this project consisted of a custom developed master/slave servo controller. Each actuator is controlled directly by a slave system that monitors a feedback potentiometer and implements PID control. Each slave in turn receives a position command from a master PIC, which itself is controlled by Matlab running on a PC.

Master PIC

Slave PIC

Mechanics

Results

Future Work