Reputation: 181
ImageManipulationsActivity.VIEW_MODE_BINARY:
capture.retrieve(mRgba, Highgui.CV_CAP_ANDROID_COLOR_FRAME_RGBA);
Mat binary = new Mat();
Imgproc.cvtColor(mRgba,binary, Imgproc.COLOR_RGBA2GRAY, 4);
int size = (int) binary.total() * binary.channels();
double[] buff = new double[size];
binary.get(0, 0, buff);
for(int i = 0; i < size; i++)
{
buff[i] = (buff[i] >= 0) ? 1 : 0;
}
Mat bv = new Mat(binary.size(), CvType.CV_8U);
bv.put(0, 0, buff);
Imgproc.cvtColor(binary, mRgba, Imgproc.COLOR_GRAY2RGBA, 4);
break;
Above code is used for binarize gray image in opencv4android, but until know that's not work for me, i copy above code from here, in above code, i try :
If you have something to suggest, please tell me. I don't know what i wrong from above code, it's no error, but when i install the app and run it, it always forceclose.
this is logcat from app :
FATAL EXCEPTION: Thread-10 java.lang.UnsupportedOperationException: Mat data type is not compatible: 0 at org.opencv.core.Mat.get(Mat.java:2042) at org.opencv.samples.imagemanipulations.ImageManipulationsView.processFrame(ImageManipulationsView.java:158) at org.opencv.samples.imagemanipulations.SampleCvViewBase.run(SampleCvViewBase.java:99) at org.opencv.samples.imagemanipulations.ImageManipulationsView.run(ImageManipulationsView.java:195) at java.lang.Thread.run(Thread.java:1019)
Upvotes: 2
Views: 3786
Reputation: 181
The Default Type of Mat is CV_8UC1 whether single channels or 3 channels (BGR) -Basic Structure OpenCV-
Upvotes: 3