title: Trivial random forest with OpenCV doesn't work and isn't the same as sklearn
body: <p>I'm trying to get the simplest example of random forest to work. The training data is 2 points {0,0} with a label 0 and {1,1} with a label 1. The sample to predict is {2,2}. OpenCV returns 0 rather than 1. Here is the OpenCV code in C++ (<code>main.cpp</code>):</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;opencv2/core/core.hpp&gt;
  #include &lt;opencv2/ml/ml.hpp&gt;
  
  using namespace std;
  using namespace cv;
  
  int main(int argc, char const *argv[]) {
    cout &lt;&lt; " hi \n";
    float trainingData[2][2] = { {0.0, 0.0}, {1.0, 1.0}};
    Mat training_data(2, 2, CV_32FC1, trainingData);
    float trainingClass[2] = {0.0,1.0};
    Mat training_class(2, 1, CV_32FC1, trainingClass);
    CvRTrees rtree;
    rtree.train(training_data, CV_ROW_SAMPLE, training_class);
    float sampleData[2] = {2.0, 2.0};
    Mat sample_data(2, 1, CV_32FC1, sampleData);
    cout &lt;&lt; rtree.predict(sample_data) &lt;&lt; "  &lt;-- predict\n";
    return 0;
  }
  </code></pre>
  
  <p>cmake file:</p>
  
  <pre><code>cmake_minimum_required(VERSION 2.8)
  project( main )
  find_package( OpenCV REQUIRED )
  add_executable( main main.cpp )
  target_link_libraries( main ${OpenCV_LIBS} )
  </code></pre>
  
  <p>running:</p>
  
  <pre><code>&gt; cmake .;make;./main
   hi 
  0  &lt;-- predict
  </code></pre>
  
  <p>To compare, here is a python's sklearn code (<code>rfc.py</code>):</p>
  
  <pre><code>from sklearn.ensemble import RandomForestClassifier
  X = [[0, 0], [1, 1]]
  Y = [0, 1]
  clf = RandomForestClassifier(n_estimators=10)
  clf = clf.fit(X, Y)
  print clf.predict([[2., 2.]])
  </code></pre>
  
  <p>running:</p>
  
  <pre><code>&gt; python rfc.py 
  [1]
  </code></pre>