Convert Mat to MatOfByte in Android
I got a Mat from OpenCV's camera. And I want to convert it to a MatOfByte or a byte[]. But I got runtime error in my code:
Mat mGray = new Mat();
capture.retrieve(mGray, Highgui.CV_CAP_ANDROID_GREY_FRAME);
MatOfByte mGrayByte = new MatOfByte(mGray);
I got the error:
10-04 12:50:35.470: E/AndroidRuntime(25086): java.lang.IllegalArgumentException: Incomatible Mat 10-04 12:50:35.470: E/AndroidRuntime(25086): at org.opencv.core.MatOfByte.<init>(MatOfByte.java:29)
The error line is:
MatOfByte mGrayByte = new MatOfByte(mGray);
For what purpose do you want to use MatOfByte? Maybe there are better solutions.
I want to pass the Image to Tesseract-OCR api with byte data array. Because I don't want to convert it to bitmap.
http://fossies.org/dox/tesseract-3.01/group__AdvancedAPI.html#gaa463622111f3b11d8fca5863709cc699