Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define ATTRIBUTES_PER_SAMPLE (16*16*3)
- // Assumes training data (1000, 16x16x3) are in training_data
- // Assumes training classifications (1000, 1) are in training_classifications
- // All inputs are numerical. You can change this to reflect your data
- Mat var_type = Mat(ATTRIBUTES_PER_SAMPLE + 1, 1, CV_8U );
- var_type.setTo(Scalar(CV_VAR_NUMERICAL) ); // all inputs are numerical
- // Output is a category; this is classification, not regression
- var_type.at<uchar>(ATTRIBUTES_PER_SAMPLE, 0) = CV_VAR_CATEGORICAL;
- // Train the classifier
- CvRTrees* rtree = new CvRTrees;
- rtree->train(training_data, CV_ROW_SAMPLE, training_classifications,
- Mat(), Mat(), var_type);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement