Log in

View Full Version : Camera Programming


2185Bilal
13-11-2012, 23:20
So after three years, our team has finally decided to use a camera on the robot.
Since I was in the team three years ago, i dont have a single idea how to program the camera.

So I would like to ask the greater programmers at CD, to help me.

What do I need to program a robot to track the 4 squares (used in rebound rumble), and then move the robot so it aligns straight towards the target.

Like what electrical components do i need and how do I program a camera

thanks for the help

McGurky
14-11-2012, 09:42
Electrically, all you need is the camera (axis cam), an Ethernet cord to plug into your bridge, and the power cable wired to 5v on the Power Distribution Board.

For setting up and configuring the camera, refer to this document (search camera)

http://www.usfirst.org/sites/default/files/uploadedFiles/Robotics_Programs/FRC/Game_and_Season__Info/2012_Assets/Getting%20Started%20with%20the%202012%20FRC%20Cont rol%20System_2.pdf

There is a great write up on the vision targets here:

http://firstforge.wpi.edu/sf/docman/do/listDocuments/projects.wpilib/docman.root

With Java code examples and an explanation of the theory! (Read all the documentation and you will learn alot, if you have specific questions, ask them here and the community will help!)

2185Bilal
14-11-2012, 20:11
Okay thanks,

So I do have one question:

So here I have a snippet of the sample code given for Java programming:
//ColorImage image = camera.getImage(); // comment if using stored images
ColorImage image; // next 2 lines read image from flash on cRIO
image = new RGBImage("/10ft2.jpg");
BinaryImage thresholdImage = image.thresholdRGB(255, 255, 0, 0, 0, 0); // keep only red objects
BinaryImage bigObjectsImage = thresholdImage.removeSmallObjects(false, 2); // remove small artifacts
BinaryImage convexHullImage = bigObjectsImage.convexHull(false); // fill in occluded rectangles
BinaryImage filteredImage = convexHullImage.particleFilter(cc); // find filled in rectangles

Now, the part that I have in bold, when I remove the "//" from the "ColourImage image = camera.getImage();" and comment out the other two lines. Netbeans gives me the error saying:
unreported exception AxisCameraException; must be caught or declared to be thrown

So what does this mean, and am I supposed to get this error, because I want to use my camera to obtain my image, not the sample images.

Also, I was just wondering. If I do happen to use the sample image, how do I get it on the cRIO. I know in the documentations it says, ftp to the root directory. But what does that actually mean, like how do i ftp to the cRIO, which software do I use and etc.

Thanks in advance

~Cory~
15-11-2012, 15:17
camera.getImage() can cause errors (think about if you tried to fetch an image that didn't exist) so you need to surround it with a

try{
//getImage
}
catch (Exception e){
//insert code to log error here, if wanted

//handle the error by notifying the user to fix what ever is throwing the //error.

}

2185Bilal
15-11-2012, 16:21
Okay thanks
But how do i download the sample images to the crio via ftp

Could u like tell me how to do it

cgmv123
15-11-2012, 19:35
ftp://10.28.15.2/

~Cory~
15-11-2012, 23:14
Use the address that cgmv123 posted (if you are using the default ip set up).

You can use FileZilla which has a graphic user interface or the default ftp

using a CLI FTP
Change to the current directory to the one with the image files
run ftp
type "open 10.28.15.2" and press enter
leave username and password blank
type "bin"
use the "cd" command to move to the directory that you want the files in
the use the "put" command to upload files.