0
votes

I am doing a android project where i have to detect a logo(logo can be of different contrast,hue or saturation),for that i am using histogram comparison of OpenCV-2.3.1 for android.

The steps that i am following is as follows;

1)Calculate the hist value of stored image

private List<Integer> histSize;
   private List<Float> ranges;


  histSize.add(50);
    histSize.add(60);
    histSize.add(10);

    ranges.add(0f);
    ranges.add(256f);

    ranges.add(0f);
    ranges.add(180f);

    ranges.add(0f);
    ranges.add(256f);

    channels.add(0);
    channels.add(1);
    channels.add(2);


hsv_base1=new Mat();
Imgproc.cvtColor(image1,hsv_base1, Imgproc.COLOR_BGR2HSV);
hsv_base.add(hsv_base1);
Imgproc.calcHist(hsv_base, channels,new Mat(), hist_base, histSize, ranges,false);

2) Then i am cropping the captured image every frame. The size of the cropped image is exactly same as of the stored image and calculating its histogram value using the same method as above.

3) Comparing the stored hist value of both the images

double base_test2 = Imgproc.compareHist(hist_base1,hist_baseCamera1,Imgproc.CV_COMP_CHISQR);

i get good value of comparehist. However problem is sometime it gives good values for some random captured images, i.e. unwanted.

So now am planning to use some other methods with histogram comparison. My logo consists of a circle .

My question is:: Is there any method so that i can find the captured image consists of circle exactly of same size as that of the circle of the stored logo.

Or any other method that i should use,or i can play with the stored value of channels ,ranges,histSize?

I had used template matching before ,its very slow and pretty difficult for the images of same size

I'd appreciate any light on this.

1

1 Answers

0
votes

There definetly are other methods. In fact, comparing histograms is a very vague choice of method, as you have already discovered. (A multitude of pictures can have the same histogram as seen on figure below)

A roughly created de- and re construction of a greylevel picture

I see that you are currently working on a logo with color, but the simpler approach often leads to more better results. So you should consider if you could work with greyscale images instead (this does not mean that your logo cannot have colors, it just means that you would have to segment the image before processing it). A simpler approach often also results in better faster runtime, due to the lesser amount of data in the image.

If you have done segmentation, you will be able to threshold your image and do BLOB analysis (Binary Large OBject), the algorithm that you need depends on your figure of interest, and the methods and description of these can be found at the OpenCV documentation.

My guess is that the matchShapes() function could serve you well. But you will need an understanding of image processing that lies a bit past the use of histograms.

You would of course have to find wrappers for the Android version of OpenCV.

P.S. Remember to include enviroment, programming language, and platform in the tags is posible.