How to train Decision Trees? How to fill TrainData with Images?
Hello OpenCV Community,
after you helped me a lot with my Cascade Classifier problems, i have a new question about decision trees (C++).
I want to train Decision Trees to recognize Persons. I red the official Implementation and all forum themes i could find about this topic, but i still dont know how to train my decision tree.
The function cv::ml::train() wants cv::ml::TrainData() as argument. How do i become my positiv and negativ images in the array of cv::ml::TrainData()???
Does somebody has an example Code of the Training of his Decision/ Random or Boosting Tree? (Doesnt matter if its Face Recognition or something like that)
Thank you a lot, Kind regards, Derrick
sample in opencv
@LBerger thanks for your answer. I actually had red this Code, but i don't really get it completely. So i cant transfer it to my problem.
The Code transfers a vector<points> to a Mat and then into TrainData. Where should i put positive and negative Trainingsimages.
Sorry, i am pretty new...
Look for trainedPointsMarkers in onMouse function currentClass (0 or 1) is pushed in vector. Data are prepared using prepare_train_data() function. In this function you have trainedPoints and trainedPointsMarkers which are used to prepare Ptr<traindata>
@LBerger I don't get that either. I'm Sorry. 400 lines uncommented Code is like a foreign language for me.
i just wanna put positive Images (e.g. face) and negative Images (e.g. no faces) into the cv::ml::TrainData and train des Decision Tree. (like a CascadeClassifier) Please correct me if i am complete wrong and DTrees cant be trained like that.
Sorry example is not exactly for your problem. you should follow this tutorials.
@LBerger First Thank you for your patience with me!
This is the traincascade tutorial, i trained a CascadeClassifier with that. But i dont get how to use it for Decision Trees. Can I use it for Decision Trees or is there something comparable for Decision Trees?
@DerrickB, no, that's a completely seperate process.
also, do you need detection (person or not, 2 class), or recognition) (who is it, multi-class) ?
then note, that opencv's ml models can't do a full detection, they cannot give you the location of a found object, only say , if whole images are same or not.