Python training custom object detector using the HOG + Linear SVM
Hello.
Im using Python and OpenCV on my raspberry pi 3 for some kind of object recognition.
I want to do this by applying the HOG + Linear SVM framework for object detection.
My problem is, that i need a dataset for training my detector.I would like to orientate on these five steps(from Pyimagesearch):
1. Extract HOG features from your positive training set.
2. Compute HOG feature vectors from your negative training set.
3. Train your Linear SVM.
4. Apply hard-negative mining.
5. Re-train your Linear SVM using the positive samples, negative samples, and hard-negative samples.
Has someone already made this and could help me? Is there some kind of documentation available? I would appreciate a step by step tutorial, but i already searched and found none.
I hope someone can help me. Kind regards.
this already has steps 1-3
Thank you. Did you use this too?
why are you asking ?
I wanted to know if it worked reliably.
it all depends on your data, and your object (which is ?)
also, yes, adding steps 4 and 5 would improve it.
please clarify: do you want to train a HOGDetector (and use detectMultiScale() later) or an SVM classifier (with HOG features) ?
I´m not sure what is the best for implementation in videostreams. I made the example for the pedestrian detector: hog = cv2.HOGDescriptor(); hog.setSVMDetector( cv2.HOGDescriptor_getDefaultPeopleDetector() ). I think i want to do it this way with my objects (specific traffic signs). Back to your question i think i want to use detectMultiScale()).
I'm trying to code it myself in Python, if im successful i post the code here. Do you know, what is the Input Format for "hog.setSVMDetector(...)"? To compare and test, how can i run the Train_HOG.cpp on my raspberry pi or virtualbox?
"Do you know, what is the Input Format for "hog.setSVMDetector(...)"? "
it's the SVM's single supportvector, with
-rho
appended, see here"how can i run the Train_HOG.cpp" -- maybe
cmake -DBUILD_EXAMPLES=ON
(but that will build all examples ..., if you don't want that, try to build trainHOG as a standalone progOkay i installed trainHog as standalone and ran it like you said it in this post (http://answers.opencv.org/question/96925/how-to-use-train_hogcpp/). I got the followin error:
OpenCV Error: Assertion failed (0 <= roi.x && 0 <= roi.width && roi.x + roi.width <= m.cols && 0 <= roi.y && 0 <= roi.height && roi.y + roi.height <= m.rows) in Mat, file /home/pyimagesearch/opencv/modules/core/src/matrix.cpp, line 495 terminate called after throwing an instance of 'cv::Exception' what(): /home/pyimagesearch/opencv/modules/core/src/matrix.cpp:495: error: (-215) 0 <= roi.x && 0 <= roi.width && roi.x + roi.width <= m.cols && 0 <= roi.y && 0 <= roi.height && roi.y + roi.height <= m.rows in function Mat
Aborted (core dumped)