Go to Post this thread made crave bacon so badly that I am now, as I write this, cooking 2 pounds of it. :o - gvarndell [more]
Home
Go Back   Chief Delphi > Technical > Programming > C/C++
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Reply
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 25-01-2009, 18:10
WatersongX WatersongX is offline
Registered User
AKA: Matthew Keen
FRC #1111 (Powerhawks)
Team Role: Programmer
 
Join Date: Feb 2008
Rookie Year: 2006
Location: Edgewater, MD
Posts: 7
WatersongX is an unknown quantity at this point
Send a message via AIM to WatersongX
Question Raw Camera Data

I've been dabbling in the camera inputs, as our team's mechanism is finally starting to come together, and I've noticed the color tracking that either NI or WPI set up (Not sure who the code is coming from) is very crudely written. Does anyone know of a way to get the raw data from the camera (preferably like a two-dimensional array of ints with rgb data)? I have written code to filter out blobs of known colors (And it works with pretty much any color, not just the bright pinks and greens for this), though I have yet to find a way to define their bounds without just averaging the position of each pixel of a given color. All I need is that array.

Thanks for your help
Reply With Quote
  #2   Spotlight this post!  
Unread 25-01-2009, 20:36
Greg McKaskle Greg McKaskle is offline
Registered User
FRC #2468 (Team NI & Appreciate)
 
Join Date: Apr 2008
Rookie Year: 2008
Location: Austin, TX
Posts: 4,748
Greg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond repute
Re: Raw Camera Data

If you look into the nivision.h file, you should find something to extract pixel integers from the image file. Sorry I can't be more helpful, but I don't have the C tools installed on this computer. But it exists in LV, so I know it exists in C. If you are looking to do the comparisons in RGB, I'd encourage you to compare it against the color tracking in the WPI or nivision file. The nivision stuff is going to be hard to beat for standard algorithms like color thresholds. Second, I think you'll find that the algorithm will be far more resilient using HSL math.

Greg McKaskle
Reply With Quote
  #3   Spotlight this post!  
Unread 25-01-2009, 22:14
WatersongX WatersongX is offline
Registered User
AKA: Matthew Keen
FRC #1111 (Powerhawks)
Team Role: Programmer
 
Join Date: Feb 2008
Rookie Year: 2006
Location: Edgewater, MD
Posts: 7
WatersongX is an unknown quantity at this point
Send a message via AIM to WatersongX
Re: Raw Camera Data

I'm using an algorithm I designed from scratch that doesn't use thresholds. And my algorithm uses an HSV derived colorspace, slightly diffent than HSL but I believe it to be more effective. We'll see how it works though, and thanks for the heads up.
Reply With Quote
  #4   Spotlight this post!  
Unread 25-01-2009, 23:32
Greg McKaskle Greg McKaskle is offline
Registered User
FRC #2468 (Team NI & Appreciate)
 
Join Date: Apr 2008
Rookie Year: 2008
Location: Austin, TX
Posts: 4,748
Greg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond repute
Re: Raw Camera Data

Sounds good so far. I'm curious to hear how it goes, and more about details.

Greg McKaskle
Reply With Quote
  #5   Spotlight this post!  
Unread 26-01-2009, 00:38
wt200999's Avatar
wt200999 wt200999 is offline
Texas Instruments
AKA: Will Toth
FRC #3005 (Robochargers)
Team Role: Mentor
 
Join Date: Mar 2006
Rookie Year: 2004
Location: Dallas, Texas
Posts: 323
wt200999 has much to be proud ofwt200999 has much to be proud ofwt200999 has much to be proud ofwt200999 has much to be proud ofwt200999 has much to be proud ofwt200999 has much to be proud ofwt200999 has much to be proud ofwt200999 has much to be proud ofwt200999 has much to be proud of
Send a message via MSN to wt200999
Re: Raw Camera Data

Quote:
Originally Posted by Greg McKaskle View Post
If you look into the nivision.h file, you should find something to extract pixel integers from the image file. Sorry I can't be more helpful, but I don't have the C tools installed on this computer. But it exists in LV, so I know it exists in C. If you are looking to do the comparisons in RGB, I'd encourage you to compare it against the color tracking in the WPI or nivision file. The nivision stuff is going to be hard to beat for standard algorithms like color thresholds. Second, I think you'll find that the algorithm will be far more resilient using HSL math.

Greg McKaskle
Maybe you are looking for
void* imaqImageToArray(const Image* image, Rect rect, int* columns, int* rows);
although it doesn't show hsv

take a look in C:\WindRiver\docs\extensions\NIVisionCVI.chm it describes all the functions as well as the data structures etc.
__________________
Programming in LabVIEW? Try VI Snippets!

FIRST LEGO League 2004 - 2005
FRC Team 870 Student 2006 - 2009
FRC Team 3005 Mentor 2013 -

Last edited by wt200999 : 26-01-2009 at 00:40.
Reply With Quote
  #6   Spotlight this post!  
