简体   繁体   English

在Android上使用OpenCV在实时摄像机预览中进行实时徽标检测

[英]Real time logo detection in live camera preview with OpenCV on Android

I am new to computer vision but I am trying to code an android app which does the following: 我是计算机视觉的新手,但我尝试编写一个执行以下操作的android应用程序:

Get the live camera preview and try to detect one logo in that (i have the logo in my resources). 获取实时摄像机预览,并尝试检测其中的一个徽标(我的资源中包含徽标)。 In real-time. 实时。 Draw a rect around the logo if found. 如果找到徽标,请在徽标周围绘制一个矩形。 If there is no match, dont draw the rectangle. 如果没有匹配项,请不要绘制矩形。

I already tried a couple of things including template-matching and feature detection using ORB. 我已经尝试了几件事,包括模板匹配和使用ORB进行功能检测。

Why that didnt work: 为什么不起作用:

Template-matching: Issues with scaling and rotation. 模板匹配:缩放和旋转问题。 I tried a multi scale variant of it but a) the performance was really bad and b) the rectangle was of course always shown trying to search for the image. 我尝试了它的多尺度变体,但是a)性能真的很差,b)当然总是显示矩形以尝试搜索图像。 There was no way to actually confirm in the code if the logo was found or not. 无法在代码中实际确认是否找到徽标。

ORB feature detection: Also pretty slow (5-6 fps) but it worked ok-ish. ORB功能检测:速度也很慢(5-6 fps),但效果还不错。 The other problem was that also i never could be sure if the logo was in the picture or not. 另一个问题是我也永远无法确定徽标是否在图片中。 ORB found random matches even if the logo was not in the picture. 即使徽标不在图片中,ORB也会发现随机匹配项。

Like I said, I am very new to this. 就像我说的那样,我对此很陌生。 I would appreciate the help on what would be the best way to achieve: 我将很高兴为您提供最好的实现方式:

  • Confirm if a picture A (around 200x200 pixels) is in ROI of camera picture (around 600x600 pixels). 确认照片A(大约200x200像素)是否在相机照片的ROI(大约600x600像素)中。

  • This shouldnt take longer than 50ms per frame. 每帧时间不应超过50ms。 I dont know if thats even possible though. 我不知道那是否可能。 So if a correct way to do this would take a bit longer than that, I would just do the work in a seperate thread and only analyze like every fifth camera frame or so. 因此,如果执行此操作的正确方法花费的时间更长,那么我将在单独的线程中进行工作,并且仅像每五个摄像头帧那样分析一次。

Would appreciate any hints or code examples on how to achieve that. 将不胜感激有关如何实现该目标的任何提示或代码示例。 Thank you! 谢谢!

With logo detection, I would highly recommend using OpenCV HaarClassifier. 对于徽标检测,我强烈建议您使用OpenCV HaarClassifier。 It is easy to generate training samples from a collection of images of the logo, or one logo image with many distortions. 很容易从徽标图像的集合或一个徽标图像失真很多的情况下生成训练样本。

If you can use a few rules like the minimum and maximum size of the logo to be detected, and possible regions on the image where it can appear, you can run the detector at a speed better than you mention with ORB. 如果可以使用一些规则,例如要检测的徽标的最小和最大尺寸以及图像上可能出现徽标的区域,则可以以比ORB提到的更好的速度运行检测器。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM