comparison scripts/rescale-homography.py @ 614:5e09583275a4

Merged Nicolas/trafficintelligence into default
author Mohamed Gomaa <eng.m.gom3a@gmail.com>
date Fri, 05 Dec 2014 12:13:53 -0500
parents 8f8f4375e441
children 56cc8a1f7082
comparison
equal deleted inserted replaced
598:11f96bd08552 614:5e09583275a4
1 #! /usr/bin/env python
2
3 import sys
4
5 import matplotlib.pyplot as plt
6 import numpy as np
7 import cv2
8
9 import cvutils
10 import utils
11
12 if len(sys.argv) < 4:
13 print('Usage: {} homography_filename original_size new_size (size can be width or height)'.format(sys.argv[0]))
14 sys.exit()
15
16 homography = np.loadtxt(sys.argv[1])
17
18 imgPoints = np.array([[10,10],
19 [10,20],
20 [20,20],
21 [20,10]])
22
23 wldPoints = cvutils.projectArray(homography, imgPoints.T).T
24
25 newSize = float(sys.argv[3])
26 originalSize = float(sys.argv[2])
27 imgPoints = imgPoints*newSize/originalSize
28
29 newHomography, mask = cv2.findHomography(imgPoints, wldPoints)
30
31 np.savetxt(sys.argv[1]+'.new', newHomography)
32