Skip to content
Advertisement

denoise_TVL1 Sizes of input arguments do not match

I am trying to implement total variation algorithm on a grayscale video. As far as I understand this method(denoise_TVL1) is using that algorithm. But I get “Sizes of input arguments do not match” CvException. Could you help me to understand what the problem is?

I have this list as class instance:

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()));

Exact output:
Exception in thread “JavaFX Application Thread” CvException [org.opencv.core.CvException: cv::Exception: OpenCV(4.5.1) C:buildmaster_winpack-bindings-win64-vc14-staticopencvmodulescoresrcarithm.cpp:669: error: (-209:Sizes of input arguments do not match) The operation is neither ‘array op array’ (where arrays have the same size and the same number of channels), nor ‘array op scalar’, nor ‘scalar op array’ in function ‘cv::arithm_op’ ]

It says inputs dont match but they are always the same, especially with if condition, i always send only the first frame as list.

Advertisement

Answer

I noticed that Mat type was CV_8UC3. It works now after converting type to CV_8UC1.

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement