0

I am new to computer vision but I am trying to code an android app which does the following:

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.

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. 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. 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.

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).

  • This shouldnt take longer than 50ms per frame. 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!

marco56
  • 165
  • 1
  • 2
  • 11
  • If you add test images and your current output, it'd help us in finding the problem! – Rick M. Aug 30 '17 at 07:30
  • @RickM. Ill see if I can make some tonight. I dont think they would help in my case though as im not having a configuration/finetuning problem but more like a general problem on whats the best way to achieve what im looking for. Just imagine I have the Volkswagen logo as a picture and I what i want is basically to be sure if the Volkswagen logo is in my camera picture as well. The camera images wont be very tricky as I will let the user know to place the logo in a small rectangle on the screen. Still, I have to kinda make sure thats really the Volkswagen logo on the camera screen. – marco56 Aug 30 '17 at 07:36
  • The pictures would still help in finding whether template matching is a viable option or not and why _ORB seems to be working ok-ish_. To find the quality of the matches from ORB after using `findHomography` using `RANSAC` you might want to look [here](https://stackoverflow.com/questions/42505299/finding-if-two-images-are-similar/42515173#42515173) – Rick M. Aug 30 '17 at 07:40
  • @RickM. Ok I will provide pictures tonight. The biggest problem for me with ORB/FAST/BRISK etc is the performance. My application shouldnt on < 20fps. After reading a bit into it, I think HaarClassifiers could be really the way to go for me, as Totoro suggested. – marco56 Aug 30 '17 at 08:09

1 Answers1

2

With logo detection, I would highly recommend using 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.

Totoro
  • 3,398
  • 1
  • 24
  • 39
  • 1
    Thanks a lot. I actually got it working already. Not perfect yet, but Im getting there. I have a follow up question. In order to make my Classifier better I feel i need more sample images of the logo. Do you know a quick and easy way to generate randomly rotated and distorted pictures of one picture? – marco56 Aug 30 '17 at 14:45
  • Did you try OpenCV's sample generator? It is described here. http://note.sonots.com/SciSoftware/haartraining.html#w0a08ab4 – Totoro Aug 30 '17 at 21:15
  • 1
    Yea, just found out about it 30 min ago. Seems to work quite nice. Thanks for your help! – marco56 Aug 30 '17 at 21:27