I'm having trouble formatting the x,y list of points to pass to undistortPoints (opencv 2.4.1).
The error message is c++ specific and complains about the array of points not being of type CV_32FC2. Shouldn't I be able to pass in an Nx2 numpy array?
import cv2
camera_matrix = array(mat('1.3e+03, 0., 6.0e+02; 0., 1.3e+03, 4.8e+02; 0., 0., 1.'), dtype=float32)
dist_coeffs = array(mat('-2.4-01, 9.5e-02, -4.0e-04, 8.9e-05, 0.'), dtype=float32)
test = zeros((10,2), dtype=float32)
print test.shape, type(test)
xy_undistorted = cv2.undistortPoints(test, camera_matrix, dist_coeffs)
results in:
opencv/modules/imgproc/src/undistort.cpp:279: error: (-215) CV_IS_MAT(_src) && CV_IS_MAT(_dst) && (_src->rows == 1 || _src->cols == 1) && (_dst->rows == 1 || _dst->cols == 1) && _src->cols + _src->rows - 1 == _dst->rows + _dst->cols - 1 && (CV_MAT_TYPE(_src->type) == CV_32FC2 || CV_MAT_TYPE(_src->type) == CV_64FC2) && (CV_MAT_TYPE(_dst->type) == CV_32FC2 || CV_MAT_TYPE(_dst->type) == CV_64FC2) in function cvUndistortPoints
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.