title: Opencv Mat conversion to QByteArray
body: <p>I need to transfer image from my Qt application (with OpenCv) to my web application through websocket. 
  The transfer with binary data works great. I have a test web app which sends an image to my Qt app and the image (QbyteArray) is directly re-sends to my web app. That's work.</p>
  
  <p>My problem now, is to receive my QByteArray, convert it to Mat image. Or convert my Mat array to QbyteArray in order to send it.</p>
  
  <p>So I tried to convert QByteArray to Mat : </p>
  
  <pre><code>Mat imgbuf = Mat(200, 200, CV_8UC3, message.data);
  Mat matImg = imdecode(imgbuf, CV_LOAD_IMAGE_ANYCOLOR);
  </code></pre>
  
  <p>Imgbuf is not empty but the imdecode method returns an empty Mat.</p>
  
  <p>And I also tried to convert Mat to QbyteArray (the most important for me) :</p>
  
  <pre><code>cv::resize(img, img, Size(200, 200));
  std::vector&lt;float&gt; array;
  if (img.isContinuous()) {
      array.assign((float*)img.datastart, (float*)img.dataend);
  }
  else {
      for (int i = 0; i &lt; img.rows; ++i) {
          array.insert(array.end(), (float*)img.ptr&lt;uchar&gt;(i),(float*)img.ptr&lt;uchar&gt;(i) + img.cols);
      }
  }
  
  QByteArray ImgByte((char*)array.data(), array.size());
  
  server-&gt;sendBinary(ImgByte);
  </code></pre>
  
  <p>Here ImgByte isn't empty but I have nothing on my Html page...</p>
  
  <p>Here the code for test web app :</p>
  
  <pre><code>function handleReceive(message) {
       // canvas    
       var c = resultCanvas = document.getElementById('result');  
       var ctx = c.getContext('2d');
       var imageData = ctx.createImageData(200, 200);
       var pixels = imageData.data;
  
       var buffer = new Uint8Array(message.data);
       for (var i=0; i &lt; pixels.length; i++) {
            pixels[i] = buffer[i];
       }
       console.log(imageData);
       ctx.putImageData(imageData, 0, 0);
  }
  </code></pre>