Ask Your Question
0

What is the correct way to convert a Mat to a Bitmap ?

asked 2015-01-10 13:39:06 -0600

sup gravatar image

updated 2015-01-10 14:02:21 -0600

I am working with OpenCV Android, I need to use a Java OCR library that works on bitmaps. Please, how can I convert my RGBA Mat (which by the way comes from Mat org.opencv.android.CameraBridgeViewBase.CvCameraViewFrame.rgba()) to a Bitmap ? Thanks

EDIT : I think I found the answer in the Utils class. But how to properly initialize the type of the Bitmap object so that it will be compatible with my Mat ?

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
0

answered 2015-01-11 09:22:33 -0600

You are right, using matToBitmap from Utils class is the easiest way.

You can see the OpenCV Android examples for usages, something like this:

Mat myMat = mListener.onCameraFrame(frame);

Utils.matToBitmap(myMat, myBitmap);

According to the documentation:

  • mat is a valid input Mat object of the types 'CV_8UC1', 'CV_8UC3' or 'CV_8UC4'.
  • bmp is a valid Bitmap object of the same size as the Mat and of type 'ARGB_8888' or 'RGB_565'.
edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2015-01-10 13:39:06 -0600

Seen: 16,301 times

Last updated: Jan 10 '15