0

I'm trying to get calibrateCamera working on my Node.js backend. The library is working fine, but I'm having trouble with the OpenCV functions not giving any error messages if I have faulty inputs. I'm kind of flying in the dark.

But that's beside the point. I've taken 17 images of the chessboard calibration pattern, and got the code to detect the pattern in all of the images. Everything works just fine until I call cv.calibrateCamera(), probably due to me not knowing what I should use as the required inputs for cameraMatrix and distCoeff (4th and 5th input parameters). However, I can't be 100% this is the issue because of not receiving any error messages from errors in the cv... functions.

I tried to follow the example at https://docs.opencv.org/3.1.0/dc/dbb/tutorial_py_calibration.html , but on python in the tutorial you can use None as inputs to cameraMatrix and distCoeff. I tried to use null, but that didn't work either.

Any help would be appreciated.

const size = new cv.Size(9,6);
  let mat = null;

  let objpt = [];
  for(let i=0;i<9;i++) {
    for(let j=0;j<6;j++) {
      objpt.push(cv.Point(2.5*i,2.5*j,0))
    }
  }

  let objectPoints = [];
  let imagePoints =[];

  for (let i=0; i < 17;i++) {
    mat = cv.imread('./calib/calib'+(i+1)+'.jpg');
    let smallmat = mat.resize(756,1008);
    const corners = smallmat.findChessboardCorners(size);
    if (corners.returnValue) {
      objectPoints = objectPoints.concat(objpt);
      imagePoints = imagePoints.concat(corners.corners);
    }
  }

 // THIS IS WHERE EXECUTION JUST STOPS WITH NO ERROR MESSAGE

  cv.calibrateCamera(
    objectPoints,
    imagePoints,
    new cv.Size(756,1008),
    new cv.Mat(3, 3, cv.CV_32FC1,0),
    [0,0,0,0,0]
  );
ekuusi
  • 57
  • 8

1 Answers1

1

According to the test parameters should be passed like this:

 [_objectPoints, _objectPoints],
 [imagePoints, imagePoints],
 imageSize,
 _cameraMatrix,
 distCoefficients

where

const _cameraMatrix = new cv.Mat([ [800, 0, 100], [0, 800, 100], [0, 0, 1] ], cv.CV_64F);

and

const distCoefficients = [0, 0.5, 1.0, 1.0];