added aruco generate and detect

This commit is contained in:
2025-11-24 14:24:19 +01:00
parent 4ea570e2ab
commit 86f70372ae
6 changed files with 171 additions and 5 deletions
+4 -4
View File
@@ -14,7 +14,7 @@ def draw_gizmo(img, corners, imgpts):
return img
def draw_cube(img, corners, imgpts):
def draw_cube(img, imgpts):
imgpts = np.int32(imgpts).reshape(-1, 2)
# draw ground floor in green
@@ -29,7 +29,7 @@ def draw_cube(img, corners, imgpts):
return img
def init_data():
def factory():
criteria = (cv.TERM_CRITERIA_EPS + cv.TERM_CRITERIA_MAX_ITER, 30, 0.001)
objp = np.zeros((PAT_NX * PAT_NY, 3), np.float32)
objp[:, :2] = np.mgrid[0:PAT_NX, 0:PAT_NY].T.reshape(-1, 2)
@@ -46,7 +46,7 @@ def process_video():
mtx, dist, _, _ = [X[i] for i in ('mtx', 'dist', 'rvecs', 'tvecs')]
# Init
criteria, objp, axis = init_data()
criteria, objp, axis = factory()
# Open camera
video = cv.VideoCapture(0)
@@ -69,7 +69,7 @@ def process_still():
mtx, dist, _, _ = [X[i] for i in ('mtx', 'dist', 'rvecs', 'tvecs')]
# Init
criteria, objp, axis = init_data()
criteria, objp, axis = factory()
for fname in glob.glob('check*.jpg'):
img = cv.imread(fname)