1

"OpenCV Error: Bad argument (Homogeneous coordinates are not supported ) in unknown function, file ......\modules\calib3d\src\calibration.cpp, line 826"

I think I'm getting this error when passing the following matrix into cvProjectPoints2() function

CvMat *dstPoints2D = cvCreateMat (4, 1, CV_32FC3);

cvProjectPoints2(srcPoints3D,rotation,translation,intrinsic_matrix,NULL,dstPoints2D);

I'm using OpenCV 2.3.0

Full code: http://pastebin.com/TYthn6Nt

Thanks in advance.

coder9
  • 1,571
  • 1
  • 27
  • 52

1 Answers1

3

The output needs to be two channels. Change the declaration to CvMat *dstPoints2D = cvCreateMat (4, 1, CV_32FC2); and you won't get the error.

SSteve
  • 10,550
  • 5
  • 46
  • 72
  • +1 for the reply. but now I'm getting the error "Bad argument: one of the requirement arguments is not a valid matrix" (Calibration.cpp, line 790) – coder9 Oct 02 '11 at 08:24
  • It works correctly for me. Did you change anything else? [Here's my version that runs.](http://pastebin.com/uEL1CKWT) – SSteve Oct 02 '11 at 16:07
  • Nope. didn't change anything. Are you running on OpenCV 2.3? – coder9 Oct 03 '11 at 10:51
  • Wow SSteve. your code really works. I changed mine to CvMat *dstPoints2D = cvCreateMat (4, 1, CV_32FC2); but the problem was still there. Wonder how your code works :S – coder9 Oct 03 '11 at 11:02
  • 1
    You can use a diff tool to compare the two files. Something must be different. You can also duplicate each individual test in the statement where cvProjectPoints2 fails in calibration.cpp to see which clause of the if statement is the one that triggers the error. – SSteve Oct 03 '11 at 17:43
  • I'm having the same error. However, when both objectPoints & imagePoints are changed to CV_32FC3 & CV_32FC2 respectively, the code works fine. Then, the documentation of OpenCV is so erroneous – TSL_ Aug 29 '12 at 05:28