什么是过滤校准图像的有效方法?

问题描述

我正在执行 this 教程中所示的校准。

我希望我的校准程序决定一个图像是否适合校准,而不是手动可视化来决定,因为有一些图像检测到的棋盘图案是弯曲的,它们可能会对校准。

我有大约 400 张图像,因此无法对每张图像进行可视化和决定。

以下是一个可能的解决方案,但考虑到大量图像,速度确实很慢。

def calculate_error(img_points_p,obj_points_p,rot_vectors_p,tr_vectors_p,mtx_p,dist_p):
    error_data = []
    for i in range(len(obj_points_p)):
        img_points_2,_ = cv.projectPoints(obj_points_p[i],rot_vectors_p[i],tr_vectors_p[i],dist_p)
        error = cv.norm(img_points_p[i],img_points_2,cv.norM_L2) / len(img_points_2)
        error_data.append(error)
    return error_data

# perform calibration
# call calculate_error(...)
# remove from img_points (2d points in image plane) the values which correspond to value greater than 0.1 in error_data
# perform calibration again with data with only lesser values from error_data 

是否有可能更快的替代方案?就像在我们检测到棋盘图案后立即检查图像是否良好,对于所有图像?

解决方法

算法形式:

  • 在每个图像上运行 findChessboardCorners(),拒绝那些没有检测到棋盘的图像。
  • 在幸存者图像上,在检测到的棋盘角上运行 findHomography(),使用 RANSAC 或 LMEDS 估计器,拒绝那些失败或找到少于 N 个内点的图像。为 N 使用一个合理的值,比如 16 或 36(意味着你想“看到”相当于 4x4 或 6x6 的内点。至少。不要对最大可接受的重投影误差太严格,因为你没有纠正镜头失真。