- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试检测这张图片上的矩形:
使用此代码:
static void Main(string[] args)
{
// Open your image
string path = "test.png";
Bitmap image = (Bitmap)Bitmap.FromFile(path);
// locating objects
BlobCounter blobCounter = new BlobCounter();
blobCounter.FilterBlobs = true;
blobCounter.MinHeight = 5;
blobCounter.MinWidth = 5;
blobCounter.ProcessImage(image);
Blob[] blobs = blobCounter.GetObjectsInformation();
// check for rectangles
SimpleShapeChecker shapeChecker = new SimpleShapeChecker();
foreach (var blob in blobs)
{
List<IntPoint> edgePoints = blobCounter.GetBlobsEdgePoints(blob);
List<IntPoint> cornerPoints;
// use the shape checker to extract the corner points
if (shapeChecker.IsQuadrilateral(edgePoints, out cornerPoints))
{
// only do things if the corners form a rectangle
if (shapeChecker.CheckPolygonSubType(cornerPoints) == PolygonSubType.Rectangle)
{
// here i use the graphics class to draw an overlay, but you
// could also just use the cornerPoints list to calculate your
// x, y, width, height values.
List<Point> Points = new List<Point>();
foreach (var point in cornerPoints)
{
Points.Add(new Point(point.X, point.Y));
}
Graphics g = Graphics.FromImage(image);
g.DrawPolygon(new Pen(Color.Red, 5.0f), Points.ToArray());
image.Save("result.png");
}
}
}
}
但它不识别矩形(墙)。它只识别大正方形,当我减小 minHeight 和 minWidth 时,它识别文字上的梯形..
最佳答案
我提出了一种不同的算法方法,在使用图像处理算法将近一年之后,我可以告诉你的是,要创建一个高效的算法,你必须“反射(reflect)”你作为一个人会怎么做,这里是建议的方法:
我们并不真正关心纹理,我们关心边缘(矩形是边缘),因此我们将应用边缘检测>差异(http://www.aforgenet.com/framework/docs/html/d0eb5827-33e6-c8bb-8a62-d6dd3634b0c9.htm),这给我们:
我们想夸大墙壁,因为人类知道我们正在寻找墙壁,但计算机不知道这一点,因此应用两轮形态学>扩张 ( http://www.aforgenet.com/framework/docs/html/88f713d4-a469-30d2-dc57-5ceb33210723.htm ),这给出我们:
我们只关心什么是墙什么不是,应用二值化>阈值 ( http://www.aforgenet.com/framework/docs/html/503a43b9-d98b-a19f-b74e-44767916ad65.htm ),我们得到:
(可选)我们可以应用 blob 提取来删除标签(“QUARTO、BANHEIRO”等)
我们应用 Color>Invert,这是刚刚完成的,因为下一步检测的是白色而不是黑色。
Apply a Blob>Processing>Connected Components Labeling ( http://www.aforgenet.com/framework/docs/html/240525ea-c114-8b0a-f294-508aae3e95eb.htm ),这将为我们提供所有矩形,如下所示:
请注意,对于每个彩色框,您都有其坐标、中心、宽度和高度。因此,您可以使用该坐标从真实图像中提取片段。
PS:强烈建议使用 AForge Image Processing Lab 程序来测试您的算法。
关于c# - 检测图像 AForge 中的小矩形,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18872415/
我目前正在做一个“自动车牌检测和识别”,我正在使用 AForge.Net;我使用了一个简单的算法; 虽然它不是很有效,但它会满足我的要求。我已经计算出高度、宽度和高度与宽度(高度/宽度)的比率超过40
我的 WinForms .NET 4 C# 应用程序在用户与其交互时记录桌面。 它根据系统的速度使用 AForge FFMPEG 或 VFW 包装器。当然,捕获是在后台线程中完成的。 无论哪种情况,包
我已经编写了一些需要处理大约 3000 张图像的 C# 代码,但是到第 500 张图像时,任务管理器显示该程序使用了 1.5GB 的内存。下面的功能似乎是罪魁祸首之一。我可以在这里做得更好吗?任何帮助
我正在使用 Aforge .NET 框架在我的应用程序中获取网络摄像头,但我总是得到一个全灰色的图像框架。 this.videoSource = new VideoCaptur
我正在玩 AForge。我从 AForge 网站复制粘贴了示例。 using System; using System.Collections.Generic; using System.Linq;
我正在尝试在 Unity 中使用 AForge,但在转换输入数据时遇到了问题。我有一个二维数组,用于存储需要转换为 UnmanagedImage 的像素值。我想出了以下代码,但我不确定它是否是最有效的
关闭。这个问题需要更多focused .它目前不接受答案。 想改进这个问题吗? 更新问题,使其只关注一个问题 editing this post . 关闭 8 年前。 Improve this qu
我正在尝试学习 Aforge.net。我写了 o 代码,它工作正常,但我只想在我的图像上检测到紫色,但我找不到它是怎么回事。所以任何人都可以帮助我吗?这是我的代码 Bitmap resim = new
有人可以给我一个完整的例子,使用这个用 VB.NET 或 C# 编写的库在 picturebox 中显示流的图像 最佳答案 这是一个非常非常简单的表单,它使用了 AForge.Video.MJPEGS
如何使用此方法: public static void DFT (Complex[] data, Direction direction) 如果我的输入数组是short[] samples?我可以轻松
我正在尝试使用 Aforge.net 开发一个 LPR 系统,我想在我的图像上应用一个过滤器,正如您在此处看到的: Bitmap a = new Bitmap(@"C:\Use
我需要一些帮助将视频从笔记本电脑相机保存到文件。现在我使用代码来搜索图片框上的视频设备和以前的视频。 我试过 AVIFileWrite 但我失败了。 如何使用 VideoFileWriter 来实现我
我正在尝试从视频文件中提取特定帧。当我使用 aforge 库播放视频文件时,我有一个想要的帧。我调用了一个新帧事件,如果新帧与我的特定帧匹配,那么它会显示一条消息:“帧匹配”。此特定帧随机出现在视频文
我尝试使用 AForge 在 C# 中使用 IP 摄像机做一个录制功能,但我无法真正理解编码,因为我是一个新学习者。录制的视频将保存在我的电脑中。 据我所知,此功能是编写/创建视频并将其保存在我的存储
很难说出这里要问什么。这个问题模棱两可、含糊不清、不完整、过于宽泛或夸夸其谈,无法以目前的形式得到合理的回答。如需帮助澄清此问题以便重新打开,visit the help center . 关闭 1
我正在尝试检测这张图片上的矩形: 使用此代码: static void Main(string[] args) { // Open your image string path = "
我正在使用 AForge 进行运动检测,并且我知道可以设置运动区域。是否可以让它仅在所有定义区域中有运动时触发?如果上面的功能不是现成的,我正在考虑编写它。 目前,我的理解是区域设置为视觉库中 Mot
我需要在图像上查找对象,因此我尝试使用 AForge 库来完成。我从非常简单的图案和图片开始,但识别准确度已经很糟糕了。我正在使用 ExhaustiveTemplateMatching: Exhaus
如何检测视频中的非移动 Blob ? 假设我有一个视频和一个初始背景帧位图。是否有可能检测到不移动的 Blob /对象?并围绕该对象绘制一个矩形? 最佳答案 这让我想起了一种检测地铁上遗忘元素的算法。
我正在尝试在 AForge 中检测矩形内的圆。我已成功确定 Rectangles,但无法在 Rectangle 中找到 circles。如何在 AForge 中找到另一个形状内的形状。 string
我是一名优秀的程序员,十分优秀!