Vision-based Cannon

From Mech
Jump to navigationJump to search

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)

-classify target shapes

Servo Calibration

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