OpenCV GPU Accelerated using Python
I am trying to run my python code which is basically related to image processing and finding defects. I want to get this code on GPU (it works perfectly fine using CPU but takes time due to many libraries) and was suggested using opencv gpu accelerated library. I have no clue how to start doing this.. I have tried to do this following example but does not have any change in its time taken to complete the task. import cv2 import time
import cv2
import time
t=time.time()
img="Red.jpg"
img_original=cv2.UMat(cv2.imread(img))
imgUmat=cv2.UMat(img_original)
blur= cv2.pyrMeanShiftFiltering(imgUmat,21,49)
gray_image= cv2.cvtColor(blur,cv2.COLOR_BGR2GRAY)
cv2.imshow('original',gray_image)
print('Done in', (time.time()-t))
cv2.waitKey(0)
cv2.destroyAllWindows()
Output:
Done in 9.723002672195435
It would be great, if anyone can suggest where do i start from and how does this even work??
please use
time.clock()
orcv2.getTickCount()
for measurement.you also should restrict it to the processing, not imread() imshow(), etc.
t=time.process_time() i have updated to this as time.clock() is depricated as per this error ''
DeprecationWarning: time.clock has been deprecated in Python 3.3 and will be removed from Python 3.8: use time.perf_counter or time.process_time instead print('Done in', (time.clock()-t))
''you also should restrict it to the processing, not imread() imshow(), etc
I dont understand what you meant by this
Thanks for responding as well
if you want to find out, how long your processing takes, you need to set the timers more "tightly" around that, don't measure, how long imshow() took, or how long you waited for a keypress, even
ok ok i get it what u say regarding timers