Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Programming (http://www.chiefdelphi.com/forums/forumdisplay.php?f=51)
-   -   Tower Tracker 1.0 (http://www.chiefdelphi.com/forums/showthread.php?t=142173)

riftware 11-02-2016 00:09

Re: Tower Tracker 1.0
 
Quote:

Originally Posted by Fauge7 (Post 1527019)
Team 3019 graciously presents their vision tracking program for everybody to use and borrow! Now instead of dreaming about the perils of computer vision YOU can bring your team the joy of having a robot that is capable of tracking the target with ease! No more Grip crashes or weird deploys, can calculate fun things such as: distance to target, and angle to target! to be used to auto align and auto aim!

if you are going to modify the code, all i ask is give me and my team credit in a comment at the top of the code and comment your suggestions and or your praise!

My students are using Grip to get the countours out of the streamer but were still working on distance to target last I checked. We identify valid targets by taking the ration of length to width which I think is working pretty well. I think they were looking at taking a couple of known distances and identifying size at those distances and then extrapolating for distances between. Your methodology looks very interesting but I did have a couple of questions on the "angle"

(Note: Its been 28 or so years since I had to do more complicated math so go easy on me). It looked like in the code you had a known angle of the camera (I'm assuming vertical angle.) and you are plugging that in. I get how this works more or less for figuring out distance/vertical angle. Where we are struggling a bit is in figuring out when we are "off center" - given what you can get out of a contour I'm not sure we would know that we need to move a bit to the right or left in order for a shot to work. Did you wind up solving that? If the contour had given us the boundaries of the rectangle's length or coordinates then I think we could evaluate relative sizes to know to move left or right but I'm not sure even about that. Any feedback is appreciated!

legts 15-02-2016 10:34

Re: Tower Tracker 1.0
 
Would this code work with a Microsoft Lifecam?

lethc 15-02-2016 12:07

Re: Tower Tracker 1.0
 
Quote:

Originally Posted by legts (Post 1540544)
Would this code work with a Microsoft Lifecam?

You will have to modify a few lines of code but other than that... Yes.

kinganu123 15-02-2016 16:34

Re: Tower Tracker 1.0
 
Quote:

Originally Posted by lethc (Post 1540600)
You will have to modify a few lines of code but other than that... Yes.

Wait, is there a way to offload the usbcamera data onto a program on the computer?! I thought that wasn't possible yet...

lethc 16-02-2016 00:56

Re: Tower Tracker 1.0
 
Quote:

Originally Posted by kinganu123 (Post 1540728)
Wait, is there a way to offload the usbcamera data onto a program on the computer?! I thought that wasn't possible yet...

We are only using it to view the USB camera feed in the SmartDashboard

axton900 17-02-2016 17:21

Re: Tower Tracker 1.0
 
Has anyone gotten a python version of this code to work?
In python many of the methods that this code requires do not exist and this is a problem for many teams that plan on using Python for their vision processing.
We have trying to port this code for use as sample code for days but as you can see many of the functions do not exist which causes problems.
Here is our code.. so far
http://pastebin.com/ecdDFDQp

the rectangle class is the main problem we are being faced with. There seems to be no equivalent for those using Python. If anyone has found a solution to this issue. Then please let us know!
Thanks!

virtuald 18-02-2016 14:06

Re: Tower Tracker 1.0
 
Quote:

Originally Posted by axton900 (Post 1541873)
the rectangle class is the main problem we are being faced with. There seems to be no equivalent for those using Python. If anyone has found a solution to this issue. Then please let us know!
Thanks!

I believe that in the OpenCV python bindings rectangles are represented as tuples.

Fauge7 19-02-2016 00:04

Re: Tower Tracker 1.0
 
Quote:

Originally Posted by axton900 (Post 1541873)
Has anyone gotten a python version of this code to work?
In python many of the methods that this code requires do not exist and this is a problem for many teams that plan on using Python for their vision processing.
We have trying to port this code for use as sample code for days but as you can see many of the functions do not exist which causes problems.
Here is our code.. so far
http://pastebin.com/ecdDFDQp

the rectangle class is the main problem we are being faced with. There seems to be no equivalent for those using Python. If anyone has found a solution to this issue. Then please let us know!
Thanks!

This code runs on the driver station laptop, there is 0 need to switch programming languages unless you want it to run on the rio. I would avoid running it on the rio as that can cause issues during the match. All you need to do is setup the program like i instructed then simply run it, maybe even export it to have a runnable .jar file and a simple batch file to make executing easier.

Breadbocks 19-02-2016 00:51

Re: Tower Tracker 1.0
 
We got it all compiled into a jar and running, but it never seems to open the connection to the camera. It's at the right IP, if we put the address in the code in our browser the mjpg stream comes up, but it just sits at opening forever in the cmd prompt.

Fauge7 20-02-2016 10:47

Re: Tower Tracker 1.0
 
Quote:

Originally Posted by Breadbocks (Post 1542567)
We got it all compiled into a jar and running, but it never seems to open the connection to the camera. It's at the right IP, if we put the address in the code in our browser the mjpg stream comes up, but it just sits at opening forever in the cmd prompt.

We had this problem too, we fixed it by installing the ffmpeg codec into the system32 like I mentioned on the front page.

JohnM 20-02-2016 14:09

Re: Tower Tracker 1.0
 
Quote:

Originally Posted by Fauge7 (Post 1543132)
We had this problem too, we fixed it by installing the ffmpeg codec into the system32 like I mentioned on the front page.

I did this, but it is still not pulling the images off the camera. I'm not exactly using this code, but the code is the same for getting the images from our network camera.
Any idea?

joeojazz 20-02-2016 14:25

Re: Tower Tracker 1.0
 
Do you know if you can find the distance with this anyone

Fauge7 21-02-2016 12:17

Re: Tower Tracker 1.0
 
Quote:

Originally Posted by joeojazz (Post 1543200)
Do you know if you can find the distance with this anyone

yes, update the constants with the constants on YOUR robot, you will find the distance to be accurate to within +- 6-8 inches.

joeojazz 22-02-2016 14:58

Re: Tower Tracker 1.0
 
Quote:

Originally Posted by Fauge7 (Post 1527019)
Team 3019 graciously presents their vision tracking program for everybody to use and borrow! Now instead of dreaming about the perils of computer vision YOU can bring your team the joy of having a robot that is capable of tracking the target with ease! No more Grip crashes or weird deploys, can calculate fun things such as: distance to target, and angle to target! to be used to auto align and auto aim!

if you are going to modify the code, all i ask is give me and my team credit in a comment at the top of the code and comment your suggestions and or your praise!

to install:
  • download opencv 3.1 from here
  • download Network table 3.0 jar
  • make a new project in eclipse
  • make opencv and networktables added as a user library to the build path of your new project
  • copy opencv_ffmpeg310_64.dll from C:\Path\to\opencv\build\bin to C:\Windows\System32
  • add the code in a class that is named TowerTracker.java
  • when your ready to export
  • export the .jar file as a runnable jar
  • move the .jar to a folder similar to this
  • run the .jar with "java -jar c:\Path\to\TowerTracker.jar" on a command prompt window

the code is just an example of what it can do, i can add network table stuff soon but i thought i would publish it first!
github link

want to see an example of what it can output?
here you go!

how it works: using an axis camera or a mjpeg streamer you can use a stream of a webcam to process images using an opencv program that runs on the driver station computer. This program can be modified to run on a coprocessor and directly input to the roborio for even better results because network tables can only go at 10hz vs the camera stream which is 30hz...this program can easily be ported over to c++ and python and would probably run better with those as c++ and python are way more supported then java with opencv.

Can't find the .jar where is it located at.

alexpell00 09-03-2016 16:50

Re: Tower Tracker 1.0
 
Thanks for the code, really helped! If anyone is having trouble with the thresh holds you can take the HSV image to http://html-color-codes.info/colors-from-image/ to pull the hex colors of the target. Once you have 3-5 hex colors simply convert them to bgr and find the range from high to low (add/subtract 10% on either end to make it work better).


All times are GMT -5. The time now is 22:01.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi