if __name__ == '__main__': import cv2 import ipcv import os.path import time home = os.path.expanduser('~') filename = home + os.path.sep + 'src/python/examples/data/crowd.jpg' filename = home + os.path.sep + 'src/python/examples/data/lenna.tif' #filename = home + os.path.sep + 'src/python/examples/data/redhat.ppm' #filename = home + os.path.sep + 'src/python/examples/data/lenna_color.tif' src = cv2.imread(filename) map1, map2 = ipcv.map_rotation_scale(src, rotation=30, scale=[1.3, 0.8]) startTime = time.clock() dst = ipcv.remap(src, map1, map2, interpolation=ipcv.INTER_NEAREST, borderMode=ipcv.BORDER_CONSTANT, borderValue=0) elapsedTime = time.clock() - startTime print('Elapsed time (remap) = {0} [s]'.format(elapsedTime)) srcName = 'Source (' + filename + ')' cv2.namedWindow(srcName, cv2.WINDOW_AUTOSIZE) cv2.imshow(srcName, src)
if __name__ == '__main__': import os.path import time import cv2 import ipcv import numpy home = os.path.expanduser('~') filename = home + os.path.sep + 'src/python/examples/data/sparse_checkerboard.tif' src = cv2.imread(filename, cv2.IMREAD_UNCHANGED) maps = ipcv.map_rotation_scale(src, 0, [0.5, 0.5]) src = ipcv.remap(src, maps[0], maps[1]) M = (2**8) N = (2**8) f = numpy.ones((M, N), dtype=numpy.complex128) f = src.astype(numpy.complex128) if f.shape[2] == 1: f = numpy.reshape(f, (f.shape[0], f.shape[1])) #reals = f.real #imag = f.imag repeats = 2 print('Repetitions = {0}'.format(repeats)) startTime = time.clock() for repeat in range(repeats): F = ipcv.dft2(f, method='break', verbose=True) string = 'Average time per transform = {0:.8f} [s] ' string += '({1}x{2}-point DFT2)' print(string.format((time.clock() - startTime) / repeats, M, N))
PYTHON TEST HARNESS """ if __name__ == '__main__': import cv2 import ipcv import os.path import time home = os.path.expanduser('~') filename = home + os.path.sep + 'src/python/examples/data/crowd.jpg' filename = home + os.path.sep + 'src/python/examples/data/lenna.tif' src = cv2.imread(filename) startTime = time.clock() map1, map2 = ipcv.map_rotation_scale(src, rotation=30, scale=[1.3, 0.8]) #map1, map2 = ipcv.map_rotation_scale(src, rotation=0, scale=[2.0, 2.0]) elapsedTime = time.clock() - startTime print('Elapsed time (map creation) = {0} [s]'.format(elapsedTime)) startTime = time.clock() dst = cv2.remap(src, map1, map2, cv2.INTER_NEAREST) # dst = ipcv.remap(src, map1, map2, ipcv.INTER_NEAREST) elapsedTime = time.clock() - startTime print('Elapsed time (remapping) = {0} [s]'.format(elapsedTime)) srcName = 'Source (' + filename + ')' cv2.namedWindow(srcName, cv2.WINDOW_AUTOSIZE) cv2.imshow(srcName, src) dstName = 'Destination (' + filename + ')'
if __name__ == '__main__': import numpy import cv2 import ipcv import os.path import time home = os.path.expanduser('~') #filename = home + os.path.sep + 'src/python/examples/data/crowd.jpg' filename = home + os.path.sep + 'src/python/examples/data/lenna.tif' #filename = home + os.path.sep + 'src/python/examples/data/photo1.png' #filename = home + os.path.sep + 'src/python/examples/data/jernigan_joseph_paul.jpg' src = cv2.imread(filename) startTime = time.clock() map1, map2 = ipcv.map_rotation_scale(src, rotation=45, scale=[2, 2]) elapsedTime = time.clock() - startTime print('Elapsed time (RST) = {0} [s]'.format(elapsedTime)) startTime = time.clock() dst = ipcv.remap(src, map1, map2, cv2.INTER_NEAREST, borderMode=ipcv.BORDER_REPLICATE) elapsedTime = time.clock() - startTime print('Elapsed time (remap) = {0} [s]'.format(elapsedTime)) srcName = 'Source (' + filename + ')' cv2.namedWindow(srcName, cv2.WINDOW_AUTOSIZE) cv2.imshow(srcName, src)
if __name__ == '__main__': import os.path import time import cv2 import ipcv import numpy home = os.path.expanduser('~') filename = home + os.path.sep + 'src/python/examples/data/checkerboard.tif' filename = home + os.path.sep + 'src/python/examples/data/gecko.jpg' filename = home + os.path.sep + \ 'src/python/examples/data/sparse_checkerboard.tif' src = cv2.imread(filename, cv2.IMREAD_UNCHANGED) src = ipcv.map_rotation_scale() sigma = 1 k = 0.01 startTime = time.time() dst = ipcv.harris(src, sigma, k) print('Elapsed time = {0} [s]'.format(time.time() - startTime)) cv2.namedWindow(filename, cv2.WINDOW_AUTOSIZE) cv2.imshow(filename, src) if len(src.shape) == 2: annotatedImage = cv2.merge((src, src, src)) else: annotatedImage = src fractionMaxResponse = 0.25