OpenCV 校准相机的图像/对象点格式化

问题描述 投票:0回答:0

像点和物点应该如何格式化?我在

calibrateCamera()
电话中不断收到此错误。
(-210:Unsupported format or combination of formats) objectPoints should contain vector of vectors of points of type Point3f in function 'cv::collectCalibrationData'

我使用了与这里使用的阵列相同的形状

我看到了这篇文章,但没有帮助。

等等等等我的帖子主要是代码

import cv2
import numpy as np

NUM_VIEWS = 2
NUM_PATTERN_POINTS = 9

pattern_points = np.array([[0.0, 0.0, 0.0],
[1.0, 0.0, 0.0],
[2.0, 0.0, 0.0],
[0.0, 1.0, 0.0],
[1.0, 1.0, 0.0],
[2.0, 1.0, 0.0],
[0.0, 2.0, 0.0],
[1.0, 2.0, 0.0],
[2.0, 2.0, 0.0]])

obj_points = np.zeros((NUM_VIEWS, 1, NUM_PATTERN_POINTS, 3))
for i in range(NUM_VIEWS):
    obj_points[i][0] = pattern_points

#img_points = np.zeros((NUM_VIEWS, NUM_PATTERN_POINTS, 1, 2))

img_points = np.array(
[[[[1345.0,   11.0]], 
[[1591.0,   80.0]], 
[[1803.0,  138.0]],
[[1368.0,  307.0]],
[[1627.0,  355.0]],
[[1847.0,  396.0]],
[[1397.0,  641.0]],
[[1671.0,  663.0]],
[[1903.0,  682.0]]],
[[[ 296.0,  366.0]],
[[ 627.0,  362.0]],
[[ 960.0,  357.0]],
[[ 183.0,  655.0]],
[[ 570.0,  651.0]],
[[ 960.0,  647.0]],
[[  10.0, 1070.0]],
[[ 484.0, 1065.0]],
[[ 960.0, 1062.0]]]]
)

print("img points shape")
print(img_points.shape) # (2, 9, 1, 2)
print("obj points shape")
print(obj_points.shape) # (2, 1, 9, 3)

img_size = (1920, 1080)
ret, matrix, distortion, r_vecs, t_vecs = cv2.calibrateCamera(obj_points, img_points, img_size, None, None)
python opencv camera-calibration
© www.soinside.com 2019 - 2024. All rights reserved.