LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Convert a Bit rgb bitmap to a vision image

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

0 Kudos
Message 1 of 3
(4,013 Views)

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.

 

0 Kudos
Message 2 of 3
(3,958 Views)

Create NI Vision Image - > obtain bitmap pointer -> pass data from camera to bitmap -> release pointer -> manipulate with vision tools.

0 Kudos
Message 3 of 3
(3,813 Views)