Go to Post I'm unconvinced that this thread itself is not a performance art piece. - DCA Fan [more]
Home
Go Back   Chief Delphi > Technical > Programming
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Closed Thread
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 12-01-2009, 14:32
LinuxMercedes LinuxMercedes is offline
Real men use Macs
FRC #1444 (Lightning Lancers)
Team Role: Programmer
 
Join Date: Jan 2009
Rookie Year: 2009
Location: St. Louis, MO
Posts: 22
LinuxMercedes is an unknown quantity at this point
Camera not working

I have been trying to get the camera to work with the cRIO. We set the camera up as per the directions and hooked it into the cRIO via the crossover cable. I compiled their default camera code and uploaded it to see if it was working, but the terminal just prints "Unable to find color" (or something along those lines). No matter how close or far away I hold the green cloth it won't see it.

I heard that there are still bugs in the camera color recognition code...is that true? Or are we having a different problem?
__________________
  #2   Spotlight this post!  
Unread 12-01-2009, 23:52
foemill's Avatar
foemill foemill is offline
What do you mean it's overweight?
AKA: Eric Miller
FRC #1270 (Red Dragons)
Team Role: Mentor
 
Join Date: Feb 2007
Rookie Year: 2007
Location: Cleveland, Ohio
Posts: 12
foemill is on a distinguished road
Re: Camera not working

I've been having the same problem here. I managed to get the LabView code working with the camera (including tracking) but the vision API's written in C/C++ don't seem to be working correctly. I'm going to dig into the libs further and see if I can generate my own wrapper class for the vision API. I really don't want to use LabView. Give me gcc and vi and I'm happy. There's just something about GUIs that get me.
  #3   Spotlight this post!  
Unread 13-01-2009, 00:24
JamesByrne's Avatar
JamesByrne JamesByrne is offline
Registered User
FRC #0360 (The revelution)
Team Role: Mentor
 
Join Date: Jan 2006
Rookie Year: 2003
Location: Tacoma
Posts: 74
JamesByrne is on a distinguished road
Re: Camera not working

did you set the color in the code to red, if i remember right the default color that it is searching for is red.

Also did you build the camera pan tilt mount? so that you can use it with that.
__________________
  #4   Spotlight this post!  
Unread 13-01-2009, 00:29
comphappy comphappy is offline
Registered User
AKA: Brennan Ashton
FRC #2605 (A2D_16)
Team Role: Leadership
 
Join Date: Jan 2008
Rookie Year: 2008
Location: Bellingham, WA
Posts: 157
comphappy is a splendid one to beholdcomphappy is a splendid one to beholdcomphappy is a splendid one to beholdcomphappy is a splendid one to beholdcomphappy is a splendid one to beholdcomphappy is a splendid one to beholdcomphappy is a splendid one to behold
Send a message via AIM to comphappy
Re: Camera not working

what does line 114 say. This sets the mode for the demo. By default it is STOPLIGHT which does
"
/* this simple test move forward for green

* and move away for red

*/
"

You might want to try GOFORWARD
"
/* this simple test will drive forward if COLOR is detected

* drive will last until autonomous terminates

*/
"
The color is GREEN in that example

Also check SNAPSHOT to see what the image looks like. If it is too dim the image goes all grey and will not pick the color up.
__________________
A2D Solving the Imaginary Error Function...
  #5   Spotlight this post!  
Unread 13-01-2009, 09:11
foemill's Avatar
foemill foemill is offline
What do you mean it's overweight?
AKA: Eric Miller
FRC #1270 (Red Dragons)
Team Role: Mentor
 
Join Date: Feb 2007
Rookie Year: 2007
Location: Cleveland, Ohio
Posts: 12
foemill is on a distinguished road
Re: Camera not working

I set up the camera using the LabView vision application and determined the hue, saturation and luminance with fixed color correction and exposure for the red piece of material supplied with the kit of parts. Using those values, I created the min/max structures for each property of the color I wanted to track as follows:
(the color values are not what I was using. this is just an example of what was in the code)


