LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

read image from a memory pointer imaq

Hello everyboy,

I am using LV 2011. I have an ActiveX control for managing an USB camera (IDS-uEye). With the ActiveX controls I can get the location in memory of the images (with an order that gives me a pointer) and also the size. Now what I need is to procces the images, I have thought in using the Imaq controls, but I don´t know how to start from a pointer to a memory location.

Could somebody help me with this (starting imaq proccessing from a memory pointer) I would be very thanked if sombody gives me a sample VI or any help.

Thank you very much.

Best Regards

0 Kudos
Message 1 of 11
(5,134 Views)

If you are trying to get a pointer to the memory location of an Imaq image use IMAQ GetImagePixelPointer.

Be apare that an Imaq image is not a simple flat array of pixels and does contain border and memory alignment "pixels" so getting a pointer to the 1st pixel can be different than on some other image packages.

 

Paul Falkenstein
Coleman Technologies Inc.
CLA, CPI, AIA-Vision
Labview 4.0- 2013, RT, Vision, FPGA
0 Kudos
Message 2 of 11
(5,105 Views)

You can use LabVIEW's MoveBlock function to copy data from a pointer into a LabVIEW array. From there, you should be able to process it as LabVIEW data. I'm not that familiar with IMAQ but I'm sure there's a function to convert an array into an IMAQ image. Search this forum for help on MoveBlock.

0 Kudos
Message 3 of 11
(5,096 Views)

Hello,

first of all, thank you for your responses. But for the first, I don´t have an imaq image, is an image that  comes from an activex controller for a camera, so that the thing I have is the pointer to the image in memory and the size of the image. What I need is to be able to pick up it from memory and proccess it with imaq. 

Nathand, I am not able to find the Labview MoveBlock function in my Labview.

Thank for your responses and I hope next ones.

Best regards.

0 Kudos
Message 4 of 11
(5,069 Views)

Hello again,

I have found a way to peek the image from memory by using the IMAQ MemPeek control, that gaves me a string that represents the image.

Now I am trying to convert that string into an image with the unflatten from string control, but I don´t succed on it. I get the following: 

Error 116. 

Possible reason(s):

LabVIEW: Unflatten or byte stream read operation failed due to corrupt, unexpected, or truncated data.

I adjunt a picture of my VI in order to make you eassier to help me.

Thank you in advance for help.

Regards.

0 Kudos
Message 5 of 11
(5,047 Views)

You can't just typecast a random image pointer into an IMAQ picture. The IMAQ picture has a very specific (and private) memory structure that is quite unlikely to be returned by your Camera ActiveX control. You will have to read in the manual about how the memory in that pointer is supposed to be structured and read the information yourself. Typically there is most likely some form of header such as a BITMAPINFOHEADER structure at the begin that describes the format of the actual bitmal data that follows. Depending on the information in that header you will have to decode the memory area into a 2D array containing the rows and columns of the bitmap data and then convert that data into an IMAQ image that you have prepared properly by setting its bitmap format (8B grayscale, RGB, etc) and width and height.

Every image acquisition interface comes with its own idea about bitmap formats so there is no easy way of interfacing one to the other and you have to do it the hard way yourself.

Rolf Kalbermatter
My Blog
0 Kudos
Message 6 of 11
(5,040 Views)

Hello,

Thank you for your response rolf, you are right. By the moment I have solved it by saving the image (with an ActiveX option for my camera) into a bmp on disk and after taking that image from disk with imaq utilities, but as is known that is a bad way to proceed because of the waste of recourses for the memory transactions. So I would like to convert it from an array of RGB values that I can get into an image. I mean, if my image is in 1200x1600 resolution, I can get a vector (1D) from the memory that represents the value (0 to 255) of each pixel (1920000 values in this case). What I want is to pass from it to an imaq image, how could I do that?.

Thank you in advance for your help.

Regards.

0 Kudos
Message 7 of 11
(5,015 Views)

@JMSH wrote:

Hello,

Thank you for your response rolf, you are right. By the moment I have solved it by saving the image (with an ActiveX option for my camera) into a bmp on disk and after taking that image from disk with imaq utilities, but as is known that is a bad way to proceed because of the waste of recourses for the memory transactions. So I would like to convert it from an array of RGB values that I can get into an image. I mean, if my image is in 1200x1600 resolution, I can get a vector (1D) from the memory that represents the value (0 to 255) of each pixel (1920000 values in this case). What I want is to pass from it to an imaq image, how could I do that?.

Thank you in advance for your help.

Regards.


Your calculation goes wrong there already!

An RGB image has at least 3 components per pixel. So your 1920000 suddenly gets at least 5760000 bytes. I say at least since there are other factors that can influence the size. So could an RGB pixel be also RGBA with an alpha channel that may be used or not. And you have also BGR, BGRA and just about every other permutation of this as possibility. And then you have the possibility of padding where each row is padded to a 16 bit or 32 bit address. Last but not least can the RGB information be stored in seperate planes of 1 byte per pixel or in consecutive RGB values per pixel.

 

Lots of variables that all need to be known exactly to make sure you are accessing the memory data correctly and turn it into a good picture. And unless you really want to dive into bit manipulation to your nose, you won't get around copying the data from the memory pointer into an intermediate LabVIEW data array and then pass this to the IMAQ ArrayToImage VI.

 

If you haven't dealt with bitmap data before on a byte level, your solution of saving it as BMP and reading it back is maybe not the quickest in terms of performance but most likely the only one that will ever reliably work.

Rolf Kalbermatter
My Blog
0 Kudos
Message 8 of 11
(5,009 Views)

Thank you for your response rolf.

You are right again, I have not worked with image treatment before and I am learning :D. 

But, despite I understand your reasoning about the amount of bytes I should have (3 bytes per pixel), what I obtain is a vector with (for 1200x1600 resolution) 1920000 values that range in [0,255].

I can get the colorMode, and in the case I am testing is on RGB32, I don´t know if it deferes in the memory storation of that values... I would like to be able to do it without passing by the saveImage option, because for this application could be enough, but in the future probably we will need something on the closer Real Time we could.

Thank you very much for your help and forgive my neeby knowledges on image proccessing.

Regards.

0 Kudos
Message 9 of 11
(4,994 Views)

Sorry again, you are right of course xD, I did correctly the count, I can get 7680000 bytes in range [0,255], so it is 1200x1600x4. Format is RGB32. 

What I need is to know how to pass from it to the controlable image. But as you said, I don´t know how it is stored on memory, so I don´t know the order in with I get the vector. But what should I have to do to passing it to image now?

Thank you again,

Best regards.

0 Kudos
Message 10 of 11
(4,986 Views)