Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Programming (http://www.chiefdelphi.com/forums/forumdisplay.php?f=51)
-   -   Tracking 2 targets (http://www.chiefdelphi.com/forums/showthread.php?t=51642)

Smoking_Gun 12-01-2007 08:32

Tracking 2 targets
 
Hi, I'm having a small trobble finding out how can I track 2 targets with the new CMUCam 2 code.
Can someone explain it to me?

10x Tal

bear24rw 12-01-2007 08:45

Re: Tracking 2 targets
 
From my understanding you cannot actually "track" multipul targets. You can only identify how many there are. The blob size returned from the camera will be twice as large as a regular blog size if you are looking at two targets, but I dont believe that you can actually "track" two target..

Smoking_Gun 12-01-2007 08:53

Re: Tracking 2 targets
 
Quote:

Originally Posted by bear24rw (Post 554833)
From my understanding you cannot actually "track" multipul targets. You can only identify how many there are. The blob size returned from the camera will be twice as large as a regular blog size if you are looking at two targets, but I dont believe that you can actually "track" two target..

But if one is far apart from the other (Like on the rack) and I want to know the angle between them?

steveg 12-01-2007 08:59

Re: Tracking 2 targets
 
rst of all, which are you using, EasyC or mplab?

I'm going to assume that you're using mplab and relatively new to this, given your team number.

Have you downloaded Kevin Watson's camera code at http://www.kevin.org/frc? It's a great place to start if you're unfamiliar with the CMUCam.

Anyway, once you download that, compile it and load it onto your RC. Be sure that your pan and tilt servos are plugged into pwm01 and pwm02. Connect power and the TTL inputs to the camera to the appropriate place. Turn it on, and the camera should start panning around looking for the target.


Now, when your programming cable is plugged in, the console open, and the camera tracking, you can see a bunch of data, including the x and y locations of a bounding rectangle, the center of that rectangle, and the percentage of pixels in that rectangle that are being tracked. That percentage value is called the confidence. If you're tracking a single target, your confidence value should be fairly high. If you're tracking multiple targets, there will be a huge space of untracked pixels in between the two targets, which will lower your confidence substantially. So, if you see a big bounding box with low confidence, you can figure out that you're tracking two targets.

Smoking_Gun 12-01-2007 09:33

Re: Tracking 2 targets
 
Quote:

Originally Posted by steveg (Post 554841)
....

Thank you, but I know all this from last year.
All I'm asking is how can I track 2 targerts or at least know the angle between them.

Tom Bottiglieri 12-01-2007 09:44

Re: Tracking 2 targets
 
Quote:

Originally Posted by Smoking_Gun (Post 554862)
Thank you, but I know all this from last year.
All I'm asking is how can I track 2 targerts or at least know the angle between them.

He told you.

There is no way to "track" two targets. The CMUCam2 firmware still only allows 1 target to be tracked. If it sees multiple color blobs, it will include them all in its "bounding box" and return a low confidence value.

Look at the spread of the bounding box. When tracking two targets it will most likely look like a very wide rectangle. From that you can determine the left and right limits of the targets. Using the servo angle, X center of the bounding box, and a little math, you can figure out exactly where they are in relation to your robot.

Workaphobia 12-01-2007 14:24

Re: Tracking 2 targets
 
Since the two lights should be at the same height, it seems that you only need the width of the bounding box to determine their two positions. However I think in general it should be possible to generate multiple bounding boxes for each target by using the virtual window features of the camera. That is, you should be able to cut the area being processed in half and operate only on that side, thus cropping the other light out of the picture.

But I'm not sure - I'm just an alumnus, I've never even plugged in the camera.

BradAMiller 13-01-2007 06:33

Re: Tracking 2 targets
 
Take a look at the following web site:
http://first.wpi.edu/FRC/25814.htm

It has a video that describes how to identify that you are tracking two lights and some sample code that will let you get a start playing with the camera.

Keith Watson 15-01-2007 00:07

Re: Tracking 2 targets
 
Unfortunately, the only place in the frc_camera code which can be used as data from the camera to do non-default searching and tracking behaviors is the T_Packet_Data_Type struct in camera.h. And it is not documented in that file as to what the fields are. Or in a txt file.

If you look at the only non-easyC code on the WPI site it uses an undocumented API call which does not seem to be available with the frc_camera code. Where that API call is used in the non-easyC code has descriptive variable names, assuming that the argument order happens to match the order of the fields in the T_Packet_Data_Type struct.

Is there anyplace where this stuff is officially documented? If not it really should be added to the .h file where the struct is defined. Last year new people kept asking questions about this right up to the first regionals. I expect the same this year.

Kevin Watson 15-01-2007 01:11

Re: Tracking 2 targets
 
Quote:

Originally Posted by Keith Watson (Post 557023)
Unfortunately, the only place in the frc_camera code which can be used as data from the camera to do non-default searching and tracking behaviors is the T_Packet_Data_Type struct in camera.h. And it is not documented in that file as to what the fields are. Or in a txt file.

If you look at the only non-easyC code on the WPI site it uses an undocumented API call which does not seem to be available with the frc_camera code. Where that API call is used in the non-easyC code has descriptive variable names, assuming that the argument order happens to match the order of the fields in the T_Packet_Data_Type struct.

Is there anyplace where this stuff is officially documented? If not it really should be added to the .h file where the struct is defined. Last year new people kept asking questions about this right up to the first regionals. I expect the same this year.

The information you seek is the the file "CMUcam2_data_packets.pdf" available on my website since January 10th, 2006. The point about the t-packet not being documented in the header file is a good one and I'll make that change when I freshen the code in the next few days.

-Kevin

amateurrobotguy 15-01-2007 02:36

Re: Tracking 2 targets
 
Alrighty then, I got a quick, late night question. This "rectangle" will be determined by blob size?

BradAMiller 15-01-2007 08:21

Re: Tracking 2 targets
 
Quote:

Originally Posted by Keith Watson (Post 557023)
Is there anyplace where this stuff is officially documented? If not it really should be added to the .h file where the struct is defined. Last year new people kept asking questions about this right up to the first regionals. I expect the same this year.

Hi Kieth -

Good question, I guess I should have done that.

For the easyC versions of the program, all the calls are extensively documented in the easyC help with the API and examples. If you use the WPILib version of the program, the entire API (not just the camera) is documented here:
WPILib docs

The library is the same one that easyC uses so it was trival to make a version of Neil Rosenberg's program that didn't require easyC for people who wanted a quick stand-alone MPLab project.

Dominicano0519 15-01-2007 08:39

Re: Tracking 2 targets
 
Quote:

Originally Posted by BradAMiller (Post 555556)
Take a look at the following web site:
http://first.wpi.edu/FRC/25814.htm

It has a video that describes how to identify that you are tracking two lights and some sample code that will let you get a start playing with the camera.


thanks for the link this really helped

Keith Watson 22-01-2007 00:26

Re: Tracking 2 targets
 
Kevin, thank you very much for that link! That is exactly what I was looking for.

I see that web page also has the camera calibration procedures, which our default 2007 camera has a problem with. Looks like I need to do some reading. But this is a different thread. :D

Regards,
Keith

mvalvo 22-01-2007 19:29

Re: Tracking 2 targets
 
Does anyone know if the code on the camera's microprocessor is different than the previous 2 years? If so, what changes were made?


All times are GMT -5. The time now is 02:08.

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