(-215:Assertion failed) _src1.sameSize(_src2) in function 'norm'

I tried the face similar code, I’m still new to cpp, but an error appears as shown in the title

my code

#include <iostream>
#include <opencv2/opencv.hpp>
using namespace std; 
int main()
{ 
    try
    {
        cv::Mat face1 = cv::imread("face1.jpg", 1); 
        cv::Mat face2 = cv::imread("face3.jpg", 1);
        double similarity = cv::norm(face1, face2, cv::NORM_L2);

        cout << "Tingkat kemiripan wajah: " << similarity << endl;
    }
    catch (cv::Exception e)
    {
        cout << e.msg << endl;
    }

    return 0;
}

script to compile

c++ ./face.cpp  -lopencv_core -lopencv_highgui -lopencv_imgcodecs -lopencv_imgproc

Error Message:

OpenCV error: (-215:Assertion failed) _src1.sameSize(_src2) in function 'norm'

how to solve this problem?

If an image’s size is not the same as another’s, the fix should be obvious…

2 Likes