title: How to convert Mat to byte array in android opencv?
body: <p>Step 1: I was converted Mat to byte array using below method</p>
  
  <pre><code>MatOfByte matOfByte = new MatOfByte();
    Imgcodecs.imencode(".png", mRgba, matOfByte); 
     byteArray = matOfByte.toArray();
  </code></pre>
  
  <p>its efficiently converted byte array values. But when i calculate time taken for this method is 100 - 200ms and above. </p>
  
  <p>Step2: I did one sample in Opencv Facedetection, i pass a byte array value to native i have FPS count is 1.314. </p>
  
  <p>Step3: Before that for my analyse I didn't call native just i return a same capture Mat i have FPS count 13 to 18 frames per second.</p>
  
  <p>Step4: Problem i found is Mat to Byte array conversion it takes more time to convert so i didn't get any improvements in FPS.</p>
  
  <p>Step5: I change conversion method </p>
  
  <pre><code>byte[] return_buff = new byte[(int) (mRgba.total() * 
                  mRgba.channels())];
  mRgba.get(0, 0, return_buff);
  </code></pre>
  
  <p>this method cannot take more time to convert but when i was Pass a byte array to native, channels value changed to 1 and image not found. </p>
  
  <p>Is there any other solution to convert byte array, please justify me, thank you</p>