Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

error Sizes of input arguments do not match while using Core.compare

I am trying below code to compare 2 images. 

   Mat img1 = Imgcodecs.imread(filename1, Imgcodecs.CV_LOAD_IMAGE_GRAYSCALE);
   Mat img2 = Imgcodecs.imread(filename2, Imgcodecs.CV_LOAD_IMAGE_GRAYSCALE);
   Mat result = new Mat();
    Core.compare(img1,img2,result,Core.CMP_NE);
    int val = Core.countNonZero(result);

    if(val == 0) {
        //
        System.out.println("Duplicate Image");
    } else {
        //Different Image
        System.out.println("Different Image");
    }

But get below error

OpenCV Error: Sizes of input arguments do not match (The operation is neither 'array op array' (where arrays have the same size and the same type), nor 'array op scalar', nor 'scalar op array') in compare, file /tmp/opencv3-20161019-20369-7r0q5p/modules/core/src/arithm.cpp, line 1253
Exception in thread "main" CvException [org.opencv.core.CvException: cv::Exception: /tmp/opencv3-20161019-20369-7r0q5p/modules/core/src/arithm.cpp:1253: error: (-209) The operation is neither 'array op array' (where arrays have the same size and the same type), nor 'array op scalar', nor 'scalar op array' in function compare
]
    at org.opencv.core.Core.compare_0(Native Method)
    at org.opencv.core.Core.compare(Core.java:1071)

Please suggest.

error Sizes of input arguments do not match while using Core.compare

I am trying below code to compare 2 images. 

   Mat img1 = Imgcodecs.imread(filename1, Imgcodecs.CV_LOAD_IMAGE_GRAYSCALE);
   Mat img2 = Imgcodecs.imread(filename2, Imgcodecs.CV_LOAD_IMAGE_GRAYSCALE);
   Mat result = new Mat();
    Core.compare(img1,img2,result,Core.CMP_NE);
    int val = Core.countNonZero(result);

    if(val == 0) {
        //
        System.out.println("Duplicate Image");
    } else {
        //Different Image
        System.out.println("Different Image");
    }

But get getting below error

OpenCV Error: Sizes of input arguments do not match (The operation is neither 'array op array' (where arrays have the same size and the same type), nor 'array op scalar', nor 'scalar op array') in compare, file /tmp/opencv3-20161019-20369-7r0q5p/modules/core/src/arithm.cpp, line 1253
Exception in thread "main" CvException [org.opencv.core.CvException: cv::Exception: /tmp/opencv3-20161019-20369-7r0q5p/modules/core/src/arithm.cpp:1253: error: (-209) The operation is neither 'array op array' (where arrays have the same size and the same type), nor 'array op scalar', nor 'scalar op array' in function compare
]
    at org.opencv.core.Core.compare_0(Native Method)
    at org.opencv.core.Core.compare(Core.java:1071)

Please suggest.