reg_shift.py 405 Bytes
Newer Older
1 2
#!/usr/bin/python

3
import cv2 as cv
4 5 6
import numpy as np
import sys

7
img1 = cv.imread(sys.argv[1])
8 9
img1 = img1.astype(np.float32)
shift = np.array([5., 5.])
10
mapTest = cv.reg.MapShift(shift)
11 12 13

img2 = mapTest.warp(img1)

14 15
mapper = cv.reg.MapperGradShift()
mappPyr = cv.reg.MapperPyramid(mapper)
16 17

resMap = mappPyr.calculate(img1, img2)
18
mapShift = cv.reg.MapTypeCaster_toShift(resMap)
19 20

print(mapShift.getShift())