Ask Your Question
0

Sharpness opencv cuda python

asked 2020-02-28 03:16:38 -0600

Imran B gravatar image

Hi all, I have tried adjusting sharpness with bilateral filter and addweighted methods. But it's not adjusting properly

import cv2
import numpy as np

img =  cv2.imread('test.png')
imgMat = cv2.cuda_GpuMat(img)

blur = cv2.cuda.bilateralFilter(imgMat,90,30,30)
sharp = cv2.cuda.addWeighted(imgMat, 0.3, blur,.5, 100)

sharpened = sharp.download()
cv2.imshow('Frame 1',img)
cv2.imshow('Frame 2',sharpened)
cv2.waitKey(0)
cv2.destroyAllWindows()

I'm using cuda so I can't use detailenhance method as well as gaussian blur also not working as expected.

Thanks in advance !!

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
1

answered 2020-02-28 04:30:30 -0600

As I have said in previous answers to your questions, virtually all functions in the cv.cuda namespace take GpuMat not numpy arrays as input.

I assume you are seeing the following error from

error: OpenCV(4.2.0-dev) modules\core\src\matrix_wrap.cpp:359: error: (-213:The function/feature is not implemented) getGpuMat is available only for cuda::GpuMat and cuda::HostMem in function 'cv::debug_build_guard::_InputArray::getGpuMat'

from

blur = cv2.cuda.bilateralFilter(imgMat,90,30,30)

which implies what I have said above. If so this can be simply fixed by passing a GpuMat

blur = cv2.cuda.bilateralFilter(cv.cuda_GpuMat(imgMat),90,30,30)

Can you please post all errors you get when asking a question and not say "not working as expected".

Additionally please try a few things yourself before asking questions.

edit flag offensive delete link more

Comments

Thanks cudawarped . but imgMat is already GpuMat

img =  cv2.imread('test.png')
imgMat = cv2.cuda_GpuMat(img)

after converting only I'm giving imgMat as input and I tried on my end but it didn't worked good after that only I posted question. And I'm not getting any error's problem is it's not sharpening like expected and slow's down the process.

Imran B gravatar imageImran B ( 2020-03-02 01:28:39 -0600 )edit

Can you post code/pictures/values of "like expected", e.g.

cuBlur = cv.cuda.bilateralFilter(imgMat,90,30,30)
blur = cv.bilateralFilter(img,90,30,30)
absDiff = cv.absdiff(cuBlur.download(),blur)
absDiff.min(),absDiff.max(),absDiff.sum(),absDiff.mean()
plt.imshow(absDiff)
cudawarped gravatar imagecudawarped ( 2020-03-03 05:19:54 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2020-02-28 03:16:38 -0600

Seen: 2,497 times

Last updated: Feb 28 '20