Ask Your Question
0

access rgb from UMat

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

dineshlama gravatar image

How do i access rgb or any color data from UMat? For example before i was accesing the color data like ForegroundImage.at<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

Comments

Color plane order is BGR in opencv

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

1 answer

Sort by ยป oldest newest most voted
0

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

LBerger gravatar image

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

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

example

UMat w;
...
// get access to UMat
{
Mat b= w.getMat(cv::ACCESS_READ);
b.at<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

Comments

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 -0600 )edit

Question Tools

1 follower

Stats

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

Seen: 499 times

Last updated: Jan 09 '20