3

I'm currently transferring a program in OpenCV 2.4.9 over to OpenCV 3.1.0, however I've been having trouble changing from Mats to UMats. I use Mats to store pictures that I need to access single binary pixel values from. In 2.4.9 I did it like so:

Mat test_mat;
test_mat.at<uchar>(row,column);

Unfortunately, I haven't been able to find a way to do the same sort of thing with the UMats OpenCV 3.1.0 provides through my research. Does anyone have any ideas? Apologies if this is a really trivial thing.

Nacho
  • 1,104
  • 1
  • 13
  • 30
The_Walker
  • 31
  • 1
  • 2
  • If anyone is wondering why I'm doing this, I need the processing speed-boost that 3.1.0 provides over 2.4.9 – The_Walker Mar 03 '16 at 01:13
  • If my answer worked for you, [mark it as accepted](http://meta.stackexchange.com/questions/5234/how-does-accepting-an-answer-work). If it didn't, add a comment asking for clarification or corrections if needed (I guess you can only comment on your own question as per your current reputation, but no worries I will read it). – Nacho Apr 18 '16 at 20:02

1 Answers1

4

Try the following:

UMat test_umat;
test_umat.getMat(ACCESS_READ).at<uchar>(row, column);

Different access flags are:

  • ACCESS_READ
  • ACCESS_WRITE
  • ACCESS_RW
  • ACCESS_FAST
Nacho
  • 1,104
  • 1
  • 13
  • 30
  • 3
    This command casts to cv::Mat() which loses the performance of UMat. So the question should be, is there a similar function .at() on UMat class? It will be very helpful for me. – uelordi Feb 16 '17 at 13:28
  • you are right, opencv Internally uses .getMat(Access) to access to especific elements from the functions. – uelordi Feb 16 '17 at 14:12