1

I am having a little bit of trouble creating a haar classifier. I need to build up a classifier to detect cars. At the moment I made a program in python that reads in an image, I draw a rectangle around the area the object is in, Once the rectangle is drawn, it outputs the image name, the top left and bottom right coordinates of the rectangle. I am unsure of where to go from here and how to actually build up the classifier. Can anyone offer me any help?

EDIT*

I am looking for help on how to use the opencv_traincascade. I have looked at the documentation but I can't quite figure out how to use it to create the xml file to be used in the detection program.

1 Answer 1

1

This looks like you need to determine what features you would like to train your classifier on first, as using the haar classifier it benefits from those extra features. From there you will need to train the classifier, this requires you to get a lot of images that have cars and those that do not have cars in them and then run it over this and having it tweak the average it is shooting for in order to classify to the best it can with your selected features.

To get a better classifier you will have to figure out the order of your features and the optimal order you put them together to further dive into the object and determine if it is in fact what you are looking for. Again this will require a lot of examples for your particular features and your problem as a whole.

Sign up to request clarification or add additional context in comments.

5 Comments

That's what I was doing with the program I wrote. I took videos of cars and an empty car park. I used ffmpeg to generate all of the images. In my program I use the rectangle to highlight what I am looking for. What I need to now is how do I go about using the opencv_traincascade. I can't make heads or tails of it.
Ah, ok, I would add the specific about using opencv_traincascade into your question to make it more specific. To add on about the opencv it looks like you need to individually tag specific images as negative and positive images. This is done through a info.dat file (can be changed) and a positive file that gives the attributes about that file. Then this is run through the opencv_traincascade to create your values to then use in your classifier.
So instead of having the text file. When I put a rectangle around the object in the image. I create a .dat file and place the coordinates and if it's positive or negative in that file?
No, I used info.data out of personal naming convention. What you need to do is have a directory of negative samples and a directory of positive samples. The info.dat tells the trainer what files it should use so in a real application you would have: negatives.dat that would hold all the negative sample image locations, and another positives.dat that has the locations for the positive images. The docs opencv_traincascade describes this much more concisely.
Sorry. I get it now thanks for the help I'll get working on that now. hopefully it will work alright.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.