Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Python] rectifyPoint is broken since OpenCV 2 Python API change #62

Closed
bsubei opened this issue Jun 2, 2015 · 4 comments
Closed

[Python] rectifyPoint is broken since OpenCV 2 Python API change #62

bsubei opened this issue Jun 2, 2015 · 4 comments

Comments

@bsubei
Copy link
Contributor

bsubei commented Jun 2, 2015

Just realized the Python rectifyPoint() method (in PinholeCameraModel inside image_geometry package) is broken, probably since the OpenCV 2 Python API change in this commit.

It seems the cv2.undistortPoints() function in Python (OpenCV 2 API) behaves differently than in OpenCV 1 (they don't document it apparently). Possible solution: the input argument src has to be a 3d array (?).

Just uncomment this line in the test and run it, and you will see it crash and give this error:

OpenCV Error: Assertion failed (src.isContinuous() && (src.depth() == CV_32F || src.depth() == CV_64F) && ((src.rows == 1 && src.channels() == 2) || src.cols*src.channels() == 2)) in undistortPoints, file /build/buildd/opencv-2.4.8+dfsg1/modules/imgproc/src/undistort.cpp, line 394
test_monocular ... ERROR!
ERROR: /build/buildd/opencv-2.4.8+dfsg1/modules/imgproc/src/undistort.cpp:394: error: (-215) src.isContinuous() && (src.depth() == CV_32F || src.depth() == CV_64F) && ((src.rows == 1 && src.channels() == 2) || src.cols*src.channels() == 2) in function undistortPoints
@bsubei
Copy link
Contributor Author

bsubei commented Jun 2, 2015

I noticed I can get past this specific error if I comment out line 102, but then I face another error:

cv2.error: /build/buildd/opencv-2.4.8+dfsg1/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

Notice this error is inside cvUndistortPoints, which is called by undistortPoints (the previous error), so it seems like the above-mentioned fix is at least fixing part of the problem (or is progress towards one).

@bsubei
Copy link
Contributor Author

bsubei commented Jun 2, 2015

Also, since the function signature (opencv 2) has changed to:
undistortPoints(src, cameraMatrix, distCoeffs[, dst[, R[, P]]]) -> dst , line 104 has to change to:
dst = cv2.undistortPoints(src, self.K, self.D, self.R, self.P)

@bsubei
Copy link
Contributor Author

bsubei commented Jun 2, 2015

The cvUndistortPoints source code, where the assertion error is, for reference.

@bsubei
Copy link
Contributor Author

bsubei commented Jun 2, 2015

found the solution! Will submit pull request soon.

bsubei added a commit to bsubei/vision_opencv that referenced this issue Jun 2, 2015
@vrabaud vrabaud closed this as completed in b4d9ac8 Jun 3, 2015
vrabaud added a commit that referenced this issue Jun 3, 2015
fixes #62, bug in Python rectifyPoint old opencv1 API
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant