@@ -61,25 +61,23 @@ if __name__ == "__main__":
6161 if weight > 0 and adj_image in shot_index :
6262 adj_indices .append (shot_index [adj_image ])
6363
64-
6564 num_covisible = len (adj_indices )
6665 fvis .write ("%d " % i )
6766 fvis .write ("%d " % num_covisible )
6867 for ai in adj_indices :
6968 fvis .write ("%d " % ai )
7069 fvis .write ("\n " )
7170
72-
7371 #### write camera projection matrix to txt/%08d.txt
7472 camera = reconstruction ['cameras' ][shot ['camera' ]]
7573
76- focal = camera ["focal" ]
7774 w = camera ["width" ]
7875 h = camera ["height" ]
76+ f = camera ["focal" ] * max (w , h )
7977
8078 # build that projection matrix that PMVS actually accepts!
8179 Rt = Rt_from_shot (shot )
82- K = np .matrix ([[focal * w , 0 , 0.5 * w ], [0 , focal * h , 0.5 * h ], [0 , 0 , 1.0 ]])
80+ K = np .matrix ([[f , 0 , 0.5 * ( w - 1 ) ], [0 , f , 0.5 * ( h - 1 ) ], [0 , 0 , 1.0 ]])
8381 P = K * Rt
8482
8583 new_txt = os .path .join (output_path , "txt" , base + ".txt" )
@@ -90,21 +88,14 @@ if __name__ == "__main__":
9088 f .write ("%f " % c )
9189 f .write ("\n " )
9290
93-
94-
9591 #### radially undistort image and copy to visualize/%08d.jpg
9692 orig_image = os .path .abspath (data .image_files [image ]) #why is dataset.__image_file() method private?
9793 new_image = os .path .join (output_path , "visualize" , base + ".jpg" )
9894
9995 im = cv2 .imread (orig_image )
100- camera_matrix = np .identity (3 )
101- camera_matrix [0 ][0 ] = camera ["width" ]* camera ["focal" ]
102- camera_matrix [1 ][1 ] = camera ["width" ]* camera ["focal" ]
103- camera_matrix [0 ][2 ] = camera ["width" ]/ 2.0
104- camera_matrix [1 ][2 ] = camera ["height" ]/ 2.0
10596 k1 = camera ["k1" ]
10697 k2 = camera ["k2" ]
107- im = cv2 .undistort (im , camera_matrix , np .array ([k1 , k2 , 0 , 0 ]))
98+ im = cv2 .undistort (im , K , np .array ([k1 , k2 , 0 , 0 ]))
10899 cv2 .imwrite (new_image , im )
109100
110101 fvis .close ()
@@ -123,5 +114,3 @@ if __name__ == "__main__":
123114 f .write ("sequence -1\n " )
124115 f .write ("timages -1 0 %d\n " % len (shot_index ))
125116 f .write ("oimages 0\n " );
126-
127-
0 commit comments