本文整理汇总了C#中Mat.PutText方法的典型用法代码示例。如果您正苦于以下问题:C# Mat.PutText方法的具体用法?C# Mat.PutText怎么用?C# Mat.PutText使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mat
的用法示例。
在下文中一共展示了Mat.PutText方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DetectBallView
static Mat DetectBallView(Mat s, Mat h)
{
//Console.WriteLine(mat);
//Console.WriteLine("{0}:{1}", mat.Width, mat.Height);
//Console.WriteLine("{0}, {1}, {2}", mat.Step(0), mat.Step(), mat.Step(1));
//return;
const int ballWidth = 36;
var balls = DetectBalls(s, h, ballWidth);
var detectM = QuickDetectBalls_Field(s.Threshold(20, 255, ThresholdType.Binary), ballWidth);
if (true)
{
var debugMat = new Mat();
Cv2.CvtColor(s, debugMat, ColorConversion.GrayToRgb);
const int ballWidth_3 = ballWidth / 3;
var detectCount = 0;
var allDetectCount = 0;
for (var y = 0; y < detectM.GetLength(1); ++y)
for (var x = 0; x < detectM.GetLength(0); ++x)
{
if (detectM[x, y] > 0.8 * ballWidth_3 * ballWidth_3)
{
debugMat.Circle(x * ballWidth_3 + ballWidth_3 / 2, y * ballWidth_3 + ballWidth_3 / 2, 2, Color.LightGreen.ToScalar(), -1);
detectCount++;
}
allDetectCount++;
}
foreach (var ball in balls)
{
debugMat.Circle(ball.Point.X, ball.Point.Y, ballWidth / 2, Color.Orange.ToScalar(), thickness: 1);
debugMat.PutText(ball.H.ToString(), new OpenCvSharp.CPlusPlus.Point(ball.Point.X - ballWidth / 4, ball.Point.Y), FontFace.HersheySimplex, 0.5, Color.Red.ToScalar());
}
if (true)
{
var p = new Point(400, 150);
var center = new Point(400, 300);
var resPoint = RotatePointAroundCenter(p, center, 90);
var resPoint2 = RotatePointAroundCenter(p, center, 45);
var resPoint3 = RotatePointAroundCenter(p, center, 135);
debugMat.Circle(resPoint.X, resPoint.Y, 3, Color.LightBlue.ToScalar(), -1);
debugMat.Circle(resPoint2.X, resPoint2.Y, 3, Color.LightBlue.ToScalar(), -1);
debugMat.Circle(resPoint3.X, resPoint3.Y, 3, Color.LightBlue.ToScalar(), -1);
debugMat.Circle(center.X, center.Y, 3, Color.LightBlue.ToScalar(), -1);
debugMat.Circle(p.X, p.Y, 3, Color.LightBlue.ToScalar(), -1);
}
Console.WriteLine("detect count: {0}%", 100 * detectCount / allDetectCount);
debugMat.ImWrite("q.bmp");
return debugMat;
}
}
示例2: With_Title
public static Mat With_Title(this Mat mat, string text)
{
var res = new Mat(mat.ToIplImage(), true);
res.Rectangle(new Rect(res.Width / 2 - 10, 30, 20 + text.Length * 15, 25), new Scalar(0), -1);
res.PutText(text, new OpenCvSharp.CPlusPlus.Point(res.Width / 2, 50), FontFace.HersheyComplex, 0.7, new Scalar(150, 200, 150));
return res;
}