|
@@ -684,6 +684,16 @@ class CameraCalibrator:
|
|
|
print(f"有效校准点: {len(valid_points)}")
|
|
print(f"有效校准点: {len(valid_points)}")
|
|
|
print(f"重叠区间数: {len(self.overlap_ranges)}")
|
|
print(f"重叠区间数: {len(self.overlap_ranges)}")
|
|
|
print(f"RMS误差: {rms_error:.4f}°")
|
|
print(f"RMS误差: {rms_error:.4f}°")
|
|
|
|
|
+
|
|
|
|
|
+ # 自动保存校准结果
|
|
|
|
|
+ try:
|
|
|
|
|
+ from config import CALIBRATION_CONFIG
|
|
|
|
|
+ if CALIBRATION_CONFIG.get('auto_save', True):
|
|
|
|
|
+ filepath = CALIBRATION_CONFIG.get('calibration_file', 'calibration.json')
|
|
|
|
|
+ self.save_calibration(filepath)
|
|
|
|
|
+ except Exception:
|
|
|
|
|
+ pass
|
|
|
|
|
+
|
|
|
print(f"{'='*60}")
|
|
print(f"{'='*60}")
|
|
|
else:
|
|
else:
|
|
|
self.state = CalibrationState.FAILED
|
|
self.state = CalibrationState.FAILED
|
|
@@ -765,6 +775,7 @@ class CameraCalibrator:
|
|
|
if inlier_count < 4:
|
|
if inlier_count < 4:
|
|
|
print(f"RANSAC后有效点不足({inlier_count}个),使用全部点")
|
|
print(f"RANSAC后有效点不足({inlier_count}个),使用全部点")
|
|
|
inlier_mask = np.ones(len(points), dtype=bool)
|
|
inlier_mask = np.ones(len(points), dtype=bool)
|
|
|
|
|
+ inlier_count = np.sum(inlier_mask) # 更新inlier_count
|
|
|
else:
|
|
else:
|
|
|
print(f"RANSAC: {len(points)}个点中{inlier_count}个内点,剔除{len(points) - inlier_count}个异常值")
|
|
print(f"RANSAC: {len(points)}个点中{inlier_count}个内点,剔除{len(points) - inlier_count}个异常值")
|
|
|
|
|
|
|
@@ -962,9 +973,19 @@ class CameraCalibrator:
|
|
|
class CalibrationManager:
|
|
class CalibrationManager:
|
|
|
"""校准管理器"""
|
|
"""校准管理器"""
|
|
|
|
|
|
|
|
- def __init__(self, calibrator: CameraCalibrator):
|
|
|
|
|
|
|
+ def __init__(self, calibrator: CameraCalibrator, calibration_file: str = None):
|
|
|
self.calibrator = calibrator
|
|
self.calibrator = calibrator
|
|
|
- self.calibration_file = "calibration.json"
|
|
|
|
|
|
|
+ # 优先使用传入的路径,否则从配置读取,最后使用默认值
|
|
|
|
|
+ if calibration_file:
|
|
|
|
|
+ self.calibration_file = calibration_file
|
|
|
|
|
+ else:
|
|
|
|
|
+ try:
|
|
|
|
|
+ from config import CALIBRATION_CONFIG
|
|
|
|
|
+ self.calibration_file = CALIBRATION_CONFIG.get(
|
|
|
|
|
+ 'calibration_file', 'calibration.json'
|
|
|
|
|
+ )
|
|
|
|
|
+ except ImportError:
|
|
|
|
|
+ self.calibration_file = 'calibration.json'
|
|
|
|
|
|
|
|
def auto_calibrate(self, force: bool = False) -> CalibrationResult:
|
|
def auto_calibrate(self, force: bool = False) -> CalibrationResult:
|
|
|
"""自动校准"""
|
|
"""自动校准"""
|