gpt4 book ai didi

c# - 如何在 EmguCv 中使用 OpenCv 3.0 CvInvoke.HoughLines 方法

转载 作者:太空宇宙 更新时间:2023-11-03 23:16:39 24 4
gpt4 key购买 nike

如何在 C# 中使用 EmguCv 调用 CvInvoke.HoughLines?因此不是 HoughLinesP 方法。我遇到的问题是用于第二个参数的类型,它是 IOutputArray。

最佳答案

        LineSegment2D[] lines;
using (var vector = new VectorOfPointF())
{
CvInvoke.HoughLines(cannyEdges, vector,
_arguments.HoughLineArgs.DistanceResolution,
Math.PI / _arguments.HoughLineArgs.AngleResolution,
_arguments.HoughLineArgs.Threshold);

var linesList = new List<LineSegment2D>();
for (var i = 0; i < vector.Size; i++)
{
var rho = vector[i].X;
var theta = vector[i].Y;
var pt1 = new Point();
var pt2 = new Point();
var a = Math.Cos(theta);
var b = Math.Sin(theta);
var x0 = a * rho;
var y0 = b * rho;
pt1.X = (int)Math.Round(x0 + mat.Width * (-b));
pt1.Y = (int)Math.Round(y0 + mat.Height * (a));
pt2.X = (int)Math.Round(x0 - mat.Width * (-b));
pt2.Y = (int)Math.Round(y0 - mat.Height * (a));

linesList.Add(new LineSegment2D(pt1, pt2));
}

lines = linesList.ToArray();
}

关于c# - 如何在 EmguCv 中使用 OpenCv 3.0 CvInvoke.HoughLines 方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38031836/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com