def testApplyHomographyPoster(): signH = np.array( [ [1.12265192e00, 1.44940136e-01, 1.70000000e02], [8.65164180e-03, 1.19897030e00, 9.50000000e01], [2.55704864e-04, 8.06420365e-04, 1.00000000e00], ] ) green = io.getImage("green.png") poster = io.getImage("poster.png") a6.applyHomography(poster, green, signH, True) io.imwrite(green, "HWDueAt9pm_applyHomography.png")
def testComputeAndApplyHomographyPoster(): green = io.getImage("green.png") poster = io.getImage("poster.png") h, w = poster.shape[0] - 1, poster.shape[1] - 1 pointListPoster = [np.array([0, 0, 1]), np.array([0, w, 1]), np.array([h, w, 1]), np.array([h, 0, 1])] pointListT = [np.array([170, 95, 1]), np.array([171, 238, 1]), np.array([233, 235, 1]), np.array([239, 94, 1])] listOfPairs = zip(pointListPoster, pointListT) H = a6.computeHomography(listOfPairs) # print H a6.applyHomography(poster, green, H, True) io.imwrite(green, "HWDueAt9pm_computeHomography.png")
def testComputeAndApplyHomographyPrudential(): pru = io.getImage("pruSkyline.png") poster = io.getImage("andrewTag.png") h, w = poster.shape[0]-1, poster.shape[1]-1 pointListPoster=[np.array([0, 0, 1]), np.array([0, w, 1]), np.array([h, w, 1]), np.array([h, 0, 1])] #pointListPru=[np.array([78, 120, 1]), np.array([99, 160, 1]), np.array([150, 159, 1]), np.array([132, 118, 1])] pointListPru=[np.array([78, 120, 1], dtype=np.float64), np.array([99, 160, 1], dtype=np.float64), np.array([207, 156, 1], dtype=np.float64), np.array([194, 115, 1], dtype=np.float64)] listOfPairs=zip(pointListPoster, pointListPru) H = a6.computeHomography(listOfPairs) #print H a6.applyHomography(poster, pru, H, True) io.imwrite(pru, "Fun.png")
def getPNGsInDir(path): fnames = glob.glob(path + "*.png") pngs = list() for f in fnames: imi = io.getImage(f) pngs.append(imi) return pngs