opencvsharp
opencvsharp copied to clipboard
Cannot convert from OpenCvSharp.Point2f[] to OpenCvSharp.Mat<OpenCvSharp.Point2f>
Summary of your issue
Could not find any methods that will let me convert the Point2f[] to Mat<Point2f>
A little background: I am trying to move from OpenCvSharp 3 to OpencvSharp 4. Therefore changing every instance of MatOfPoint2f to Mat<Point2f>.
Environment
Visual Studio 2019 Windows 10 .Net Framework 4.7.2
Example code:
I only pasted the part of the code and please do not care about the approach here! The variable Point2f[] is of my interest here.
List<Mat<Point2f>> imagePoints = new List<Mat<Point2f>>
Point2f[] corners = null;
var foundCorners = Cv2.FindChessboardCorners(
calibrationImage,
new Size(CalibrationPatternSize.X, CalibrationPatternSize.Y),
out corners,
ChessboardFlags.AdaptiveThresh);
var subPixelCorners = Cv2.CornerSubPix(calibrationImage, corners, new Size(1, 1), new Size(-1, -1), criteria);
imagePoints.Add(corners.Clone()); // This is where I get the error
corners.Dispose(); // Obviously an error here as well
What did you intend to be?
Either I wish to know a workaround or a simpler way to convert the variable 'corners' to Mat<Point2f> and add it to my list.
Something like this:
var matCorners = new Mat(corners.Length, 1, MatType.CV_32FC2, corners);
No need to dispose corners
it's an array of structs.
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.