StereoCalibrate Error i < 0
See original GitHub issueSummary of your issue
I’m attempting to run StereoCalibrate on the left/right calibration images in the example data. I can calibrate each camera separately but I get this very undescriptive error ( i < 0 ) when moving on to the StereoCalibrate function. There’s a good probability that one of my inputs isn’t right, but I have no way of knowing which one. From what I can tell, all inputs are the correct type and size. Nothing is empty.
Environment
Windows 10, x64
What did you do when you faced the problem?
Checked to make sure all input lists of points are the correct size, not empty or null.
Example code:
` // images contains a list of pairs of left/right images var objectPointsOfFrames = new List<InputArray>(images.Count);
var leftImagePointsOfFrames = new List<InputArray>(images.Count);
var rightImagePointsOfFrames = new List<InputArray>(images.Count);
var frameSize = images.First().Item1.Size();
foreach (var imagePair in images)
{
// I can confirm that each image contains a chessboard pattern and returns points
leftImagePointsOfFrames.Add(chessBoard.FindFromImage(imagePair.Item1));
rightImagePointsOfFrames.Add(chessBoard.FindFromImage(imagePair.Item2));
// This adds a MatOfPoint3f with the points in the chess pattern
objectPointsOfFrames.Add(chessBoard.GetObjectMatPoints());
}
var essentialMatrix = new Mat();
var fundamentalMatrix = new Mat();
// LeftCam.CamMatrix, LeftCam.DistortionCoefficients are configured from successfully calibrating from the left image set. The same applies to RightCam.
Cv2.StereoCalibrate(
objectPointsOfFrames,
leftImagePointsOfFrames,
rightImagePointsOfFrames,
LeftCam.CamMatrix, LeftCam.DistortionCoefficients,
RightCam.CamMatrix, RightCam.DistortionCoefficients,
frameSize, RotationVector, TranslationVector, essentialMatrix, fundamentalMatrix);
`
Output:
OpenCvSharp.OpenCVException: i < 0
at OpenCvSharp.NativeMethods+<>c.<.cctor>b__1619_0 (OpenCvSharp.ErrorCode status, System.String funcName, System.String errMsg, System.String fileName, System.Int32 line, System.IntPtr userdata) [0x00010] in <45a494b8b9514a01b4c3f460652ae2ad>:0
at (wrapper managed-to-native) OpenCvSharp.NativeMethods.calib3d_stereoCalibrate_InputArray(intptr[],int,intptr[],int,intptr[],int,intptr,intptr,intptr,intptr,OpenCvSharp.Size,intptr,intptr,intptr,intptr,int,OpenCvSharp.TermCriteria)
at OpenCvSharp.Cv2.StereoCalibrate (System.Collections.Generic.IEnumerable1[T] objectPoints, System.Collections.Generic.IEnumerable
1[T] imagePoints1, System.Collections.Generic.IEnumerable1[T] imagePoints2, OpenCvSharp.InputOutputArray cameraMatrix1, OpenCvSharp.InputOutputArray distCoeffs1, OpenCvSharp.InputOutputArray cameraMatrix2, OpenCvSharp.InputOutputArray distCoeffs2, OpenCvSharp.Size imageSize, OpenCvSharp.OutputArray R, OpenCvSharp.OutputArray T, OpenCvSharp.OutputArray E, OpenCvSharp.OutputArray F, OpenCvSharp.CalibrationFlags flags, System.Nullable
1[T] criteria) [0x0010c] in <45a494b8b9514a01b4c3f460652ae2ad>:0
What did you intend to be?
Not an exception 😃
Issue Analytics
- State:
- Created 5 years ago
- Comments:9
Here’s my code, I hope it helps:
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.