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) dstName = 'Destination (' + filename + ')' cv2.namedWindow(dstName, cv2.WINDOW_AUTOSIZE) cv2.imshow(dstName, dst) ipcv.flush()
if linesRead > 2: data = line.rstrip().split() srcX.append(float(data[0])) srcY.append(float(data[1])) mapX.append(float(data[2])) mapY.append(float(data[3])) f.close() startTime = time.clock() map1, map2 = ipcv.map_gcp(src, map, srcX, srcY, mapX, mapY, order=2) 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 (remap) = {0} [s]'.format(elapsedTime)) srcName = 'Source (' + imgFilename + ')' cv2.namedWindow(srcName, cv2.WINDOW_AUTOSIZE) cv2.imshow(srcName, src) mapName = 'Map (' + mapFilename + ')' cv2.namedWindow(mapName, cv2.WINDOW_AUTOSIZE) cv2.imshow(mapName, map) dstName = 'Warped (' + mapFilename + ')' cv2.namedWindow(dstName, cv2.WINDOW_AUTOSIZE) cv2.imshow(dstName, dst)
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))
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) dstName = 'Destination (' + filename + ')' cv2.namedWindow(dstName, cv2.WINDOW_AUTOSIZE) cv2.imshow(dstName, dst) ipcv.flush()