Ask Your Question
1

How do you compute abs() using UMat?

asked Sep 25 '17

epatton gravatar image

updated Sep 26 '17

Hi My input is UMat 32FC1 and I'd like to compute abs() but I get a compile error "no matching function for call to 'abs'". my code works find for Mat, but I'd like to use the GPUs. I also tried convertScaleAbs() but it outputs an 8 bit value whereas I want to stay with 32FC1. Any ideas on what's the most efficient way to do this other than writing my own ocl kernel? Many Thanks

Preview: (hide)

1 answer

Sort by » oldest newest most voted
2

answered Sep 26 '17

matman gravatar image

Mmh, cv::abs doesn't seem to exist anymore. Even in docs the link is dead. As a workaround you could try:

cv::absdiff(src, cv::Scalar::all(0), dst);
Preview: (hide)

Comments

@matman I think it is abs and it is not UMat compatible

LBerger gravatar imageLBerger (Sep 26 '17)edit

Thanks, it works. Odd thing is that absdiff is marginally faster than copying the UMat to mat and then using abs(). Odd in that doing so doesn't use the GPU yet it runs almost as fast.

aUmat.copyTo(aMat); bMat = cv::abs(aMat); bMat.copyTo(bUMat);

epatton gravatar imageepatton (Sep 26 '17)edit

Question Tools

1 follower

Stats

Asked: Sep 25 '17

Seen: 1,633 times

Last updated: Sep 26 '17