|
Re: Camera tracking and following
For starters we'll assume your camera is pointed straight ahead. So the first thing you'll want to know is if the target is to the left or right of center. The target coordinates come out of the Two Color Servo Example VI and give you X and Y in the image. The X will be the target's horizontal position and the Y will be the vertical position. Note that the origin in most image processing applications is at the top left of the image so the positive Y direction is downward.
You will then need to know the size (resolution) of the image that you are using. Let's assume your image size is 640x480 (I think this is the full size image that the camera can return, but you can specify smaller ones for faster frame rates). If the X value of target position is 320, then the target is straight ahead. If the X is less than 320, then the target is to the left. If the X is greater than 320, then the target is the right.
If you are using arcade steering in the Basic Robot Main.vi (I believe this is the out of the box default), then the X Axis Value of the Arcade Drive.vi will tell the robot whether to head left or right. So a simplistic approach might be to wire a 1 into the X Axis Value of the Arcade Drive.vi to go right and a -1 to go left. However, this will likely be too chaotic and you should reduce the magnitude of the X Axis Value as the target gets closer to center.
|