Discussion:
How to convert an array of RGB values to IMAQ image?
(too old to reply)
JSI
2007-08-17 19:10:19 UTC
Permalink
Hello,
 
I am using VideoCapX control from Fath Software to capture image, the method I want to use is GetRGB. The reference for this method is as following:
 





VideoCapX control
Fath Software

GetRGB method

Returns current video frame image as array of RGB values.

Syntax
Function GetRGB

Return value(none)

Remarks.

ExampleDim a() As Bytea = VideoCapX1.GetRGBFor y = 0 To 239 'image height is 240 pixels in this caseFor x = 0 To 319 '320 pixelsi = (y * (320 * 3)) + (x * 3)'NOTE: byte order isn't RGB, it's BGRPSet (x, y), RGB(a(i + 2), a(i + 1), a(i))Next xNext y
 
Does any body know how to convert the array to IMAQ image?
Thanks,
JSI
 
Guenter Mueller
2007-08-17 21:10:14 UTC
Permalink
To produce an IMAQ Image from an array you can you can use the C function imaqArraytoImage().In LabVIEW, NI Vision also provides a VI to create an IMAQ Image from a color array.
I don't have the representation order (RGB or BGR) in mind.If changing your byte order matters, simply change one line of your code to
PSet (x, y), RGB(a(i), a(i + 1), a(i + 2))
Regards, Guenter
JSI
2007-08-31 05:10:08 UTC
Permalink
Guenter,
 
Thank you for your help. I have figured out the way to convert it as attached picture.


GetRGB.JPG:
Loading Image...
JSI
2007-09-05 02:10:10 UTC
Permalink
Guenter,
 
You ask a very good question. In fact, the performance of this code is poor. The load of the CPU is high, and the frame rate of vidoe preview becomes very low. Any suggestion?
 
Thanks,
 
JSI
JSI
2007-09-05 02:40:10 UTC
Permalink
Bruce,
 
Even I remove the flip step the CPU load is still very high.
 
Do you have any example or more information on Join Numbers?
 
Thanks,
 
JSI
Bruce Ammons
2007-09-05 20:40:13 UTC
Permalink
Join Numbers is under the Advanced -> Data Manipulation palette (or was in LV 7.1).
It combines two smaller integers to make one larger integer.  You can combine two U8 values to get a U16, or two U16 values to get a U32 value.
For colors, you can combine two color planes to get a U16 value.  Use a second Join Numbers to add the third color plane, and it should be a correct representation of a color image.
Bruce
JSI
2007-09-12 05:10:14 UTC
Permalink
Hi Bruce,
 
I try Join Numbers as in the attachment, but the CPU load is still 100%. Any idea?
 
Thanks,
 
JSI


JoinNumbers.JPG:
Loading Image...
BlueCheese
2007-09-12 05:40:09 UTC
Permalink
Hi JSI,
 
I'm thinking you're taking a huge hit in the conversion of the ActiveX SAFEARRAY into a LV array. From past experience (though perhaps its improved by now), the penalty was quite large because memory had to be reallocated and copied each time. At one point I believe I used a C DLL to copy the elements out of a SAFEARRAY in one big chunk and into pre-allocated memory (like a LV array passed in) and got a pretty big improvement in speed (this was in a data acquisition application accessing single-precision floating point arrays retrieved from a COM DLL.
 
Hope this helps,
Eric
Bruce Ammons
2007-09-12 13:10:13 UTC
Permalink
You will probably always have 100% CPU load unless you can process images faster than the camera can acquire them.  The only other way to reduce the CPU load is to put a delay in the loop, but that slows down your processing framerate.  My suggestions were merely an attempt to improve your framerate, not CPU load.
Bruce

Loading...