Skip to content

Commit 6b17b4f

Browse files
authored
Fix in camera calibration.
1 parent bba66f0 commit 6b17b4f

File tree

1 file changed

+2
-9
lines changed

1 file changed

+2
-9
lines changed

libs/utils/camera_calibration.py

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,9 @@ class Config:
2121
def compute_and_save_inv_homography_matrix(points: ConfigHomographyMatrix, destination: str):
2222
Path(os.path.dirname(destination)).mkdir(parents=True, exist_ok=True)
2323
pts_destination = np.float32(points.pts_destination)
24-
distances_bt_points = []
25-
for i in range(4):
26-
distances_bt_points.append(
27-
distance.euclidean(points.pts_destination[i], points.pts_destination[(i+1)%4])
28-
)
29-
square_size = np.average(distances_bt_points)
30-
pts_sources = np.float32(
31-
[[0, 0], [0, square_size], [square_size , square_size], [square_size, 0]]
24+
h, _ = cv.findHomography(
25+
np.float32([[0, 0], [0, 100], [100 , 100], [100, 0]]), pts_destination
3226
)
33-
h, _ = cv.findHomography(pts_sources, pts_destination)
3427
h_inv = np.linalg.inv(h).flatten()
3528
h_inv = ' '.join(map(str, h_inv))
3629
with open(destination, 'w') as f:

0 commit comments

Comments
 (0)