Ask Your Question
0

Help with Random Trees

asked Mar 11 '13

imran gravatar image

Can anyone point me to any examples or tutorials on how to use random trees in OpenCV, other than the opencv documentation. I would like to use it for hand detection in images. The idea is to use Local Binary Patterns to extract features and a Random Forest to classify whether a hand is detected or not.

It will be used along with skin detection to reduce areas that are not a hand.

Any advice will be highly appreciated.

Preview: (hide)

1 answer

Sort by » oldest newest most voted
4

answered Mar 11 '13

berak gravatar image

updated Mar 11 '13

here is, what i used recently for the random forest:

Mat train_features; // 1 row for each lbp feature, float !
Mat train_labels    // 1 row (containing 1 float element with the id) for each feature

CvRTrees tree;      
CvRTParams cvrtp; // set params, play with those!! (the numbers were for my problem)
cvrtp.max_depth = 25; 
cvrtp.min_sample_count = 6;
cvrtp.max_categories = 2;
cvrtp.term_crit.max_iter = 100;

tree.train ( train_features , CV_ROW_SAMPLE , train_labels,cv::Mat(),cv::Mat(),cv::Mat(),cv::Mat(),cvrtp );

// later:
float id = tree.predict(sample); // where sample is a lbp feature , again

but again, since your problem is more a binary classification, not a multi-class one, another classifier, like svm or dtree might give better results.

if you look at the lbp-FaceRecognizer , it's not even using any of those, just a plain chi-square based knn. (and seemingly, results did not improve using svm or such)

please have a look here, for a nice tut on machinelearning in opencv

Preview: (hide)

Comments

1

Thanks berak! This is definitely helpful. It seems very simple, I will give it a go. The tutorial also seems very helpful. Thanks again for helping me out.

imran gravatar imageimran (Mar 11 '13)edit

I want to user LBP + Random forest,can you help me? I don't konw how to create LBP feature

piaoye123 gravatar imagepiaoye123 (Sep 2 '13)edit

@paioye, with questions on LBP and Random Forests, please stick to your new question. Also accept this answer if it helps you out for the Random Trees part.

StevenPuttemans gravatar imageStevenPuttemans (Sep 2 '13)edit

Question Tools

1 follower

Stats

Asked: Mar 11 '13

Seen: 1,012 times

Last updated: Sep 01 '13