title: Convert Mat to vector <float> and Vector<float> to mat in opencv
body: <p>i want to Convert Mat to vector  and Vector to mat in opencv .</p>
  
  <p>my code : </p>
  
  <pre><code>     void mat_to_vector(Mat in,vector&lt;float&gt; &amp;out){
  
          for (int i=0; i &lt; in.rows; i++) {
               for (int j =0; j &lt; in.cols; j++){
                  //unsigned char temp;
  
                  //file &lt;&lt; Dst.at&lt;float&gt;(i,j)  &lt;&lt; endl;
                   out.push_back(in.at&lt;float&gt;(i,j));
              }
          }
  
      }
  void vector_to_mat(vector&lt;float&gt; in, Mat out,int cols , int rows){
      for (int i=rows-1; i &gt;=0; i--) {
               for (int j =cols -1; j &gt;=0; j--){
  
                   out.at&lt;float&gt;(i,j) = in.back();
                   in.pop_back();
                  //file &lt;&lt; Dst.at&lt;float&gt;(i,j)  &lt;&lt; endl;
                  // dst_temp.push_back(Dst.at&lt;float&gt;(i,j));
              }
          }
  }
  </code></pre>
  
  <p>Above codes are slow.
  are there  faster solutions?</p>