LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

detecting color video

I am using a program basic off the Color Pattern matching example in CVI.  The camera I am testing can switch between color and B+W.  How can I detect if the image is color or B+W?  The pattern match program example will find a match both ways. 

Jon K.

0 Kudos
Message 1 of 5
(3,697 Views)
Hi Jon,

I took a look at the Color Pattern matching example, and it looks like it hard-coded to always be the image type of RGB.  What you can do is extract the pixel data for one of the pixels and compare the red, green, and blue values.  If they're all exactly the same, then you're probably dealing with a grayscale image.  Take a look at the NI Vision for LabWindows/CVI Function Reference Help for a list of all the Vision functions available (located in C:\Program Files\National Instruments\Vision\Documentation\NIVisionCVI.chm).  Also, to find out how the red, green, and blue values are stored, take a look at the NI Vision Concepts Manual (see page 1-4).

Hope this helps,
Irene Chow
National Instruments
Applications Engineer
0 Kudos
Message 2 of 5
(3,675 Views)

I am testing a camera that has a filter that switches the camera from Color to B+W.  I have a calibrated image that has various color images that I am using for various tests/measurements.  When the camera filter is turned on, the image appears B+W but it is saved as an RGB Image.  I am trying to detect if the filter actaully turned on.  I have a specific color patterned rectangle in my test image.  I am trying to pattern match by color only but can not get the image to learn.  Any Suggestions?

 

 

0 Kudos
Message 3 of 5
(3,662 Views)

I tried using the imaqGetPixel function.  The function returns a 1 (success) but the pixval is NULL.  I set pixval to NULL because I get an initialization error.  Any suggestions?  Here is my code:

int r,g,b;

PixelValue *pixval=NULL;

Point rgbpt;

rgbpt.x=centerx;

rgbpt.y=centery;

 stat = imaqGetPixel (tempImage, rgbpt, pixval);
    
  r= pixval->rgb.R;
  b= pixval->rgb.B;
  g= pixval->rgb.G;

0 Kudos
Message 4 of 5
(3,640 Views)

Whoops!  I found the problem.  I refrenced everything wrong!!  It works fine now,  Thank You!!

PixelValue pixval;

 stat = imaqGetPixel (tempImage, rgbpt, &pixval);   r=pixval.rgb.R;
  b= pixval.rgb.B;
  g= pixval.rgb.G;

0 Kudos
Message 5 of 5
(3,633 Views)