Range hue, sat, lum;
hue.minValue = 140; // Hue
hue.maxValue = 155;
sat.minValue = 100; // Saturation
sat.maxValue = 255;
lum.minValue = 40; // Luminance
lum.maxValue = 255;

ParticleAnalysisReport par;

if (StartCameraTask() == -1)
{
printf( "Failed to spawn camera task; Error code %s", GetErrorText( GetLastError()) );
}

// this code is in the operator control loop...
if (FindColor(IMAQ_HSL, &hue, &sat, &lum, &par)
{
printf(“color found at x = %i, y = %i", par.center_mass_x_normalized, par.center_mass_y_normalized);
printf(“color as percent of image: %d", par.particleToImagePercent); }
}


Runs without errors but FindColor returns a value of 128. I find this odd.

I also tried setting min/max values for all to 1 and 250 and it still couln't find anything. I think this should have found everything in the room no?


Quote:
Originally Posted by JamesByrne View Post
did you set the color in the code to red, if i remember right the default color that it is searching for is red.

Also did you build the camera pan tilt mount? so that you can use it with that.
  #6   Spotlight this post!  
Unread 13-01-2009, 09:30
Bongle's Avatar
Bongle Bongle is offline
Registered User
FRC #2702 (REBotics)
Team Role: Mentor
 
Join Date: Feb 2004
Rookie Year: 2002
Location: Waterloo
Posts: 1,069
Bongle has a reputation beyond reputeBongle has a reputation beyond reputeBongle has a reputation beyond reputeBongle has a reputation beyond reputeBongle has a reputation beyond reputeBongle has a reputation beyond reputeBongle has a reputation beyond reputeBongle has a reputation beyond reputeBongle has a reputation beyond reputeBongle has a reputation beyond reputeBongle has a reputation beyond repute
Send a message via MSN to Bongle
Re: Camera not working

Quote:
I heard that there are still bugs in the camera color recognition code...is that true?
Yes. See my thread here for temporary bugfixes for WPILib. These are completely unofficial and have only been tested on our robot.

Quote:
I also tried setting min/max values for all to 1 and 250 and it still couln't find anything. I think this should have found everything in the room no?
This is because the values from the camera run from 0 to 255, so you wouldn't have selected everything. The nature of the bugs means that FindColor is likely finding a single pixel or single small group of pixels before it finds the main 'big' particle, and returning that.
  #7   Spotlight this post!  
Unread 13-01-2009, 09:38
foemill's Avatar
foemill foemill is offline
What do you mean it's overweight?
AKA: Eric Miller
FRC #1270 (Red Dragons)
Team Role: Mentor
 
Join Date: Feb 2007
Rookie Year: 2007
Location: Cleveland, Ohio
Posts: 12
foemill is on a distinguished road
Re: Camera not working

It does tha same thing when I select realistic values grabbed from VisionAssist.

Quote:
Originally Posted by Bongle View Post
Yes. See my thread here for temporary bugfixes for WPILib. These are completely unofficial and have only been tested on our robot.


This is because the values from the camera run from 0 to 255, so you wouldn't have selected everything. The nature of the bugs means that FindColor is likely finding a single pixel or single small group of pixels before it finds the main 'big' particle, and returning that.
  #8   Spotlight this post!  
Unread 13-01-2009, 09:43
Bongle's Avatar
Bongle Bongle is offline
Registered User
FRC #2702 (REBotics)
Team Role: Mentor
 
Join Date: Feb 2004
Rookie Year: 2002
Location: Waterloo
Posts: 1,069
Bongle has a reputation beyond reputeBongle has a reputation beyond reputeBongle has a reputation beyond reputeBongle has a reputation beyond reputeBongle has a reputation beyond reputeBongle has a reputation beyond reputeBongle has a reputation beyond reputeBongle has a reputation beyond reputeBongle has a reputation beyond reputeBongle has a reputation beyond reputeBongle has a reputation beyond repute
Send a message via MSN to Bongle
Re: Camera not working

Quote:
Originally Posted by foemill View Post
It does tha same thing when I select realistic values grabbed from VisionAssist.
We spent the last 3 days trying to figure out why our realistic values didn't work, just like you. The bugs we found are why.

FindColor goes like this:
1) Selects all pixels in the latest camera image that match your color [this part is fine]
2) Treats groups of selected pixels as particles [this part is fine]
3) Takes the very first particles, regardless of size, and analyzes it [this is a bug because of bugs in GetLargestParticle and InArea]
4) Returns the analysis of this first group, rather than an analysis of the biggest set found.

