title: opencv C++ create Mat object from android NV21 image data buffer
body: <p>I have implemented an android application that starts the camera and send all the preview buffer down to native components using JNI interface. Since the preview data is in NV21 image format, I need to create a cv::Mat instance from it. I searched for it and found the below solution:</p>
  
  <pre><code>cv::Mat _yuv(height, width, CV_8UC1, (uchar *) imagebuffer);
  
  where imagebuffer is jbyte*
  </code></pre>
  
  <p>However, don't get the expected image in the output image. It's all filled with some random lines etc. Does anyone know how exactly I can do it?</p>