本文整理汇总了C#中OpenCvSharp.CPlusPlus.Mat.Circle方法的典型用法代码示例。如果您正苦于以下问题:C# Mat.Circle方法的具体用法?C# Mat.Circle怎么用?C# Mat.Circle使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OpenCvSharp.CPlusPlus.Mat
的用法示例。
在下文中一共展示了Mat.Circle方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
private static void Main(string[] args)
{
string fileName = "C:\\perspective_chessboard.jpg";
// Cv
using (CvMat chessboard = new CvMat(fileName))
{
Cv.ShowImage("Input_Cv", chessboard);
CvPoint2D32f[] corners;
if (Cv.FindChessboardCorners(chessboard, new Size(10, 7), out corners))
{
using (CvMat dest = new CvMat(chessboard.Rows, chessboard.Cols, MatrixType.U8C3))
{
CvPoint2D32f[] a =
{
corners[0],
corners[60],
corners[69],
corners[9]
};
foreach (var corner in a)
{
Cv.Circle(chessboard, corner, 5, new CvScalar(0, 0, 255));
}
Cv.ShowImage("RectangleVertices_Cv", chessboard);
CvPoint2D32f[] b =
{
new CvPoint2D32f(0, 0),
new CvPoint2D32f(0, chessboard.Height),
new CvPoint2D32f(chessboard.Width, chessboard.Height),
new CvPoint2D32f(chessboard.Width, 0)
};
CvMat map_matrix;
Cv.GetPerspectiveTransform(a, b, out map_matrix);
Cv.WarpPerspective(chessboard, dest, map_matrix, Interpolation.Linear | Interpolation.FillOutliers, CvScalar.ScalarAll(255)); //Succeed
Cv.ReleaseMat(map_matrix);
Cv.ShowImage("Output_Cv", dest);
}
//Cv.WaitKey();
}
}
//Cv2
using (Mat chessboard = new Mat(fileName))
{
Point2f[] corners;
if (Cv2.FindChessboardCorners(chessboard, new Size(10, 7), out corners))
{
Point2f[] a =
{
corners[0],
corners[60],
corners[69],
corners[9]
};
foreach (var corner in a)
{
chessboard.Circle(corner, 5, new Scalar(0, 0, 255));
}
Cv2.ImShow("RectangleVertices_Cv2", chessboard);
//Cv2.WaitKey();
Point2f[] b =
{
new Point2f(0, 0),
new Point2f(0, chessboard.Height),
new Point2f(chessboard.Width, chessboard.Height),
new Point2f(chessboard.Width, 0)
};
using (Mat map_matrix = Cv2.GetPerspectiveTransform(a, b))
using (Mat dest = new Mat(new Size(640, 480), MatType.CV_8UC3))
{
Cv2.WarpPerspective(chessboard, dest, map_matrix, dest.Size(), Interpolation.Linear | Interpolation.FillOutliers, BorderType.Default, Scalar.All(255)); //AccessViolation
Cv2.ImShow("Output_Cv2", dest);
}
////Another way (Using Mat.WarpPerspective())
//using (Mat map_matrix = Cv2.GetPerspectiveTransform(a, b))
//using (Mat dest = chessboard.WarpPerspective(map_matrix, new Size(640, 480), Interpolation.Linear | Interpolation.FillOutliers, BorderType.Default, Scalar.All(255))) //AccessViolation
//{
// Cv2.ImShow("Output_Cv2", dest);
//}
Cv2.WaitKey();
}
}
//Track();
//Run();
}