Advertisement
Guest User

Untitled

a guest
Jul 22nd, 2017
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.66 KB | None | 0 0
  1. #define ATTRIBUTES_PER_SAMPLE (16*16*3)
  2. // Assumes training data (1000, 16x16x3) are in training_data
  3. // Assumes training classifications (1000, 1) are in training_classifications
  4.  
  5. // All inputs are numerical. You can change this to reflect your data
  6. Mat var_type = Mat(ATTRIBUTES_PER_SAMPLE + 1, 1, CV_8U );
  7. var_type.setTo(Scalar(CV_VAR_NUMERICAL) ); // all inputs are numerical
  8.  
  9. // Output is a category; this is classification, not regression
  10. var_type.at<uchar>(ATTRIBUTES_PER_SAMPLE, 0) = CV_VAR_CATEGORICAL;
  11.  
  12. // Train the classifier
  13. CvRTrees* rtree = new CvRTrees;
  14. rtree->train(training_data, CV_ROW_SAMPLE, training_classifications,
  15. Mat(), Mat(), var_type);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement