denoise_TVL1 输入参数的大小不匹配

denoise_TVL1 Sizes of input arguments do not match

我正在尝试对灰度视频实施全变分算法。据我了解,此方法(denoise_TVL1)正在使用该算法。但是我得到“输入参数的大小不匹配”CvException。你能帮我了解问题出在哪里吗?

我将此列表作为 class 实例:

public static List<Mat> test = new ArrayList<Mat>();
// src is Mat obj given as parameter
Mat resizedSrc = new Mat();
Size scaleSize = new Size(960,540);
Imgproc.resize(src, resizedSrc, scaleSize);
Mat dst = new Mat(scaleSize, resizedSrc.type());

// On first frame I add resized image to my list, because denoise_TVL1 requirest list as input
// I also tried it without if condition
if(test.isEmpty()){
            test.add(resizedSrc);
}
//On this line I get CvException
Photo.denoise_TVL1(test, dst);

// Then I return filtered image
MatOfByte buffer2 = new MatOfByte();
Imgcodecs.imencode(".png", dst, buffer2);       
return new Image(new ByteArrayInputStream(buffer2.toArray()));

精确输出:
线程“JavaFX 应用程序线程”CvException [org.opencv.core.CvException: cv::Exception: OpenCV(4.5.1) C:\build\master_winpack-bindings-win64-vc14-static\opencv\modules\core\src\arithm.cpp:669: 错误: (-209:Sizes of input arguments不匹配)操作既不是 'array op array'(其中数组具有相同的大小和相同的通道数),也不是 'array op scalar',也不是函数 'cv::arithm_op' 中的 'scalar op array' ]

它说输入不匹配,但它们总是相同的,尤其是在 if 条件下,我总是只发送第一帧作为列表。

我注意到垫子类型是 CV_8UC3。在将类型转换为 CV_8UC1.

后,它现在可以工作了