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?
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With