Machine Vision

cancel
Showing results for 
Search instead for 
Did you mean: 

IMAQ performance: image/memory allocation at every frame?

In my application, I have several functions that need temporary images. Inside the functions, I use imaqCreateImage() to allocate memory for the images.

What I am wondering: is there a performance loss when calling imaqCreateImage() several times each frame?

I thought about allocating memory to all temporary images just once, at startup, and then use the allocated memory over and over again each frame. Then imaqCreateImage() would only be called a few times when the applications starts. The downside is that my code then gets very messy with lots of global variables...

Comments? Thanks!

Torbjørn
0 Kudos
Message 1 of 7
(3,789 Views)
Hello Torbjoen,

I would suggest that you keep the number of buffers to a minimum because imaqCreateImage will allocate new memory space for your image each time you call it. Reusing the same buffer space would be the best practice because you won't have to waste resources creating new buffers and destroying them.

BB_Phil
0 Kudos
Message 2 of 7
(3,788 Views)
Thanks, BB,

I guess I thought that was the way of doing things, it's just that the source code gets a bit less tidy when using "global" buffers.
0 Kudos
Message 3 of 7
(3,788 Views)
Hi!

I have some questions and remarks.

1. Which version was used? I've got a lot of troubles with IMAQ Create with Vision 7.0. Before it was OK.

2. You can organize array for temporary images, which must be initialized only once at startup.

3. In LabVIEW we have function "IMAQ Create&Lock Space". Below you can find desription, may be it help:

IMAQ Create&Lock Space: Creates a new image that has a permanently-allocated maximum memory space. Using this VI, the pixel memory space allocated to an image can increase but never decreases. This mechanism guarantees that an image that has filled a certain amount of memory always is able to occupy the same space, whatever the memory fragmentation may be.

Note: The IMAQ Create VI is recommend
ed over the IMAQ Create&LockSpace VI for most applications. The IMAQ Create&LockSpace VI must be used only in applications in which the memory requirements are stringent. The IMAQ Create&LockSpace VI must be used in conjunction with the IMAQ Dispose VI to avoid saturating the memory reserved for LabVIEW or BridgeVIEW.
The IMAQ Create&LockSpace VI is hidden in the Image palette but can be found in Manage.llb.
---
0 Kudos
Message 4 of 7
(3,788 Views)
Thanks for your comments, Andrey.

I am using 6.1 with LabWindows.

During initialization I am now malloc'ing for all my images. The downside is that it gets a little messy. I would like to have as few global variables as possible. But it works ok.

Torbjørn 🙂
0 Kudos
Message 5 of 7
(3,788 Views)
I can't seem to find the Manage.llb. Where can this be located?

"Andrey Dmitriev" wrote in message
news:5065000000050000000E260100-1042324653000@exchange.ni.com...
> Hi!
>
> I have some questions and remarks.
>
> 1. Which version was used? I've got a lot of troubles with IMAQ Create
> with Vision 7.0. Before it was OK.
>
> 2. You can organize array for temporary images, which must be
> initialized only once at startup.
>
> 3. In LabVIEW we have function "IMAQ Create&Lock Space". Below you can
> find desription, may be it help:
>
> IMAQ Create&Lock Space: Creates a new image that has a
> permanently-allocated maximum memory space. Using this VI, the pixel
> memory space allocated to an image can increase but never decreases.
> This mechanism
guarantees that an image that has filled a certain
> amount of memory always is able to occupy the same space, whatever the
> memory fragmentation may be.
>
> Note: The IMAQ Create VI is recommended over the IMAQ
> Create&LockSpace VI for most applications. The IMAQ Create&LockSpace
> VI must be used only in applications in which the memory requirements
> are stringent. The IMAQ Create&LockSpace VI must be used in
> conjunction with the IMAQ Dispose VI to avoid saturating the memory
> reserved for LabVIEW or BridgeVIEW.
> The IMAQ Create&LockSpace VI is hidden in the Image palette
> but can be found in Manage.llb.
> ---
0 Kudos
Message 6 of 7
(3,788 Views)
Hi!
>"I can't seem to find the Manage.llb. Where can this be located?

The IMAQ Create&LockSpace VI can be found now in Compatibility.llb. (in \LabVIEW 7.0\vi.lib\vision )
0 Kudos
Message 7 of 7
(3,788 Views)