That is why FindColor is broken, even for realistic colors.
  #9   Spotlight this post!  
Unread 13-01-2009, 09:49
Bongle's Avatar
Bongle Bongle is offline
Registered User
FRC #2702 (REBotics)
Team Role: Mentor
 
Join Date: Feb 2004
Rookie Year: 2002
Location: Waterloo
Posts: 1,069
Bongle has a reputation beyond reputeBongle has a reputation beyond reputeBongle has a reputation beyond reputeBongle has a reputation beyond reputeBongle has a reputation beyond reputeBongle has a reputation beyond reputeBongle has a reputation beyond reputeBongle has a reputation beyond reputeBongle has a reputation beyond reputeBongle has a reputation beyond reputeBongle has a reputation beyond repute
Send a message via MSN to Bongle
Re: Camera not working

And here's a picture to demonstrate the way it is broken.

The picture is an example of what the particle analysis actually uses: a 'thresholded' image where only the pixels that match your criteria are selected. The little dots are things like bright lights or pink/green dots in the background that inadvertently get selected. They are inevitable. The problem is that FindColor, as written, ALWAYS returns analysis on the first dot it finds.
Attached Thumbnails
Click image for larger version

Name:	example.PNG
Views:	36
Size:	4.1 KB
ID:	7139  
  #10   Spotlight this post!  
Unread 13-01-2009, 10:10
foemill's Avatar
foemill foemill is offline
What do you mean it's overweight?
AKA: Eric Miller
FRC #1270 (Red Dragons)
Team Role: Mentor
 
Join Date: Feb 2007
Rookie Year: 2007
Location: Cleveland, Ohio
Posts: 12
foemill is on a distinguished road
Re: Camera not working

Yes, i realize that but, in a real-world situation, you're not going to get the full range of values. To say "everything" was an exaggeration to explain the concept. But on the side of practical application, in a low-contrast setting it would have included practically "everything".


Quote:
Originally Posted by Bongle View Post

This is because the values from the camera run from 0 to 255, so you wouldn't have selected everything.
  #11   Spotlight this post!  
Unread 13-01-2009, 10:18
Bongle's Avatar
Bongle Bongle is offline
Registered User
FRC #2702 (REBotics)
Team Role: Mentor
 
Join Date: Feb 2004
Rookie Year: 2002
Location: Waterloo
Posts: 1,069
Bongle has a reputation beyond reputeBongle has a reputation beyond reputeBongle has a reputation beyond reputeBongle has a reputation beyond reputeBongle has a reputation beyond reputeBongle has a reputation beyond reputeBongle has a reputation beyond reputeBongle has a reputation beyond reputeBongle has a reputation beyond reputeBongle has a reputation beyond reputeBongle has a reputation beyond repute
Send a message via MSN to Bongle
Re: Camera not working

Quote:
Originally Posted by foemill View Post
Yes, i realize that but, in a real-world situation, you're not going to get the full range of values. To say "everything" was an exaggeration to explain the concept. But on the side of practical application, in a low-contrast setting it would have included practically "everything".
You're right, it would very nearly select every pixel and if FindColor worked properly it should totally return a particle with size nearly equal to your camera's pixel count. But so long as there was a way for a single small selected particle to exist (the middle of a lighting array or something), then you'd potentially have bad FindColor results if it decided to return that small pixel rather than the big particle.
Closed Thread


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Help Camera Not Working wingnut1705 Programming 1 18-02-2007 08:53
Camera not working in autonomous Roger Programming 9 09-03-2006 07:38
Camera code not working.... DemonYawgmoth Programming 5 11-02-2006 09:21
Camera not working st1nkm4n Programming 7 02-02-2006 08:22
Camera not working st1nkm4n Programming 0 31-01-2006 19:23


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

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


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