paella/src/DetectionAndMatching/main.cpp

91 lines
2.9 KiB
C++

////////////////////////////////////////////////////////////////////////////////
//
// Paella
// Copyright (C) 2015 - Thomas FORGIONE, Emilie JALRAS, Marion LENFANT, Thierry MALON, Amandine PAILLOUX
// Authors :
// Thomas FORGIONE
// Emilie JALRAS
// Marion LENFANT
// Thierry MALON
// Amandine PAILLOUX
//
// This file is part of the project Paella
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
//
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it freely,
// subject to the following restrictions:
//
// 1. The origin of this software must not be misrepresented;
// you must not claim that you wrote the original software.
// If you use this software in a product, an acknowledgment
// in the product documentation would be appreciated but is not required.
//
// 2. Altered source versions must be plainly marked as such,
// and must not be misrepresented as being the original software.
//
// 3. This notice may not be removed or altered from any source distribution.
////////////////////////////////////////////////////////////////////////////////
#include "DetectionAndMatching/DetectionAndMatching.hpp"
#include <iostream>
#include <vector>
#include <opencv2/imgproc/imgproc.hpp>
#include <opencv2/core/core.hpp>
#include <opencv2/features2d/features2d.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/calib3d/calib3d.hpp>
int main( int argc, char** argv )
{
cv::Mat img_1;
cv::Mat img_2;
cv::Mat masque_1;
cv::Mat masque_2;
cv::Size s1;
cv::Size s2;
if( argc != 5 )
{
if (argc==3) {
img_1 = cv::imread( argv[1], CV_LOAD_IMAGE_GRAYSCALE );
img_2 = cv::imread( argv[2], CV_LOAD_IMAGE_GRAYSCALE );
s1 = img_1.size();
s2 = img_2.size();
masque_1 = cv::Mat::ones(s1.height,s1.width, CV_8UC1);
masque_2 = cv::Mat::ones(s2.height,s2.width, CV_8UC1);
} else {
readme(); return -1;
}
}
if (argc!=3)
{
img_1 = cv::imread( argv[1], CV_LOAD_IMAGE_GRAYSCALE );
img_2 = cv::imread( argv[2], CV_LOAD_IMAGE_GRAYSCALE );
masque_1 = cv::imread( argv[3], CV_LOAD_IMAGE_GRAYSCALE );
masque_2 = cv::imread( argv[4], CV_LOAD_IMAGE_GRAYSCALE );
}
//std::cout << masque_1 << std::endl;
if( !img_1.data || !img_2.data )
{
std::cout<< " --(!) Error reading images " << std::endl;
return -1;
}
std::vector<std::pair<cv::Point, cv::Point>> matchPoints;
cv::Mat masque_1_resize = resizeMask(masque_1,img_1.size());
cv::Mat masque_2_resize = resizeMask(masque_2,img_2.size());
matchPoints = detectAndMatch(img_1, img_2, masque_1_resize, masque_2_resize);
return 0;
}