Tablet/Microcontroller Interface
The interface between the tablet and microcontroller will utilize the IEEE 802.11n wireless standard, since this standard calls for a 70m indoor/250m outdoor range which will afford the project a margin of error beyond its initial 40m specification.
The tablet will broadcast control information using this protocol, and the microcontroller will receive it via a Maple board made by weburban.com. The microcontroller will then, in turn, process this information on-board and output control to the servos.
Microcontroller/Gun Interface
The Arduino Uno has 6 analog inputs, labeled A0 through A5, each of which provide 10 bits of resolution (i.e. 1024 different values). By default they measure from ground to 5 volts, so to fire the laser pointer, which operates normally on two AA batteries, the microcontroller will simply have to, from any one of the A0 to A5 pins, be fed a binary value representing 3V. Since the 5V is divided by 1024 distinct values, a binary value is needed to represent that fraction. Thus, it is simply discernable by
(8)
which, rounding down to 614 and converting to binary, is a value of
which can be fed to the board via the analogreference{} function.
-
Camera Hardware
After deliberating amongst camera hardware and using a wireless USB interface, the group decided that using an integrated wireless-N camera would be the most efficient, elegant, and discrete solution. The model chosen was the Linksys WVC80N (LINKSYS by Cisco) for its price ($109.95 on Amazon.com), resolution (640x480), and relatively high frame rate for consumer cameras (30 fps). While this did not quite match the initial requirements, it should still be sufficient, as the velocity of the moving target was overestimated by a large margin.
Target Acquisition
One of the larger tasks of the project will be using the tablet to find and track moving targets based on the images transmitted by the wireless camera. This process can be divided into three fundamental operations. First, when an object initially comes into view of the camera, it must be recognized as a potential target. Next, the object must be represented in some way so that its basic boundaries are known and the processor knows where to aim the gun to hit the center of the target. Finally, since the object is not stationary, its movement must be tracked so that the turret can find the distance between the target location and the current gun position, and aim accordingly.
Object Detection
One of the common methods of object detection, especially for use in video security applications, is a technique known as background subtraction. In this technique, the processor “learns” what the background image looks like. This is then used as a reference with which to compare the current image. The known background parts are subtracted away, which leaves only the object in the foreground.
There are a numerous weaknesses in dealing with this method, which must be overcome to properly identify the targeted objects. One consideration to take into account is that the camera must be stationary for this method to work; otherwise each new image would differ entirely from the original frame of reference, which negates the purpose. Another concern is the separation of foreground and background. If, for example, a trash can is moved, it will be read as a foreground image in both its new location and in the hole it originally inhabited. To solve this problem, the program needs to classify three distinct layers: new foreground, old foreground, and background. When an object moves initially, it is placed in the new foreground. Then, after a specific amount of time has passed with no further movement, the object is relegated to the old foreground, where its pixels are gradually learned and joined to the learned background image. Another problem deals with a change in lighting. If the lights in a darkened room are suddenly turned on, it will appear that the entire image has changed, and thus everything is in the new foreground. To avoid this scenario, it can be stipulated that if a large number of pixels change at the same time, this constitutes a global change rather than a local one, which a new model can be set up to handle.
At the most basic level, background subtraction can be demonstrated in the following procedure, which is also illustrated in Figure 15. First, the difference between two frames, which may or may not be consecutive, is taken and set as the new foreground image. The program can utilize the function cvAbsDiff to find the divergence between the original frame, called frametime1, and the current frame, frametime2, and detect the magnitude of differences in frameForeground. To more clearly delineate the layers, the function cvThreshold can then be employed to set any pixel with a value less than 15 to 0, and any pixel with a value greater than 15 to 255. This way any small fluctuations due to noise can be moderated.
Figure : Basic Flowchart of Background Differencing
The simplicity of this program is useful for demonstrating the basic process of background subtraction, but in the real world it doesn’t correct for errors such as slight background movement. One method that is a little more complicated is the averaging background method, which learns the average and average difference for each pixel in the background image. The average difference is similar to standard deviation but faster to calculate, which makes it the better option for this procedure. This is useful because the background image will probably still contain miniscule movements of background objects due to environmental factors. This movement can be taken into account by analyzing the image over a period of time and finding the average value for each pixel, as well as the average difference which is due to background motion. When there is movement detected in the image, the program calculates whether or not the new pixels fall within the given range for average pixel difference. If they do, it is assumed to be part of the background layer. If, however, they fall outside of the computed range, the object is determined to be a new entity and classified to be a foreground object.
The following procedure was based off an example from the book “Learning OpenCV” by Gary Bradski and Adrian Kaehler. The first step is to initialize all the intermediate images that the program will use to hold the various values for each pixel, such as average, pixel difference, previous image, highest and lowest points in the range, etc. It also creates a variable called Icount, which is declared as a float, to be the counter for the number of images analyzed, so the average can be calculated at a later point. The function IplImage is used for these purposes
Share with your friends: |