How to compare 2 images using OpenCV c++ [closed]

asked 2018-05-01 13:45:20 -0600

anushkawellawaya@gmail.com gravatar image

I want to compare two images.

edit retag flag offensive reopen merge delete

Closed for the following reason not a real question by berak
close date 2018-05-01 16:40:17.762230

Comments

Check out their absolute difference, with the function absdiff:

#include <opencv2/opencv.hpp>
using namespace cv;
#pragma comment(lib, "opencv_world331.lib") // or whatever version you're using...

#include <iostream>
using namespace std;


int main(void)
{
    Mat master = imread("frame1.png");
    Mat current = imread("frame2.png");

    if (master.empty() || current.empty())
    {
        cout << "Read error" << endl;
        return -1;
    }

    Mat a;

    absdiff(master, current, a);

    imshow("a", a);

    waitKey();

    return 0;
}
sjhalayka gravatar imagesjhalayka ( 2018-05-01 13:48:43 -0600 )edit