Subversion Repositories OpenCV2-Cookbook

Rev

Rev 3 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
3 PointedEar 1
/*------------------------------------------------------------------------------------------*\
2
   This file contains material supporting chapter 4 of the cookbook:  
3
   Computer Vision Programming using the OpenCV Library.
4
   by Robert Laganiere, Packt Publishing, 2011.
5
 
6
   This program is free software; permission is hereby granted to use, copy, modify,
7
   and distribute this source code, or portions thereof, for any purpose, without fee,
8
   subject to the restriction that the copyright notice may not be removed
9
   or altered from any source or altered source distribution.
10
   The software is released on an as-is basis and without any warranties of any kind.
11
   In particular, the software is not guaranteed to be fault-tolerant or free from failure.
12
   The author disclaims all warranties with regard to this software, any use,
13
   and any consequent failure, is purely the responsibility of the user.
14
 
15
   Copyright (C) 2010-2011 Robert Laganiere, www.laganiere.name
16
\*------------------------------------------------------------------------------------------*/
17
 
18
#include <iostream>
19
using namespace std;
20
 
5 PointedEar 21
#include <opencv2/core/core.hpp>
22
#include <opencv2/highgui/highgui.hpp>
3 PointedEar 23
 
24
#include "imageComparator.h"
25
 
26
int main()
27
{
28
        // Read reference image
29
        cv::Mat image= cv::imread("../waves.jpg");
30
        if (!image.data)
31
                return 0;
32
 
33
        // Display image
34
        cv::namedWindow("Query Image");
35
        cv::imshow("Query Image",image);
36
 
37
        ImageComparator c;
38
        c.setReferenceImage(image);
39
 
40
        // Read an image and compare it with reference
41
        cv::Mat input= cv::imread("../dog.jpg");
42
        cout << "waves vs dog: " << c.compare(input) << endl;
43
 
44
        // Read an image and compare it with reference
45
        input= cv::imread("../marais.jpg");
46
        cout << "waves vs marais: " << c.compare(input) << endl;
47
 
48
        // Read an image and compare it with reference
49
        input= cv::imread("../bear.jpg");
50
        cout << "waves vs bear: " << c.compare(input) << endl;
51
 
52
        // Read an image and compare it with reference
53
        input= cv::imread("../beach.jpg");
54
        cout << "waves vs beach: " << c.compare(input) << endl;
55
 
56
        // Read an image and compare it with reference
57
        input= cv::imread("../polar.jpg");
58
        cout << "waves vs polar: " << c.compare(input) << endl;
59
 
60
        // Read an image and compare it with reference
61
        input= cv::imread("../moose.jpg");
62
        cout << "waves vs moose: " << c.compare(input) << endl;
63
 
64
        // Read an image and compare it with reference
65
        input= cv::imread("../lake.jpg");
66
        cout << "waves vs lake: " << c.compare(input) << endl;
67
 
68
        // Read an image and compare it with reference
69
        input= cv::imread("../fundy.jpg");
70
        cout << "waves vs fundy: " << c.compare(input) << endl;
71
 
72
        cv::waitKey();
73
        return 0;
5 PointedEar 74
}