Jump to content

Direct access to camera memory

Recommended Posts

Hi everyone,

Is it possible to read the memory contents directly from the camera's memory?  In other words, If the Invoke Node can provide the pointer to the active memory, can we access the memory location directly from the camera instead of using the CopyToArray function?

The reason for asking is because a client needs to read the image faster than 4ms/MB that it takes the function to read the image data and write it to an array.  Below is an image of what is implemented and what is desired. 

The first image is what is desired. 



The 2nd image is what is currently implemented. (I did not have the Vision toolkit installed on this PC).


Edited by RayR
Link to comment

[collided in air with infinitenothing]

single port GigE is ~120MBytes/sec. you're not talking of bits/sec? Or of a dual GigE (I ran into one once)?

GigE (at least Genicam compliant) is supported by IMAQdx. Normally I just use high level IMAQdx blocks (e.g. GetImage2) and get good throughput, whatever is under the hood. But a camera driver might be in the way for a less efficient than ideal transfer.

Link to comment

Have you checked what methods and properties are available for the .NET class that's returned by GetActive? Are you sure that the ToInt64 method returns a memory address? How did you configure the MoveBlock call? Make sure that you configured the src parameter as a pointer-sized integer passed by value. If ToInt64 does what you indicate it should do, then the value on the wire is the memory address and should be passed directly (by value); if you instead pass a pointer to that pointer, you'll get garbage.

Link to comment

Depending on what you're wanting to do with the image in imaq, it could be easier to compile a little c# or vb module using opencv/http://www.emgu.com/wiki/index.php/Main_Page

Its also not crazy difficult to make a 10 line class which take the ptr reference in c# and calls the imaq dll directly or calls the tdms api directly (http://digital.ni.com/public.nsf/allkb/A3663DE39D6A2C5A86257204005C11CA) or if you have measurement studio (http://www.ni.com/white-paper/8032/en/)

Getting one managed to allow a language without pointers to directly manipulate its memory in order to generate a image structure in a c++ dll seems more challenging than its worth :)

Edited by smithd
Link to comment

Without documentation of the .Net interface for this component, there is no way to say if that would work. This refnum that is returned could be just a .Net object wrapping an IntPtr memory pointer as you hope, but it could be also a real object that is not just a memory pointer. Without seeing the actual underlaying object class name it's impossible to say anything about it.

It is to me not clear if that Memory object is just the description of the image buffer in the camera with methods to transfer the data to the computer or if it is only managing the memory buffer on the local computer AFTER the driver has moved everything over the wire.

If it is the first, your IntPtr conversion has absolutely no chance to work, since the "address" that refnum contains is not a locally mapped virtual memory address on your computer but rather a description of the remote buffer in the camera, and the CopyToArray method does a lot more than just shuffling data between two memory locations on your local computer. If it is indeed just a local memory pointer as you hope, I would not even try to copy anything into an intermediate array buffer but rather use the Advanced IMAQ function "IMAQ Map Memory Pointer.vi" to retrieve the internal memory buffer of the IMAQ image and then copy the data directly in there. However you can usually not do that with a single memcpy() call for the entire image since IMAQ images have extra border pixels which make the memory layout have several more bytes per image line than your source image would contain.

So without a possibility to see the documentation for your .Net component we really can't say anything more about this.


Edited by rolfk
Link to comment
  • 6 months later...

access to camera in labview is based on xml file that any camera create to use as interface and this connection will be happen with imaq 
if you do not want use imaq you have to use active x your write your own method but at the end the thing that you done is re- writing code as imaq code and nothing change in speed so it is not so rational 

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...

Important Information

By using this site, you agree to our Terms of Use.