Hi,
On android we need to do this :
Mat rgba = inputFrame.rgba();
// get the full picture
Mat rgbaInnerWindow = rgba.submat(0, height, 0, width);
// Procces it
Imgproc.cvtColor(rgbaInnerWindow, mIntermediateMat, Imgproc.COLOR_RGB2GRAY);
Imgproc.Canny(mIntermediateMat, mIntermediateMat, 15, 40, 3, true);
// ??????????
rgbaInnerWindow.release();
// convert rgbaInnerWindow to bitmap
Utils.matToBitmap(rgba, bitmap);
So if a want to convert the "mIntermediateMat" (output of the canny) a got a crash on Utils.matToBitmap
Utils.matToBitmap(mIntermediateMat, bitmap);
08-09 12:33:56.602 4104-4748/com.example.user.opengl_touch E/cv::error(): OpenCV Error: Assertion failed (src.dims == 2 && info.height == (uint32_t)src.rows && info.width == (uint32_t)src.cols) in void Java_org_opencv_android_Utils_nMatToBitmap2(JNIEnv*, jclass, jlong, jobject, jboolean), file /Volumes/Linux/builds/master_pack-android/opencv/modules/java/generator/src/cpp/utils.cpp, line 97
08-09 12:33:56.602 4104-4748/com.example.user.opengl_touch E/org.opencv.android.Utils: nMatToBitmap catched cv::Exception: /Volumes/Linux/builds/master_pack-android/opencv/modules/java/generator/src/cpp/utils.cpp:97: error: (-215) src.dims == 2 && info.height == (uint32_t)src.rows && info.width == (uint32_t)src.cols in function void Java_org_opencv_android_Utils_nMatToBitmap2(JNIEnv*, jclass, jlong, jobject, jboolean)
08-09 12:33:56.603 4104-4748/com.example.user.opengl_touch E/AndroidRuntime: FATAL EXCEPTION: Thread-68692
Process: com.example.user.opengl_touch, PID: 4104
CvException [org.opencv.core.CvException: /Volumes/Linux/builds/master_pack-android/opencv/modules/java/generator/src/cpp/utils.cpp:97: error: (-215) src.dims == 2 && info.height == (uint32_t)src.rows && info.width == (uint32_t)src.cols in function void Java_org_opencv_android_Utils_nMatToBitmap2(JNIEnv*, jclass, jlong, jobject, jboolean)
]
at org.opencv.android.Utils.nMatToBitmap2(Native Method)
at org.opencv.android.Utils.matToBitmap(Utils.java:123)
at org.opencv.android.Utils.matToBitmap(Utils.java:132)
at com.example.user.opengl_touch.OpenGLES20Activity.onCameraFrame(OpenGLES20Activity.java:749)
at org.opencv.android.CameraBridgeViewBase.deliverAndDrawFrame(CameraBridgeViewBase.java:391)
at org.opencv.android.JavaCameraView$CameraWorker.run(JavaCameraView.java:349)
at java.lang.Thread.run(Thread.java:818)
On other suport they use IMSHOW but they is no such thing in OpenCV android.
How to convert "mIntermediateMat" to Bitmap ??
Thanks a lot
↧