0

I am currently using the function "getdata" from the imaqtool library to get my camera data, and make some postprocessing on my GPU.

Hence, I would like to get the data directly transfer from the buffer CPU memory to my GPU memory.

It is my understanding that "getdata" move data from CPU memory (buffer) to CPU memory. Hence, it should be trivial to transfer these data to my GPU directly.

However, I cannot find anything about it.

Any help is appreciated.

Tual
  • 3
  • 4
  • 1
    "Hence, it should be trivial...." Hold your horses my friend. GPU RAM is a separate piece of hardware on your computer that your camera has no access to. You dont have your GPU plugged to the camera, and in any way, thats not how it works. Unless you write CUDA code (and possibly even if you do so) you need to go trough CPU memory to get to GPU memory. – Ander Biguri Jun 04 '19 at 15:40
  • Thanks for your answer Ander Biguri. Ok, I understand that the camera has no access to the GPU. However, if the data are "logging" in the CPU memory (buffer) when the camera acquisition start (after trigger), and, are staying "there" until "getdata" is used, then the data (after acquisition) are actually being transferred from CPU memory to CPU memory. Once the acquisition data are filling the allocated memory, there should be a way to transfer the data directly to the GPU. – Tual Jun 05 '19 at 16:54
  • Right now it is doing: Camera->CPU memory allocated (buffer) by using "trigger"->CPU memory emptied to CPU memory by using "getdata". It should be possible to do: Camera->CPU memory allocated (buffer) by using "trigger"->CPU memory emptied to GPU memory by using "getdata". – Tual Jun 05 '19 at 16:55
  • You'll need to write your own real time adquisition application for that, in CUDA – Ander Biguri Jun 05 '19 at 16:57
  • Thank you for your answer Ander Biguri. – Tual Jun 05 '19 at 17:02
  • Ander Biguri, I will accept your second comment as the answer. – Tual Jun 06 '19 at 09:09

1 Answers1

0

In short: MATLAB is not the right tool for your desires. MATLAB provides quite an easy interface, but that means you dont have full control on some things, and the main one is memory allocation and management. This is generally a good thing, as it is non-trivial to handle memory, but in your case, this is what you are asking for.

If you want to make a fast acquisition system where the memory is fully controlled by you, you will need to use low level languages such as C++/CUDA, and play with asynchronous operations and threads.

In MATLAB, the most flexibility you can get is using gpuArray(captured_data) once is on CPU.

Ander Biguri
  • 35,140
  • 11
  • 74
  • 120