输出图像中的Grabcut OpenCV Android错误
我将OpenCV与Android一起使用,并在图像上执行Grabcut以进行前景提取,我获得了预期的输出,但输出图像具有蓝色色调,而不是提供的原始图像?这个问题的解决办法是什么 我附加了我目前正在使用的代码输出图像中的Grabcut OpenCV Android错误,android,opencv,image-processing,Android,Opencv,Image Processing,我将OpenCV与Android一起使用,并在图像上执行Grabcut以进行前景提取,我获得了预期的输出,但输出图像具有蓝色色调,而不是提供的原始图像?这个问题的解决办法是什么 我附加了我目前正在使用的代码 private Mat performGrabCut(Mat image) { Mat firstMask = new Mat(); Mat foregroundModel = new Mat(); Mat backgroundModel = new Ma
private Mat performGrabCut(Mat image)
{
Mat firstMask = new Mat();
Mat foregroundModel = new Mat();
Mat backgroundModel = new Mat();
Mat mask;
Mat source = new Mat(1, 1, CvType.CV_8U, new Scalar(3.0));
Mat destination = new Mat();
Rect rect = new Rect(topLeft, bottomRight);
Imgproc.grabCut(image, firstMask, rect, backgroundModel, foregroundModel, 1, 0);
Core.compare(firstMask, source, firstMask, Core.CMP_EQ);
Mat foreground = new Mat(image.size(), CvType.CV_8UC3, new Scalar(255,255,255));
image.copyTo(foreground, firstMask);
return foreground;
}
您可能对频道顺序有问题,OpenCV按顺序使用BGR,而其他LIB通常使用RGB。在android中如何做到这一点?使用OpenCV的cvt颜色搭配
Imgproc.cvtColor(src、dst、Imgproc.color\u BGR2RGB)代码>@y300谢谢。您的解决方案解决了您的问题“>这里给出了类似的问题。您可能对频道顺序有问题,OpenCV按顺序使用BGR,而其他LIB通常使用RGB。在android中如何做到这一点?使用OpenCV的cvt颜色搭配Imgproc.cvtColor(src、dst、Imgproc.color\u BGR2RGB);
@y300谢谢。您的解决方案做了手脚。您的问题的解决方案“>在类似问题中给出。