The_Walker
The_Walker

Reputation: 31

OpenCV 3.1.0: Accessing single elements from a UMat

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.

Upvotes: 3

Views: 3951

Answers (1)

Nacho
Nacho

Reputation: 1124

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

Upvotes: 4

Related Questions