title: How can I initialize a cv::Mat with data from a float array
body: <p>I need to create a <code>cv::Mat</code> variable that is initialized with my data from a <code>float *</code> array.
  This should be basic, but I'm having trouble figuring it out.</p>
  
  <p>I have the code:</p>
  
  <pre><code>float *matrixAB = &lt;120 floating point array created elsewhere&gt;;
  cv::Mat cv_matrixAB = cv::Mat(12, 10, CV_32F, &amp;matrixAB);
  </code></pre>
  
  <p>but <code>cv_matrixAB</code> never contains <code>float</code> values, and more importantly doesn't match the data contained in <code>matrixAB</code>.</p>
  
  <p>If I change the line to:</p>
  
  <pre><code>cv::Mat cv_matrixAB = cv::Mat(12, 10, CV_32F, matrixAB);
  </code></pre>
  
  <p>then the <code>cv_matrixAB.data</code> are all <code>0</code>. I have also tried using <code>CV_64F</code> as the type, but I see the same behaivor.</p>
  
  <p><strong>Can anyone help me identify where I am going wrong?</strong> According to the <code>cv::Mat</code> constructor documentation, I should be able to provide my data in the form of a <code>float *</code> array.</p>
  
  <p><strong>Update:</strong> a little more info here:
  Even the following code does not work. The <code>printf</code> displays <code>63</code>, which of course is not a value in <code>dummy_query_data</code>.</p>
  
  <pre><code>float dummy_query_data[10] = { 1, 2, 3, 4,
                                 5, 6, 7, 8 };
  cv::Mat dummy_query = cv::Mat(2, 4, CV_32F, dummy_query_data);
  printf("%f\n", (float)dummy_query.data[3]);
  </code></pre>