本文整理汇总了C#中Mat.Circle方法的典型用法代码示例。如果您正苦于以下问题:C# Mat.Circle方法的具体用法?C# Mat.Circle怎么用?C# Mat.Circle使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mat
的用法示例。
在下文中一共展示了Mat.Circle方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CppStyleMSER
/// <summary>
/// Extracts MSER by C++-style code (cv::MSER)
/// </summary>
/// <param name="gray"></param>
/// <param name="dst"></param>
private void CppStyleMSER(Mat gray, Mat dst)
{
MSER mser = new MSER();
Point[][] contours = mser.Run(gray, null); // operator()
foreach (Point[] pts in contours)
{
CvColor color = CvColor.Random();
foreach (Point p in pts)
{
dst.Circle(p, 1, color);
}
}
}
示例2: Main
public static void Main(string[] args)
{
Mat src = new Mat("TestImages/2013-12-27-09G37_TRB.jpg", LoadMode.Color);
src = src.Resize (new Size (420, 625));
Mat srcGrey = src.CvtColor(ColorConversion.BgrToGray);
Mat dst = new Mat ();
Point[][] contours;
Mat invertColour = new Mat (src.Rows, src.Cols, src.Type(), new Scalar(255, 255, 255) );
HiearchyIndex[] hierarchy;
Mat contoursLines = new Mat(src.Rows, src.Cols, src.Type());
// InputArray element = Cv2.GetStructuringElement (StructuringElementShape.Ellipse, new Size (16, 16));
// Mat thresh = srcGrey.Threshold (230, 255, ThresholdType.Binary).Dilate(element);
Mat thresh = srcGrey.Threshold (230, 255, ThresholdType.Binary);
Cv2.FindContours (thresh, out contours, out hierarchy, ContourRetrieval.Tree, ContourChain.ApproxSimple);
// Find center of mass in contour
Moments center = Cv2.Moments (contours [0]);
// Convert moment matrix to X/Y coords
int x = (int) (center.M10 / center.M00);
int y = (int) (center.M01 / center.M00);
src.Circle (new Point (x, y), 5, CvColor.CornflowerBlue, 2);
src.DrawContours (contours, 1, CvColor.Green, 2);
bool intersect = IsIntersecting (selector[0], selector[1], contours[1][0], contours[1][1]);
using (var orig = new Window ("src image", src))
{
orig.OnMouseCallback += new CvMouseCallback(MouseMove);
Cv2.WaitKey();
}
}
示例3: 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;
}
}