Ask Your Question
0

Help with Random Trees

asked 2013-03-11 07:00:25 -0600

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.

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
4

answered 2013-03-11 07:45:40 -0600

berak gravatar image

updated 2013-03-11 08:07:42 -0600

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

edit flag offensive delete link more

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 ( 2013-03-11 10:30:38 -0600 )edit

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

piaoye123 gravatar imagepiaoye123 ( 2013-09-01 21:53:10 -0600 )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 ( 2013-09-02 03:32:53 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2013-03-11 07:00:25 -0600

Seen: 1,004 times

Last updated: Sep 01 '13