title: Emgu.CV Fisheye.Calibrate method
body: <p>I'm currently trying to use the Fisheye.Calibrate method and the Fisheye.UndistorImage method from the Emgu.CV library. As far as I've understood, the Calibrate method is used to calculate a camera matrix (K) and a distortion vector (D), which are to be used to undistort fisheye-images using the UndistorImage method. However, when I use these two methods the results are not convincing. This is the input image I'm testing on: <a href="https://i.stack.imgur.com/IAAyb.png" rel="nofollow noreferrer">fisheye input image</a> and this is the result: <a href="https://i.stack.imgur.com/CPbyc.png" rel="nofollow noreferrer">fisheye output image</a>. </p>
  
  <p>When I tried to look at the values of K and D by looking at the data-variable of the objects, it said 'null' for both K and D. Therefore I'm unsure if I'm using the Calibrate() metod correctly. My code is as follow:</p>
  
  <pre><code>private void EmguCVUndistortFisheye()
      {
          string[] fileNames = Directory.GetFiles(@"C:\Users\Test\Desktop\Jakob\ImageAnalysis\Images\Calibration", "*.png");
          Size patternSize = new Size(6, 8);
          VectorOfVectorOfPoint3D32F objPoints = new VectorOfVectorOfPoint3D32F();
          VectorOfVectorOfPointF imagePoints = new VectorOfVectorOfPointF();
          foreach (string file in fileNames)
          {
              Mat img = CvInvoke.Imread(file, ImreadModes.Grayscale);
              CvInvoke.Imshow("input", img);
              VectorOfPointF corners = new VectorOfPointF(patternSize.Width * patternSize.Height);
              bool find = CvInvoke.FindChessboardCorners(img, patternSize, corners);
              if (find)
              {
                  MCvPoint3D32f[] points = new MCvPoint3D32f[patternSize.Width * patternSize.Height];
                  int loopIndex = 0;
                  for (int i = 0; i &lt; patternSize.Height; i++)
                  {
                      for (int j = 0; j &lt; patternSize.Width; j++)
                          points[loopIndex++] = new MCvPoint3D32f(j, i, 0);
                  }
                  objPoints.Push(new VectorOfPoint3D32F(points));
                  imagePoints.Push(corners);
              }
          }
          Size imageSize = new Size(1280, 1024);
          Mat K = new Mat();
          Mat D = new Mat();
          Mat rotation = new Mat();
          Mat translation = new Mat();
          Fisheye.Calibrate(
              objPoints,
              imagePoints,
              imageSize,
              K,
              D,
              rotation,
              translation,
              Fisheye.CalibrationFlag.CheckCond,
              new MCvTermCriteria(30, 0.1)
          );
  
          foreach (string file in fileNames)
          {
              Mat img = CvInvoke.Imread(file, ImreadModes.Grayscale);
              Mat output = img.Clone();
              Fisheye.UndistorImage(img, output, K, D);
              CvInvoke.Imshow("output", output);
          }
      }
  </code></pre>
  
  <p>Is the reason for my strange results a consequence of wrong parameters to the Calibrate method or is it simply the case of not using enough input images?</p>