1

I just want to give this function a test. And yet, it came with some incomprehensive errors at the beginning, which I finally found the solution. That is: both objectPoints & imagePoints have to be changed to CV_32FC3 & CV_32FC2 respectively, the code works fine. For this, the documentation of OpenCV is so erroneous which tells that all matrix representation can work

Getting over this bug, I have incorrect output:

enter image description here

The projected image points are irrational (of course, I've checked my input data).

Has anyone experienced with this function of OpenCV, giving correct projection?

Edit 01: output(2,2) = -1.#QNAN000

=> can this be a clue to know the cause of error??

Community
  • 1
  • 1
TSL_
  • 2,049
  • 3
  • 34
  • 55

1 Answers1

0

the cause is from my lack of experience working with OpenCV matrices. After 2 dyas working, testing with CvMat and Mat. I've learnt a few poitns:

  • create a good matrix display function so that it will not show awkward numbers which I have found good suggestion from this post Multi channel Mat display function

  • be careful when you feed/init OpenCV matrices with your predefined data, careful with 1-channel or multi-channel matrices. Give it some trials before you know how OpenCV understands your input data

  • acknowledge that cvProjectPoints2 does not get single channel matrices as in/outputs

after all debugging, my output is like this:

enter image description here

and this is pretty closed to my real object points & image points & calibrated camera matrix

Community
  • 1
  • 1
TSL_
  • 2,049
  • 3
  • 34
  • 55