在 iPhone 上检测图像中的三角形角点

发布于 2024-11-02 01:55:18 字数 276 浏览 0 评论 0原文

嘿伙计们, 我在完成我的应用程序时遇到了一个小问题;事实上,到目前为止,在某些时候,用户必须选择带有一些可拖动对象的三角形的三个顶点。现在,尽管这不是问题,但我认为用户交互接近于零,并且让我的应用程序挑选出图像中三角形的顶点,并自动将标记放置在正确的位置上,这可能会很有趣。

在做了一些研究并考虑了 OpenCV、ImageMagick 等之后,我不太确定如何识别和找到图像中三角形顶点的位置。有什么想法吗?

提前致谢!

编辑:如果有人有一个不涉及艾米外部库的解决方案,我仍然很高兴听到它!

Hey guys,
I'm having a slight problem when finalizing my app; indeed, up until now, at some point, the user had to select the three vertices of a triangle with some draggable objects. Now, even though this isn't a problem, I thought it could be interesting to have close to zero user-interaction, and have my app pick out the vertices of the triangle in an image, and automatically place the markers on the correct spots.

After doing some research, and thinking about stuff lile OpenCV, ImageMagick, etc, I'm not really certain as to how one would recognize and find the location of the vertices of a triangle in an image. Any ideas?

Thanks in advance!

EDIT: If someone has a solution that doesn't involve amy external libraries, I'd still be quite glad to hear it!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

习ぎ惯性依靠 2024-11-09 01:55:18

可以检测图像中的形状,然后使用各种不同的图像处理技术检测这些形状的角点。例如,请参阅这个SO问题关于检测多边形的角点我的答案

这实际上是一项简单还是困难的任务,很大程度上取决于您可以安全地假设有关三角形图像的信息量。

例如,如果您的图像是计算机生成的并且其中只有一个三角形而没有其他内容,并且如果三角形与背景形成鲜明对比(如下所示),那么您可以使用 OpenCV 在几行代码中编写一些内容来找到您的顶点.
来自维基百科的三角形

在这种情况下,您会将您的图像转换为灰度图像,应用阈值来创建二值图像,使用内置函数查找图像的边界,然后使用任何SO 问题中寻找角点的方法。

另一方面,如果您正在处理三角形的照片,您的问题就会变得更加困难,因为获取三角形的二值图像并不那么简单。您将不得不处理未知的照明和背景条件。您可能无法使用简单的阈值,并且您不知道要使用什么值阈值。您可能需要对图像进行某种边缘检测,并且您将看到一个耗时的项目。首先,请参阅 O'Reilly 的书学习 OpenCV

在此处输入图像描述

It is possible to detect shapes in images and then detect the corners of those shapes using a variety of different image processing techniques. See for example this SO question about detecting corners of polygons and my answer there.

Whether this will actually be a simple or difficult task depends greatly on how much information you can safely assume about the image of your triangle.

For example, if your images are computer generated and have only a triangle in them and nothing else and if the triangle contrasts sharply with the background, as below, than you could write something in a few lines of code using OpenCV that would find your vertices.
triangle from wikipedia

In that case, you would convert your image to a grayscale image, apply a threshold to to create a binary image, use a built in function find the boundary of the image, and then use any of the methods in the SO question to find the corners.

If on the other hand you are dealing with a photograph of a triangle, your problem becomes much more difficult, because it will not be as simple to acquire a binary image of your triangle. You will have to deal with unknown lighting and background conditions. You may not be able to use a simple threshold, and you won't know what value threshold to use. You will likely need to do some kind of edge detection on your image, and you will be looking at a time consuming project. For a start, see the O'Reilly book, Learning OpenCV.

enter image description here

少女净妖师 2024-11-09 01:55:18

特征检测是复杂的事情,因此除非您想从头开始编写自己的特征检测,否则您只能使用第三方库。这是一个看起来很有前途的方案:

http://code.google.com/p/简单的 iPhone 图像处理/

Feature-detection is complicated stuff, so unless you want to write your own from scratch, you're stuck with using a third-party library. Here's one that looks promising:

http://code.google.com/p/simple-iphone-image-processing/

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文