int main()
{
	// Read reference image
	cv::Mat image= cv::imread("../images/waves.jpg");
	if (!image.data)
		return 0;

	// Display image
	cv::namedWindow("Query Image");
	cv::imshow("Query Image",image);

	ImageComparator c;
	c.setReferenceImage(image);

	// Read an image and compare it with reference
	cv::Mat input= cv::imread("../images/dog.jpg");
	cout << "waves vs dog: " << c.compare(input) << endl;

	// Read an image and compare it with reference
	input= cv::imread("../images/marais.jpg");
	cout << "waves vs marais: " << c.compare(input) << endl;

	// Read an image and compare it with reference
	input= cv::imread("../images/bear.jpg");
	cout << "waves vs bear: " << c.compare(input) << endl;

	// Read an image and compare it with reference
	input= cv::imread("../images/beach.jpg");
	cout << "waves vs beach: " << c.compare(input) << endl;

	// Read an image and compare it with reference
	input= cv::imread("../images/polar.jpg");
	cout << "waves vs polar: " << c.compare(input) << endl;

	// Read an image and compare it with reference
	input= cv::imread("../images/moose.jpg");
	cout << "waves vs moose: " << c.compare(input) << endl;

	// Read an image and compare it with reference
	input= cv::imread("../images/lake.jpg");
	cout << "waves vs lake: " << c.compare(input) << endl;

	// Read an image and compare it with reference
	input= cv::imread("../images/fundy.jpg");
	cout << "waves vs fundy: " << c.compare(input) << endl;

	cv::waitKey();
	return 0;
}
Example #2
0
int main()
{
    Mat image = imread("/media/OS/Users/gsc/My Documents/ABOOK/Information Retrieval/hw/hw1/Query/flower.jpg");
    if(!image.data)
        return -1;
    imshow("flower",image);
    //cout<<"图像像素数为:"<<image.cols*image.rows<<endl;

    ImageComparator c;
    c.setRefrenceImage(image);

    //跟自己比
    Mat input = imread("/media/OS/Users/gsc/My Documents/ABOOK/Information Retrieval/hw/hw1/Query/flower.jpg");
//    imshow("自己",input);
    cout<<"flower VS flower:"<<c.compare(input)<<endl;

    input = imread("/media/OS/Users/gsc/My Documents/ABOOK/Information Retrieval/hw/hw1/Query/result/google.jpg");
    imshow("Google",input);
    cout<<"flower VS First of Google:"<<c.compare(input)<<endl;

    input = imread("/media/OS/Users/gsc/My Documents/ABOOK/Information Retrieval/hw/hw1/Query/result/baidu.jpg");
    imshow("baidu",input);
    cout<<"flower VS First of baidu:"<<c.compare(input)<<endl;

    input= cv::imread("/media/OS/Users/gsc/My Documents/ABOOK/Information Retrieval/hw/hw1/Query/result/sogou.jpg");
    imshow("sogou",input);
    cout<<"flower VS First of sogou:"<<c.compare(input)<<endl;


    waitKey(0);
    return 0;
}