How to properly convert a byte array to a matrix?

asked 2016-04-25 03:52:44 -0600

I've posted a question on Stack Overflow just before the weekend. The gist of it is that I want to change the the bytes from the onPitctureTaken() to a OpenCV matrix, but my app freezes when I try to do this. This is what I have at the moment:

@Override
public void onPictureTaken(byte[] bytes, Camera camera) {
  Log.w(TAG, "picture taken!");

  if (bytes != null) {
    Bitmap image = BitmapFactory.decodeByteArray(bytes, 0, bytes.length);
    Mat matImage = new Mat();

    // This is where my app freezes.
    Utils.bitmapToMat(image, matImage);

    Log.w(TAG, matImage.dump());
  }

  mCamera.startPreview();
  mCamera.setPreviewCallback(this);
}

I've also tried several "solutions" I've found on stack overflow to similar problems, without any success.

link to the original Stack Overflow post: http://stackoverflow.com/questions/36...

edit retag flag offensive close merge delete