calibration: caller provides threshold
This commit is contained in:
@@ -42,13 +42,15 @@ class Calibration:
|
|||||||
calib = {'mtx': mtx.tolist(), 'dist': dist.tolist()}
|
calib = {'mtx': mtx.tolist(), 'dist': dist.tolist()}
|
||||||
print(f"Saved {filename} successfully!")
|
print(f"Saved {filename} successfully!")
|
||||||
|
|
||||||
def process(self, image: np.ndarray, r_vecs=None, t_vecs=None, flags=0):
|
def process(self, image: np.ndarray, thresh=3.0, r_vecs=None, t_vecs=None, flags=0):
|
||||||
success = False
|
success = False
|
||||||
if len(self.obj_points_list) > 0 and len(self.img_points_list) > 0:
|
no = len(self.obj_points_list)
|
||||||
|
ni = len(self.img_points_list)
|
||||||
|
if no == ni and no > 0:
|
||||||
ret, mtx, dist, r_vecs, t_vecs = cv.calibrateCamera(self.obj_points_list, self.img_points_list, image.shape, self.mtx, self.dist,
|
ret, mtx, dist, r_vecs, t_vecs = cv.calibrateCamera(self.obj_points_list, self.img_points_list, image.shape, self.mtx, self.dist,
|
||||||
rvecs=r_vecs, tvecs=t_vecs, flags=flags)
|
rvecs=r_vecs, tvecs=t_vecs, flags=flags)
|
||||||
|
|
||||||
if ret < 3:
|
if ret < thresh:
|
||||||
success = True
|
success = True
|
||||||
self.mtx = mtx
|
self.mtx = mtx
|
||||||
self.dist = dist
|
self.dist = dist
|
||||||
|
|||||||
@@ -185,7 +185,7 @@ class Detector(abc.ABC):
|
|||||||
print(f"{det}: Points matching success")
|
print(f"{det}: Points matching success")
|
||||||
elif k == ord('c'):
|
elif k == ord('c'):
|
||||||
gray = cv.cvtColor(img, cv.COLOR_BGR2GRAY)
|
gray = cv.cvtColor(img, cv.COLOR_BGR2GRAY)
|
||||||
if self.calibration.process(gray):
|
if self.calibration.process(gray, thresh=3*len(self.detector)):
|
||||||
print(f"{self.camera_name}: Camera calibration success")
|
print(f"{self.camera_name}: Camera calibration success")
|
||||||
self.calibration.save(f"{RESULTS_FOLDER}/{self.camera_name}_cal.npz")
|
self.calibration.save(f"{RESULTS_FOLDER}/{self.camera_name}_cal.npz")
|
||||||
elif k == ord('x'):
|
elif k == ord('x'):
|
||||||
|
|||||||
Reference in New Issue
Block a user