Ask Your Question
1

How do you compute abs() using UMat?

asked 2017-09-25 17:45:24 -0600

epatton gravatar image

updated 2017-09-26 11:23:27 -0600

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

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
2

answered 2017-09-26 12:07:14 -0600

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);
edit flag offensive delete link more

Comments

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

LBerger gravatar imageLBerger ( 2017-09-26 13:54:36 -0600 )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 ( 2017-09-26 16:12:05 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2017-09-25 17:45:24 -0600

Seen: 1,366 times

Last updated: Sep 26 '17