# Vision Tracking Solution

I am proud to announce Team 3019’s Vision tracking in java!

I have found that the libraries from First are too unreliable or do not even work and have researched a solution to tracking a yellow tote with or without the retro-reflective tape with green led ring-light. The solution I created runs on the driver-station computer meaning it will not interfere with the RobotRio’s processing power but should take up more bandwidth.

I commented the code to describe my methodology and tried to make it as readable as possible. The program does not have a graphical user interface (gui) as it is the bare bones vision tracking without distance or any information based purely based on location of it relative to the point (0,0).

If you are going to use it all I ask is to give credit where credit is due.

Cheers!

Interesting solution, nice work on it. It’s very sleek and simple.

Good job! It takes a lot of work to do just this, believe it or not.

If you want to take it one step further, you can figure out the angle the camera(robot) needs to move to make the center of the object the center of the image.

Simply solve this proportion

Image width/Fov_x= distance from the center of the image/degrees

be careful though, the origin of the image in opencv is the top left, so you have to do a linear remapping of the point so the origin is the center of the screen!

proof of concept: In 2013 we used this x rotation value to line up with the 3 pt goal autonomously using a pid as shown slightly in this video: http://youtu.be/VhE10dNBxXs?t=27s

Those micro adjustments were not done by our driver, but rather by simply pushing a button on the controller to line up.

This is just food for thought. Take it as you will. (You can also calculate distance to your target if your camera height and angle stay constant, that involves y rotation )

Hey, sorry for being a tad scrubby, but where is the OpenCV Library you are using?

Continuing in my eternal scrubiness, I got the library working fine, but I keep getting an error on
NATIVE_LIBRARY_NAME cannot be resolved or is not a field

Any ideas? All the imports are working, and code referencing objects/fields in the library aren’t throwing any errors.
I’d appreciate any help I could get.

for version 2.4.10 the string value is “opencv_java2410”

Hello,
I am wondering if other FRC teams are allowed to copy this code.
Thanks.

of course! Just give credit to my team(3019) that’s all I ask!

Updated! fixed a big memory leak!

At the moment we are trying to get our robot to center itself with the bin by rotating (later on by strafing as well). How might we go about getting the center of the bin from your program? First time trying to implement Vision and am having some troubles fully understanding.

The import for opencv “highgui” is not working, like it can’t find it. Any help would be appreciated.

This solution uses opencv 2.4.10 not 3.0

Thanks I believed that worked. But when we’re creating java classes on roborio, we get errors. We have installed the libraries for OpenCV.

It’s meant to be run on the driverstation laptop not the actual robot

My laptop has OpenCV 2.4.10, and when we tried to upload code that had OpenCV in it, errors started with the imports, and then every time any part of OpenCV was located it was an error.

try adding the opencv library to the build path of the project in eclipse

right click the project>java build path>Libraries>add external jar> find the java library installed should be in /path/to/opencv/build/java/opencv-2410.jar

its meant to be run on the driverstation computer not the robotcode.

Well I can’t run the robot from the driver station computer with the code that has OpenCV when I can’t upload code to the robo-rio. I get a build failed every time I try to upload the code.