You've already got the data in the right format; all that's left is to instantiate a CvRTrees object and perform your prediction.
The documentation for Random Trees v2.3 can be found here. You'll also want to look at the CvStatModel::train()
documentation, which actually has the description of most of the parameters for CvRTree::train
. Tom referenced a good complete example in comments that you should use.
Along with your data, you'll need a Mat to specify the type of each of your attributes. This Mat has one row for each input attribute, and one additional row for the output type (so 16x16x3 + 1 rows, in your case).
Optionally, you can use a CvRTParams object to specify parameters like number of trees, max depth, etc. I use the defaults in the example below.
If you like, you can pass in valIdx and sampleIdx Mats that specify which attributes and which data rows, respectively, to use for training. This could be useful for selection training/validation data without doing a bunch of gymnastics to get them in separate Mats.
Here's a quick example:
#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);