Ask Your Question

access rgb from UMat

asked 2020-01-08 12:36:48 -0500

dineshlama gravatar image

How do i access rgb or any color data from UMat? For example before i was accesing the color data like<cv::vec3b>(y,x) But this same code is not working for UMat. I am trying to use Umat for preformance reason.

edit retag flag offensive close merge delete


Color plane order is BGR in opencv

LBerger gravatar imageLBerger ( 2020-01-09 02:52:30 -0500 )edit

1 answer

Sort by ยป oldest newest most voted

answered 2020-01-08 14:55:58 -0500

LBerger gravatar image

updated 2020-01-09 02:15:11 -0500

You use method getMat with parameter access flag

There is an example in cam_shift.cpp

You cannot access to gpu data. Method getMat make a copy of gpu data to cpu and when it is finished copy cpu data to gpu


UMat w;
// get access to UMat
Mat b= w.getMat(cv::ACCESS_READ);<Vec3b>(Point(10,12)) = Vec3b(17,15,14);
} // b object is copy to gpu and b is destroyed (cpu memory used)
edit flag offensive delete link more


Ok, but how to define the x and y position in this methode and how to read the rgb value of that pixel only? can u show small eg. code or line? cas i didn't understood and see how it is done their.

dineshlama gravatar imagedineshlama ( 2020-01-09 00:10:10 -0500 )edit

Question Tools

1 follower


Asked: 2020-01-08 12:36:48 -0500

Seen: 150 times

Last updated: Jan 09 '20