title: efficient way to create an opencv mat from std::vector
body: <p>If I want to create an opencv mat from a std::vector I use the following function:</p>
  
  <pre><code>Mat::Mat(int rows, int cols, int type, void* data, size_t step=AUTO_STEP)
  
  vector&lt;double&gt; myData;
  cv::Mat m(100, 100, 1, myData.data(), myData.size())
  </code></pre>
  
  <p>This constructor does not copy the data, so when the vector is temp and we return the mat, mat has invalid data so I return a clone of it which is inefficient.</p>
  
  <pre><code>void doProcessing()
  {
    //...
    Mat m = getMat(12.2, 144, ...);
    cout&lt;&lt; m.at&lt;double&gt;(0,0);
    //...
  }
  
  Mat getMat(some parameters){
    vector&lt;double&gt; myData;
    //do some processing on parameters and myData
    cv::Mat m(100, 100, 1, myData.data(), myData.size());
    return m.clone();
  }
  </code></pre>
  
  <p>is there any better way? how can I use std::move to only move the pointer?
  I don't want to copy the data, just moving vector data pointer in O(1).</p>