In samples/python2/video.py there is usage of projectPoints which takes an array and reshapes it (-1,3) resulting in an Nx3 array for that function, it seems like the same format should work here.推荐答案我对相机校准了解不多.但是看到您的代码和错误后,我进行了如下更改:I don't know much about camera calibration. But seeing your code and the error, I changed it as follows:import cv2import numpy as npcamera_matrix = np.array([[1.3e+03, 0., 6.0e+02], [0., 1.3e+03, 4.8e+02], [0., 0., 1.]], dtype=np.float32)dist_coeffs = np.array([-2.4-01, 9.5e-02, -4.0e-04, 8.9e-05, 0.], dtype=np.float32)test = np.zeros((10,1,2), dtype=np.float32)xy_undistorted = cv2.undistortPoints(test, camera_matrix, dist_coeffs)print xy_undistorted下面是我得到的结果,请检查是否正确:Below is the result I got, Check if it is correct:[[[ 0.0187303 0.01477836]] [[ 0.0187303 0.01477836]] [[ 0.0187303 0.01477836]] [[ 0.0187303 0.01477836]] [[ 0.0187303 0.01477836]] [[ 0.0187303 0.01477836]] [[ 0.0187303 0.01477836]] [[ 0.0187303 0.01477836]] [[ 0.0187303 0.01477836]] [[ 0.0187303 0.01477836]]] 出什么问题了: 该错误表明,源应为EITHER one row OR one column.它应该是CV_32FC2或CV_64FC2,表示两个通道和浮点数.因此,将您的src形状设置为(10,1,2) or (1,10,2).两种方法都起作用并且给出相同的结果(我自己检查了).唯一的问题是,我不知道它是否正确,所以请您自己检查.The error says, source should be having EITHER one row OR one column. And it should be of CV_32FC2 or CV_64FC2, means two channels and floating point. So make your src of shape (10,1,2) or (1,10,2). Both methods work and give same result ( I checked it myself ) . Only problem is, I don't know if it is correct, so check it yourself. 这篇关于如何使用python cv2 api格式化undistortPoints的xy点?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
10-26 22:27