Mercurial Hosting > traffic-intelligence
comparison python/compute-homography.py @ 231:249d65ff6c35
merged modifications for windows
author | Nicolas Saunier <nicolas.saunier@polymtl.ca> |
---|---|
date | Mon, 02 Jul 2012 23:49:39 -0400 |
parents | ba71924cadf5 |
children | 584613399513 |
comparison
equal
deleted
inserted
replaced
230:bc4ea09b1743 | 231:249d65ff6c35 |
---|---|
8 import cvutils | 8 import cvutils |
9 import utils | 9 import utils |
10 | 10 |
11 options, args = getopt.getopt(sys.argv[1:], 'h',['help','video_frame=']) | 11 options, args = getopt.getopt(sys.argv[1:], 'h',['help','video_frame=']) |
12 options = dict(options) | 12 options = dict(options) |
13 | |
14 # TODO process camera intrinsic and extrinsic parameters to obtain image to world homography, taking example from Work/src/python/generate-homography.py script | |
15 # cameraMat = load(videoFilenamePrefix+'-camera.txt'); | |
16 # T1 = cameraMat[3:6,:].copy(); | |
17 # A = cameraMat[0:3,0:3].copy(); | |
18 | |
19 # # pay attention, rotation may be the transpose | |
20 # # R = T1[:,0:3].T; | |
21 # R = T1[:,0:3]; | |
22 # rT = dot(R, T1[:,3]/1000); | |
23 # T = zeros((3,4),'f'); | |
24 # T[:,0:3] = R[:]; | |
25 # T[:,3] = rT; | |
26 | |
27 # AT = dot(A,T); | |
28 | |
29 # nPoints = 4; | |
30 # worldPoints = cvCreateMat(nPoints, 3, CV_64FC1); | |
31 # imagePoints = cvCreateMat(nPoints, 3, CV_64FC1); | |
32 | |
33 # # extract homography from the camera calibration | |
34 # worldPoints = cvCreateMat(4, 3, CV_64FC1); | |
35 # imagePoints = cvCreateMat(4, 3, CV_64FC1); | |
36 | |
37 # worldPoints[0,:] = [[1, 1, 0]]; | |
38 # worldPoints[1,:] = [[1, 2, 0]]; | |
39 # worldPoints[2,:] = [[2, 1, 0]]; | |
40 # worldPoints[3,:] = [[2, 2, 0]]; | |
41 | |
42 # wPoints = [[1,1,2,2], | |
43 # [1,2,1,2], | |
44 # [0,0,0,0]]; | |
45 # iPoints = utils.worldToImage(AT, wPoints); | |
46 | |
47 # for i in range(nPoints): | |
48 # imagePoints[i,:] = [iPoints[:,i].tolist()]; | |
49 | |
50 # H = cvCreateMat(3, 3, CV_64FC1); | |
51 | |
52 # cvFindHomography(imagePoints, worldPoints, H); | |
53 | |
13 | 54 |
14 if '--help' in options.keys() or '-h' in options.keys(): | 55 if '--help' in options.keys() or '-h' in options.keys(): |
15 print('''The argument should be the name of a file containing at least 4 non-colinear point coordinates: | 56 print('''The argument should be the name of a file containing at least 4 non-colinear point coordinates: |
16 - the first two lines are the x and y coordinates in the projected space (usually world space) | 57 - the first two lines are the x and y coordinates in the projected space (usually world space) |
17 - the last two lines are the x and y coordinates in the origin space (usually image space)''') | 58 - the last two lines are the x and y coordinates in the origin space (usually image space)''') |