124 lines
5.7 KiB
C++
124 lines
5.7 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.
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
#ifndef DETECTIONANDMATCHING_HPP
|
|
#define DETECTIONANDMATCHING_HPP
|
|
|
|
#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>
|
|
|
|
/////////////////////////////////////////////////////////
|
|
/// \defgroup detectionandmatching Detection and Matching module
|
|
///
|
|
/// Contains all the functions to compute the keypoints and
|
|
/// match them on differents images. The algorithm used
|
|
/// to detect the keypoints and compute the descriptors is BRISK.
|
|
/// The matches are computed with a brute force matcher provided
|
|
/// by OpenCV.
|
|
///
|
|
/// This program is meant to be used like this
|
|
/// \code
|
|
/// bin/DetectionAndMatching pathImg1 pathImg2 pathMask1 pathMask2
|
|
/// \endcode
|
|
/////////////////////////////////////////////////////////
|
|
|
|
/////////////////////////////////////////////////////////
|
|
/// \ingroup detectionandmatching
|
|
/// \brief prints readme
|
|
/////////////////////////////////////////////////////////
|
|
void readme();
|
|
|
|
/////////////////////////////////////////////////////////
|
|
/// \ingroup detectionandmatching
|
|
/// \brief detects the keypoints on the two
|
|
/// inputs images with BRISK and matches the keypoints
|
|
/// \param img_1 first image
|
|
/// \param img_2 second image
|
|
/// \param masque_1 mask of img_1
|
|
/// \param masque_2 mask of img_2
|
|
/// \return a vector containing the matches (pair of Point)
|
|
/////////////////////////////////////////////////////////
|
|
std::vector<std::pair<cv::Point,cv::Point>> detectAndMatch(cv::Mat const& img_1, cv::Mat const& img_2, cv::Mat const& masque_1, cv::Mat const& masque_2);
|
|
|
|
/////////////////////////////////////////////////////////
|
|
/// \brief Resize the mask of an image
|
|
/// \param the mask to resize and the size of the image
|
|
/// \return the mask resized
|
|
/// \pre the original image need to be in landscape
|
|
////////////////////////////////////////////////////////
|
|
cv::Mat resizeMask(cv::Mat const& mask, cv::Size const& sizeImage);
|
|
|
|
/////////////////////////////////////////////////////////
|
|
/// \ingroup detectionandmatching
|
|
/// \brief filter the matches in order to
|
|
/// keep the symmetric one
|
|
/// \param matches1 contains indexes of matched points : queryIdx for image1 and trainIdx for image 2
|
|
/// \param matches2 contains indexes of matched points : queryIdx for image2 and trainIdx for image 1
|
|
/// \return symetric matches
|
|
////////////////////////////////////////////////////////
|
|
std::vector< cv::DMatch > symetricFilter( std::vector< cv::DMatch > const& matches1, std::vector< cv::DMatch > const& matches2);
|
|
|
|
///////////////////////////////////////////////////////
|
|
/// \ingroup detectionandmatching
|
|
/// \brief filter the matches in order to be ordered
|
|
/// \param symetricMatches matches that are filtered by the symetricFilter function
|
|
/// \param keypoints_1 keypoints of the first image
|
|
/// \param keypoints_2 keypoints of the second image
|
|
/// \param proportion
|
|
/// \return matches filtered with the order constraint
|
|
/// \see symetricFilter
|
|
////////////////////////////////////////////////////////
|
|
std::vector< cv::DMatch > orderConstraintFilter (std::vector< cv::DMatch > const& symetricMatches, std::vector<cv::KeyPoint> const& keypoints_1, std::vector<cv::KeyPoint> const& keypoints_2, float proportion);
|
|
|
|
////////////////////////////////////////////////////////
|
|
/// \ingroup detectionandmatching
|
|
/// \brief add a constraint on the distance between descriptors
|
|
/// \param distanceThreshold maximum distance between two descriptors
|
|
/// \param matches matches to filter
|
|
/// \return matches filtered by distance between descriptors
|
|
/////////////////////////////////////////////////////////
|
|
std::vector< cv::DMatch > thresholdFilter (float distanceThreshold, std::vector< cv::DMatch > const& matches);
|
|
|
|
////////////////////////////////////////////////////////
|
|
/// \ingroup detectionandmatching
|
|
/// \brief filter using epipolar geometry, and the fundamental matrix to filter strange points
|
|
/// \param keypoints_1 keypoints on the first image
|
|
/// \param keypoints_2 keypoints on the second image
|
|
/// \param correctedMatches the matches in input
|
|
/// \return matches filtered by geometric criteria
|
|
///////////////////////////////////////////////////////
|
|
std::tuple<std::vector<cv::DMatch>, std::vector<cv::KeyPoint>, std::vector<cv::KeyPoint>> geometricFilter ( std::vector<cv::KeyPoint> const& keypoints_1, std::vector<cv::KeyPoint> const& keypoints_2, std::vector< cv::DMatch > const& correctedMatches);
|
|
|
|
#endif // DETECTIONANDMATCHING_HPP
|