View Single Post
  #4   Spotlight this post!  
Unread 30-04-2013, 22:52
faust1706's Avatar
faust1706 faust1706 is offline
Registered User
FRC #1706 (Ratchet Rockers)
Team Role: College Student
 
Join Date: Apr 2012
Rookie Year: 2011
Location: St Louis
Posts: 498
faust1706 is infamous around these partsfaust1706 is infamous around these parts
Re: pic: Multi Disk Tracking

When I ran it with a kinect, they fps was about 20, so it was indeed the camera.

I used ubuntu 12.10 with the newest version of the opencv libraries.

I captured a RGB image, then converted it to HSV, then split the HSV into 3 images, H, S, and V. Then thresholded to eliminate all but one color (red, white or blue). Now it is a binary image, which opencv likes. I found the contours of the image using cvFindContours, and found the centers of each contour by using image moments. (tutorial found here:http://www.aishack.in/2010/07/tracki...cts-in-opencv/) -note- this guy, who I admire a lot, used

CvMoments *moments = (CvMoments*)malloc(sizeof(CvMoments));
cvMoments(imgYellowThresh, moments, 1);

where I replaced my source from being an entire image to just the contour, so I could track multiple things at once. so mine code read

CvMoments *moments = (CvMoments*)malloc(sizeof(CvMoments));
cvMoments(Contour, moments, 1);

That gives subpixel accuracy for the center. Moving on. To draw the circle, I used cvApproxPoly, and said that if the result > 5, then I am going to make the assumption it is a circle, if it has < 5 sides, I don't like it.

The next step is fitting a box around the contours. Then drawing the largest ellipse possible within that box. That ellipse is what is coloured on the image.

I'll post the program up here whenever I get a chance to take it from a computer at school.

Also, I only saved the frisbee that was closest to the camera per colour. So which one was lowest on the screen. Which one had the largest y value (opencv's coordinate plane is positive x to the right, positive y down). It was a simple algorithm that I actually used a lot in tracking the alliance wall:

cvPoint CurrentFrisbee;
double PrevClosestFrisbee = 0;
if(CurrentFrisbee.y > PrevClosestFrisbee)
{
PrevClosestFrisbee = CurrentFrisbee;
}
A very simple yet very powerful conditional statement.

If you have anymore questions I'd love to answer them.
__________________
"You're a gentleman," they used to say to him. "You shouldn't have gone murdering people with a hatchet; that's no occupation for a gentleman."
Reply With Quote