Ask Your Question

Revision history [back]

click to hide/show revision 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

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