Ask Your Question

Android: Exception in cvConvertScale, called from solvePnP

asked 2013-07-17 21:17:23 -0600

Joseph Howse gravatar image

In an OpenCV4Android app, I get the following error when running Calib3d.solvePnP(MatOfPoint3f objectPoints, MatOfPoint2f imagePoints, Mat cameraMatrix, MatOfDouble distCoeffs, Mat rvec, Mat tvec):

CvException [org.opencv.core.CvException: /home/reports/ci/slave_desktop/50-SDK/opencv/modules/core/src/convert.cpp:1352: error: (-215) src.size == dst.size && src.channels() == dst.channels() in function void cvConvertScale(void const*, void*, double, double)
at org.opencv.calib3d.Calib3d.solvePnP_1(Native Method)
at org.opencv.calib3d.Calib3d.solvePnP(

Can anyone tell me, how does solvePnP use cvConvertScale, and which arguments to solvePnP are likely to cause this exception?

My objectPoints and imagePoints matrices are Nx1 (the same size as each other). My cameraMatrix is 3x3. My distCoeffs is 4x1 and contains all zeroes. My rvec and tvec are newly instantiated MatOfFloat objects.

If any more information would be helpful, please let me know. Thanks!

edit retag flag offensive close merge delete


Nevermind, I solved the issue. I had a bug where I was resizing cameraMatrix improperly. As described above, though, 3x3 is the correct size.

Joseph Howse gravatar imageJoseph Howse ( 2013-07-22 10:46:22 -0600 )edit

1 answer

Sort by ยป oldest newest most voted

answered 2016-11-29 11:08:55 -0600

Hi there, could you please show me how you create all objects? I have same problem, can't figure out how to create cameraMatrix appropriately.

edit flag offensive delete link more

Question Tools

1 follower


Asked: 2013-07-17 21:17:23 -0600

Seen: 1,068 times

Last updated: Jul 17 '13