Watershed example in [android] opencv

android, image, image-processing, opencv

Solution

The error states that the input image for `watershed()` must be an 8-bit 3-channels image. After calling `cvtColor()`, print the number of channels of `threeChannel`. Don't be surprised if it outputs 1.

Pass `mRgba` directly to `watershed()` and see what happens. One of my previous answers have working code using watershed, you can use that for testing.

Problem

Currently trying ``` <code> public Mat onCameraFrame(CvCameraViewFrame inputFrame) { mRgba = inputFrame.rgba(); Imgproc.Canny(mRgba, markers, 80, 90); Mat threeChannel = new Mat(); Imgproc.cvtColor(mRgba, threeChannel, Imgproc.COLOR_BGR2GRAY); Imgproc.watershed(threeChannel, markers); return threeChannel; } </code> ``` However, it fails with ``` CvException [org.opencv.core.CvException: /home/reports/ci/slave/50-SDK/opencv/modules/imgproc/src/segmentation.cpp:147: error: (-210) Only 8-bit, 3-channel input images are supported in function void cvWatershed(const CvArr*, CvArr*) ``` Could you advise how to appropriately use the markers from a Canny/Sobel edge detection to feed a Watershed algorithm? Android-specifics would be greatly helpful as this is my first Android project.

Original source

Related problems