Ask Your Question
0

OpenCV with cuda

asked 2020-03-11 05:33:08 -0500

NL37 gravatar image

updated 2020-03-11 06:08:20 -0500

berak gravatar image

Hello, I am working on the TX2.

Actually, I have 5 images (6004*7920). Need to sum each pixel of the five images, in one, to calculate the average. For the first step, I use the function accumulate, i.e :

cv::Mat Image_Process = cv::Mat::zeros(height, width, CV_32FC1);
...
cv::accumulate(img1, Image_Process) ;
cv::accumulate(img2, Image_Process) ;
cv::accumulate(img3, Image_Process) ;
cv::accumulate(img4, Image_Process) ;
cv::accumulate(img5, Image_Process) ;
Image_Process = Image_Process/5 ;

That method is not very efficient ... Each accumulate function takes 50ms. Moreother, could explain why accumulate work only with CV_32FC1 ? (imgX are CV_8UC1)

To accelerate the process, I would like to send those images to the GPU, which will be faster. How can I send those images to GPU ? Furthermore, openCV can work with CUDA. Does accumulate function exist in CUDA ?

Thank you

edit retag flag offensive close merge delete

1 answer

Sort by » oldest newest most voted
0

answered 2020-03-11 08:04:17 -0500

According to the documentation, the function does support multi-channel images hence not just CV_32FC1 as you stated.

Looking into their documentation, it does not seem like they have a GPU version of this method yet. My advise:

  1. Read their code (or actual paper) to understand what is happening then maybe leverage the GPU for some of the operations
  2. Research online for an optimised version (or GPU-accelerated one)
  3. If your task allows, consider resizing your images
  4. If all fails, consider looking into multi-threading
edit flag offensive delete link more

Comments

Hello eshirima,

Many thanks for your help. I will try to change the code directly.

I can´t resize the images, and I keep multi-thread for other tasks.

Regards

NL37 gravatar imageNL37 ( 2020-03-11 09:19:39 -0500 )edit
Login/Signup to Answer

Question Tools

1 follower

Stats

Asked: 2020-03-11 05:33:08 -0500

Seen: 70 times

Last updated: Mar 11