This may be the size of your matrix :)
OpenCV expects a point vector - a column or matrix of rows with two channels. But since your input matrix is ββonly 2 points, and the number of channels is 1, it cannot determine what an input, row or colum is.
So, fill in a long input mat with dummy values ββand save only the first:
const int npoints = 4; // number of point specified // Points initialization. // Only 2 ponts in this example, in real code they are read from file. float input_points[npoints][4] = {{0,0}, {2560, 1920}}; // the rest will be set to 0 CvMat * src = cvCreateMat(1, npoints, CV_32FC2); CvMat * dst = cvCreateMat(1, npoints, CV_32FC2); // fill src matrix float * src_ptr = (float*)src->data.ptr; for (int pi = 0; pi < npoints; ++pi) { for (int ci = 0; ci < 2; ++ci) { *(src_ptr + pi * 2 + ci) = input_points[pi][ci]; } } cvUndistortPoints(src, dst, &camera1, &distCoeffs1);
EDIT
Although OpenCV indicates that undistortPoints accept only 2-channel input, it actually accepts
- 1-column, two-channel multi-row mat or (and this case is not documented)
- 2 columns, multi-row, 1-channel mats or
- multi-column, 1 row, 2-channel mats
(as seen on undistort.cpp, line 390)
But an error inside (or lack of available information) makes it wrong to mix the second with the third when the number of columns is 2. Thus, your data is considered 2-column, 2-line, 1-channel.
source share