Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

a better way to test things might be:

import cv2
import numpy as np

def test(img, N, S):
    t0 = cv2.getTickCount()
    for i in range(N):
        blur= cv2.pyrMeanShiftFiltering(img,21,49)
        gray_image= cv2.cvtColor(blur,cv2.COLOR_BGR2GRAY)
    t1 = cv2.getTickCount()
    print ("%s:\t%d iterations took %f seconds." % (S, N, (t1-t0)/cv2.getTickFrequency()))


#cv2.ocl.setUseOpenCL(False)
img = cv2.imread("Red.jpg")
print("image size: ", img.shape)
N = 100

test(img, N, "Mat")

uim = cv2.UMat(img)
test(uim, N, "UMat")

in other words:

  • use more than one iteration
  • exclude up/downloading to/from GPU
  • exclude file-io, printing and gui operations
  • use clock-time, not wall-time to measure

a better way to test things might be:

import cv2
import numpy as np

def test(img, N, S):
    t0 = cv2.getTickCount()
    for i in range(N):
        blur= cv2.pyrMeanShiftFiltering(img,21,49)
        gray_image= cv2.cvtColor(blur,cv2.COLOR_BGR2GRAY)
    t1 = cv2.getTickCount()
    print ("%s:\t%d iterations took %f seconds." % (S, N, (t1-t0)/cv2.getTickFrequency()))


#cv2.ocl.setUseOpenCL(False)
img = cv2.imread("Red.jpg")
print("image size: ", img.shape)
 N = 100
 test(img, N, "Mat")

uim = cv2.UMat(img)
test(uim, test(cv2.UMat(img), N, "UMat")

in other words:

  • use more than one iteration
  • exclude up/downloading to/from GPU
  • exclude file-io, printing and gui operations
  • use clock-time, not wall-time to measure