Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

OpenCV 3 OpenCL UMat drawing functions

I'm upgrading to OpenCV 3 and using the UMat T_API OpenCL container instead of Mat.

It appears that drawing functions like rectangle(Mat img, ...) don't have a UMat overload. I would like to work in the UMat world as much as possible for drawing on frames without having to convert UMat back to Mat for drawing and displaying.

Can anyone give me the most efficient way to draw a rectangle on a UMat? Or do I have to convert back to Mat to draw on and display?

like image 271
C Johnston Avatar asked Dec 12 '25 20:12

C Johnston


1 Answers

Unfortunately, there is no way to draw something on UMat without transferring data from GPU memory. You may use following scheme to do drawings:

cv::Mat draw_img = img.getMat(cv::ACCESS_WRITE);
cv::rectangle(draw_img, ...);
draw_img.release();

Please note that getMat(cv::ACCESS_WRITE) requires synchronization. So in order to get maximum benefits of GPU processing, it will be better to avoid drawing operations or group it into one block.

like image 173
akarsakov Avatar answered Dec 15 '25 08:12

akarsakov



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!