title: How to get the Mat object from the Byte[] in openCV android?
body: <p>I am working with OpenCV library in Android.  I have a class which implements <code>PictureCallBack</code>.</p>
  
  <p>The override method <code>onPictureTaken()</code> is as given below,</p>
  
  <pre><code>     @Override
  public void onPictureTaken(byte[] data, Camera camera) {
      Log.i(TAG, "Saving a bitmap to file");
      // The camera preview was automatically stopped. Start it again.
      mCamera.startPreview();
      mCamera.setPreviewCallback(this);
  
      // Write the image in a file (in jpeg format)
      try {
          FileOutputStream fos = new FileOutputStream(mPictureFileName);
          fos.write(data);
          fos.close();
  
      } catch (java.io.IOException e) {
          Log.e("PictureDemo", "Exception in photoCallback", e);
      }
  }
  </code></pre>
  
  <p>As I want image data to be used further in image processing in stead of saving and reloading the image.</p>
  
  <p>What is the most efficient way for getting the Mat object from the Byte array?
  I have already tried these approaches:</p>
  
  <ol>
  <li><p>Don't know what happened to the image.  </p>
  
  <p><code>Mat m=new Mat(); 
     m.put(0,0,data);</code></p></li>
  <li><p>Converting to Bitmap then use <code>bitmapToMat()</code> 
  In this case , red color becomes blue .</p></li>
  </ol>
  
  <p>I also don't have any problem in saving the image for future use,but this leads me an exception because the file not have been generated yet, when I am using the previously stored image.</p>