Unread 26-01-2009, 10:43
WatersongX WatersongX is offline
Registered User
AKA: Matthew Keen
FRC #1111 (Powerhawks)
Team Role: Programmer
 
Join Date: Feb 2008
Rookie Year: 2006
Location: Edgewater, MD
Posts: 7
WatersongX is an unknown quantity at this point
Send a message via AIM to WatersongX
Re: Raw Camera Data

Thanks, I'll take a look at it at our team's meeting today, and that it doesn't show HSV is a good thing. Calculating HSV from RGB is a tad expensive, notably the hue component, so we are going to avoid that until we need it.

Code:
typedef struct {
	float r; /* Range of [0,1] */
	float g;
	float b;
} Colorf;

float maxRGB ( Colorf* input )
{
	return ( input->r > input->b && input->r > input->g )? input->r : ( input->b > input->g )? input->b : input->g;
}

float minRGB ( Colorf* input )
{
	return ( input->r < input->b && input->r < input->g )? input->r : ( input->b < input->g )? input->b : input->g;
}

angle hue ( Colorf* input )
{
	float maxvalue = maxRGB( input );
	float minvalue = minRGB( input );
	if ( maxvalue == 0 ) return 0;
	else if ( maxvalue == input->r ) return ( ( LAMBDA / 3 ) * ( ( input->g - input->b ) / ( maxvalue - minvalue ) ) + ( 2 * LAMBDA ) );
	else if ( maxvalue == input->g ) return ( ( LAMBDA / 3 ) * ( ( input->b - input->r ) / ( maxvalue - minvalue ) ) + ( 2 * LAMBDA / 3 ) );
	else return ( ( LAMBDA / 3 ) * ( ( input->r - input->g ) / ( maxvalue - minvalue ) ) + ( 4 * LAMBDA / 3 ) );
}

float sat ( Colorf* input )
{
	if ( input->r == 0 && input->g == 0 && input->b == 0 ) return 0;
	return 1 - maxRGB( input ) - minRGB( input );
}

#define val maxRGB
Here's a quick thing on how to do the conversions I wrote last night in C, since C is arguably faster than C++ (though my float calculations don't help much XD). I was going to change this to use unsigned chars, and if I get around to it (In my free time, when such a thing exists again) handwrite a library in assembly to do it as fast as possible. Though I'm not too terribly concerned. We haven't had a problem with processing on the cRIO yet this year. Thanks again for your help.
Reply With Quote
  #7   Spotlight this post!  
Unread 26-01-2009, 15:12
WatersongX WatersongX is offline
Registered User
AKA: Matthew Keen
FRC #1111 (Powerhawks)
Team Role: Programmer
 
Join Date: Feb 2008
Rookie Year: 2006
Location: Edgewater, MD
Posts: 7
WatersongX is an unknown quantity at this point
Send a message via AIM to WatersongX
Re: Raw Camera Data

Quote:
Originally Posted by wt200999 View Post
Maybe you are looking for
void* imaqImageToArray(const Image* image, Rect rect, int* columns, int* rows);
although it doesn't show hsv

take a look in C:\WindRiver\docs\extensions\NIVisionCVI.chm it describes all the functions as well as the data structures etc.
Okay, today at our meeting we looked at that, and it looks like what we need, but we have been unable to figure out how to get the Image object we need. Do you know how to get this data?
Reply With Quote
  #8   Spotlight this post!  
Unread 01-02-2009, 19:54
Shira Shira is offline
Registered User
FRC #1836
Team Role: College Student
 
Join Date: Jan 2008
Rookie Year: 2008
Location: Los Angeles
Posts: 30
Shira is an unknown quantity at this point
Re: Raw Camera Data

I'd also like to get a bit more help on how to go about getting RGB and coordinates for pixels...I've worked with OpenCV before and my approach to programming the bot is influenced by that...My experience with object oriented programming is limited and the User Guide is helpful, but exhausting. I'd find it easier to get some raw data and make my own functions.
Reply With Quote
  #9   Spotlight this post!  
Unread 03-02-2009, 09:20
Greg McKaskle Greg McKaskle is offline
Registered User
FRC #2468 (Team NI & Appreciate)
 
Join Date: Apr 2008
Rookie Year: 2008
Location: Austin, TX
Posts: 4,748
Greg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond repute
Re: Raw Camera Data

In case you want to use it, the NI libraries already include HSL and HSV conversions. The color threshold in the examples is already being done in HSL.

And if you want the raw stuff imaqImageToArray() will get it for you.

Greg McKaskle
Reply With Quote
Reply


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
no camera data RDD Programming 1 19-02-2007 08:05
No camera data... D.Bear Programming 2 17-02-2007 18:57
Camera No Data Lakeeffect1674 Programming 5 04-02-2007 12:19
trasmitting data from a second camera iwdu15 Programming 1 02-02-2007 19:25
Served Raw Chicken at Burger King. MattK Chit-Chat 19 10-11-2005 00:56


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

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