12-19-2010 05:54 PM
Hello,
I got a 24 bit deep bitmap from a camera and want to convert it to an vision image.
Currently, I can display the picture as a bitmap. This works quite fine.
// Grab Image from my USB camera
ST_GrabImage(hDevice, pImage, Buffersize);
// create bitmap
pixelDepth=24; rowBytes = pixelDepth*Width/8;
NewBitmap (rowBytes, pixelDepth, Width, Height, 0, pImage, 0, &bmpID);
// Draw data
SetBitmapData (bmpID, rowBytes, pixelDepth, 0, pImage, 0);
CanvasDrawBitmap (panelHandle, PANEL_CANVAS, bmpID, VAL_ENTIRE_OBJECT, VAL_ENTIRE_OBJECT);
This works quite well, but I want to use the NiVision functions that work on images, like:
// Working with Ni-Vision
image = imaqCreateImage (IMAQ_IMAGE_RGB, 0); // IAMQ_IMAGE_RGB uses 32 bits not 24
success = imaqArrayToImage (image, pImage, 1024, 768); // the conversion does not work
Is there a way to convert a 24bit RGB to a IMAQ_IMAGE_RGB image?
Thanks
TomBom
12-27-2010 08:31 AM
Hello Tombom,
the Conversion will not work because NewBitmap returns a bitmap ID
"Creates a bitmap object and returns a bitmap ID.
You can pass the bitmap ID to any function that accepts a bitmap,
such as CanvasDrawBitmap or ClipboardPutBitmap."
and the Array Parameter of the imaqArraytoImage Function needs to be a Pointer to 2D Array
"The two-dimensional array of pixel values. This parameter is required and cannot be NULL."
There may be a way to create that 2D Array using GetBitmapData and some additional Array Operations.
Since you are using a USB Camera, you might as well use the IMAQ USB Driver to aquire your images.
The IMAQ USB Driver is contained in the Vision Aquisition Software.
This driver will deliver the aquired Images in the Vision Image format, witch makes handling the images much more simple.
Here are some additional links on this Toppic:
What Cameras are Supported by the NI-IMAQ for USB Cameras Driver?
http://digital.ni.com/public.nsf/allkb/89E33B77CFE244E986256F8E004E0F13
NI-IMAQ for USB Cameras User Guide
http://digital.ni.com/manuals.nsf/websearch/AFE01D21DD270C6686256F88005CD4B2
Regards
Moritz M.
02-14-2011 09:34 AM
Create NI Vision Image - > obtain bitmap pointer -> pass data from camera to bitmap -> release pointer -> manipulate with vision tools.