I am interested in creating my own haar cascade xml file, for use with python, to detect a certain logo (let's say it's the apple logo).
I have tried following the instructions at http://docs.opencv.org/trunk/doc/user_guide/ug_traincascade.html and http://note.sonots.com/SciSoftware/haartraining.html
Problem is, although I get a valid functioning cascade file, it does not detect anything. specifically, when I try to detect the object inside the original image used to create it, it is not detected even then.
I already tried resizing the image, or simply putting it in a larger context by inserting it in a picture.
what am I doing wrong?
at shell, I run:
opencv_createsamples -img original.jpg -bg negatives.dat -vec samples_set.vec -w 48 -h 48
opencv_traincascade -bg negatives.dat -data mycascade -vec samples_set.vec -w 48 -h 48
which seems to work fine, creating a cascade file. Then, in python:
import cv2
cascade2 = cv2.CascadeClassifier('mycascade.xml')
cv2Image = cv2.imread('original.jpg')
cascade2.detectMultiScale(cv2Image)
and the detection comes up empty. I did try to test with a "standard" xml that comes with python and it works, so something is wrong with mine.
I hope you have found your answer by now that it has been 2 years since you've asked your question! anyways I'll share what I know for anybody else who might have the same question. One of the best and fully explained tutorials on this matter is from Coding-Robin and I have personally learned a lot from there. one thing to remember is you should not use the same image which was involved in creating the haar cascade, and the reason is that it simply is already classified as a positive (or negative) sample, so trying to process it is pretty useless.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With