【问题标题】:denoise_TVL1 Sizes of input arguments do not matchdenoise_TVL1 输入参数的大小不匹配
【发布时间】:2022-01-01 20:30:20
【问题描述】:

我正在尝试在灰度视频上实现全变分算法。据我了解,这种方法(denoise_TVL1)正在使用该算法。但我得到“输入参数的大小不匹配”CvException。你能帮我理解问题是什么吗?

我有这个列表作为类实例:

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: error: (-209:Sizes of input arguments do not match) 该操作既不是'array op array'(其中数组具有相同的大小和相同的通道数),也不是'array op函数“cv::arithm_op”中的标量和“标量运算数组” ]

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

【问题讨论】:

    标签: java opencv javafx


    【解决方案1】:

    我注意到 Mat 类型是 CV_8UC3。将类型转换为 CV_8UC1 后,它现在可以工作了。

    【讨论】:

      猜你喜欢
      • 2018-01-31
      • 1970-01-01
      • 1970-01-01
      • 2016-01-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多