1 | initial version |
you've got the wrong flag here:
Imgproc.cvtColor(image, image_2, CvType.CV_8UC1); // does not what you expect
which probably should have been:
Imgproc.cvtColor(image, image_2, Imgproc.COLOR_BGR2GRAY);
please have another look at the Imgproc module
2 | No.2 Revision |
you've got the wrong flag flags here:
Imgproc.cvtColor(image, image_2, CvType.CV_8UC1); // please do not preallocate it, and depth() is wrong
Mat image_2 = new Mat(image.size(), image.depth());
// does not what you expect
Imgproc.cvtColor(image, image_2, CvType.CV_8UC1);
which probably should have been:
Mat image_2 = new Mat(); // leave empty.
Imgproc.cvtColor(image, image_2, Imgproc.COLOR_BGR2GRAY);
please have another look at the Imgproc module