使用通用网络摄像头进行物体检测

发布于 2024-10-21 03:38:03 字数 311 浏览 2 评论 0原文

这是我想用尽可能少的努力来解决的任务(最好使用 QT 和 C++ 或 Java):我想使用网络摄像头视频输入来检测相机前面是否有(或更多)板条箱镜头与否。当摄像头将其视频信号传送到我的应用程序时,场景可以从“清晰”变为“镜头前面有一个板条箱”,然后再返回。对于原型测试/学习,我有 2-3 张“空”场景的图像,以及 2-3 张带有一个或多个板条箱的图像。

您知道如何完成这项任务的简单想法吗?我找到了 OpenCV,但是这个框架对于这个简单的任务来说是不是太庞大了?我是计算机视觉领域的新手。这通常是一项艰巨的任务,还是在实时反馈中检测摄像头前面是否有障碍物简单而可靠?非常感谢您的专家意见!

Here’s my task which I want to solve with as little effort as possible (preferrably with QT & C++ or Java): I want to use webcam video input to detect if there’s a (or more) crate(s) in front of the camera lens or not. The scene can change from "clear" to "there is a crate in front of the lens" and back while the cam feeds its video signal to my application. For prototype testing/ learning I have 2-3 images of the “empty” scene, and 2-3 images with one or more crates.

Do you know straightforward idea how to tackle this task? I found OpenCV, but isn't this framework too bulky for this simple task? I'm new to the field of computer vision. Is this generally a hard task or is it simple and robust to detect if there's an obstacle in front of the cam in live feeds? Your expert opinion is deeply appreciated!

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

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

发布评论

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

评论(5

淑女气质 2024-10-28 03:38:03

这是我听说过的一种方法,可能会取得一些成功:

  • 对图像执行边缘检测,将其转换为黑白图像,其中边缘显示为黑色像素。
  • 现在创建一个直方图来记录图像中每个垂直像素列中黑色像素的频率。这里的理论是,一个桶内或周围的直方图中的高频值表示垂直边缘,这可能是板条箱的边缘。

您还可以考虑使用第二个直方图来测量图像每行上的像素。

显然,这是一种相当简单的方法,并且高度依赖于“简单”输入;即在空白背景下具有“硬”边缘的普通盒子(最好是与盒子形成鲜明对比的背景)。

Here's an approach I've heard of, which may yield some success:

  • Perform edge detection on your image to translate it into a black and white image, whereby edges are shown as black pixels.
  • Now create a histogram to record the frequency of black pixels in each vertical column of pixels in the image. The theory here is that a high frequency value in the histogram in or around one bucket is indicative of a vertical edge, which could be the edge of a crate.

You could also consider a second histogram to measure pixels on each row of the image.

Obviously this is a fairly simple approach and is highly dependent on "simple" input; i.e. plain boxes with "hard" edges against a blank background (preferable a background that contrasts heavily with the box).

Smile简单爱 2024-10-28 03:38:03

您不需要成熟的计算机视觉库来检测相机前面是否有板条箱。您只需拍摄快照并制作颜色直方图(简单)。要捕获快照,请查看此处:

http://msdn.microsoft.com/ en-us/library/dd742882%28VS.85%29.aspx

You dont need a full-blown computer-vision library to detect if there is a crate or no crate in front of the camera. You can just take a snapshot and make a color-histogram (simple). To capture the snapshot take a look here:

http://msdn.microsoft.com/en-us/library/dd742882%28VS.85%29.aspx

诗笺 2024-10-28 03:38:03

这里有很多变量,包括环境照明和视野中任何其他活动可能发生的变化。考虑实施 Canny 边缘检测器(OpenCV 和英特尔性能基元也有)来寻找感兴趣形状的轮廓。如果您知道框的位置,您也许可以对感兴趣区域中的像素进行求和。如果盒子可以出现在视野中的任何地方,这就更具挑战性。

Lots of variables here including any possible changes in ambient lighting and any other activity in the field of view. Look at implementing a Canny edge detector (which OpenCV has and also Intel Performance Primitives have as well) to look for the outline of the shape of interest. If you then kinda know where the box will be, you can perhaps sum pixels in the region of interest. If the box can appear anywhere in the field of view, this is more challenging.

孤独陪着我 2024-10-28 03:38:03

这不是您应该从 Java 开始的事情。当我遇到此类问题时,我会从 Matlab(OpenCV 库)或类似的东西开始,看看解决方案是否可以在那里工作,然后将其移植到 Java。

为了回答你的问题,我做了类似的事情,将“参考”图像(在你的情况下没有板条箱)与当前图像进行异或,然后要么处理直方图(右侧的聚集像素意味着很大的差异),要么只是将可见像素和将它们与阈值进行比较。 XOR 并不是很精确,但速度很快。

我的观点是,我花了 2 个小时来安装 Scilab 和工具包并编写概念证明。在 Java 中我需要花费两天的时间,如果第一个解决方案不起作用,每个附加算法(已经在 Mat-/Scilab 中完成)又需要几个小时。恕我直言,您从错误的角度解决了这个问题。

如果 Java/C++ 实际上只是一些无关紧要的简单工具,那么放弃它们并使用 Scilab 或其他一些 Matlab 克隆 - 原型设计和微调会快得多。

This is not something you should start in Java. When I had this kind of problems I would start with Matlab (OpenCV library) or something similar, see if the solution would work there and then port it to Java.

To answer your question I did something similar by XOR-ing the 'reference' image (no crate in your case) with the current image then either work on the histogram (clustered pixels at right means large difference) or just sum the visible pixels and compare them with a threshold. XOR is not really precise but it is fast.

My point is, it took me 2hrs to install Scilab and the toolkits and write a proof of concept. It would have taken me two days in Java and if the first solution didn't work each additional algorithm (already done in Mat-/Scilab) another few hours. IMHO you are approaching the problem from the wrong angle.

If really Java/C++ are just some simple tools that don't matter then drop them and use Scilab or some other Matlab clone - prototyping and fine tuning would be much faster.

一抹苦笑 2024-10-28 03:38:03

对象检测涉及两个部分。一是特征提取,二是相似度计算。板条箱的一些明显特征是几何、边缘、纹理等......

因此您可以找到一些算法来从板条箱图像中提取这些特征。然后将这些特征与您的训练样本图像进行比较。

There are 2 parts involved in object detection. One is feature extraction, the other is similarity calculation. Some obvious features of the crate are geometry, edge, texture, etc...

So you can find some algorithms to extract these features from your crate image. Then comparing these features with your training sample images.

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