aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorThéo de la Hogue2023-04-25 19:51:04 +0200
committerThéo de la Hogue2023-04-25 19:51:04 +0200
commit287fc032678fe61ad2d9318be0bc6eabfb5129b5 (patch)
treeb0fe095e022120e5a39d971ced6ad142f9d2a557 /src
parent441c250d5a0901cea0ecf580bba8f6434a2e401b (diff)
downloadargaze-287fc032678fe61ad2d9318be0bc6eabfb5129b5.zip
argaze-287fc032678fe61ad2d9318be0bc6eabfb5129b5.tar.gz
argaze-287fc032678fe61ad2d9318be0bc6eabfb5129b5.tar.bz2
argaze-287fc032678fe61ad2d9318be0bc6eabfb5129b5.tar.xz
Adding a method to show K and D camera parameters.
Diffstat (limited to 'src')
-rw-r--r--src/argaze/ArUcoMarkers/ArUcoCamera.py22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/argaze/ArUcoMarkers/ArUcoCamera.py b/src/argaze/ArUcoMarkers/ArUcoCamera.py
index 97436e9..c3c03bd 100644
--- a/src/argaze/ArUcoMarkers/ArUcoCamera.py
+++ b/src/argaze/ArUcoMarkers/ArUcoCamera.py
@@ -6,6 +6,7 @@ from argaze import DataStructures
import json
import numpy
+import cv2
import cv2.aruco as aruco
K0 = numpy.array([[1., 0., 0.], [0., 1., 0.], [0., 0., 0.]])
@@ -55,6 +56,27 @@ class CalibrationData():
return output
+ def draw(self, frame, width:float, height:float, z:float, color=(0, 0, 255)):
+ """Draw grid to display K and D"""
+
+ # Edit 3D grid
+ grid_3D = []
+ for x in range(-int(width/2), int(width/2)):
+ for y in range(-int(height/2), int(height/2)):
+ grid_3D.append([x, y, z])
+
+ # Project 3d grid
+ grid_2D, _ = cv2.projectPoints(numpy.array(grid_3D).astype(float), numpy.array([0., 0., 0.]), numpy.array([0., 0., 0.]), numpy.array(self.K), -numpy.array(self.D))
+
+ # Draw projection
+ for point in grid_2D:
+
+ # Ignore point out out field
+ try:
+ cv2.circle(frame, point.astype(int)[0], 1, color, -1)
+ except:
+ pass
+
class ArUcoCamera(CalibrationData):
"""Handle camera calibration process."""