matchselectionselector.hpp 1.57 KB
Newer Older
1 2 3 4 5
#ifndef CVVISUAL_MATCH_SELECTION_SELECTOR
#define CVVISUAL_MATCH_SELECTION_SELECTOR

#include <vector>

Maksim Shabunin's avatar
Maksim Shabunin committed
6
#include "opencv2/features2d.hpp"
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30

#include "matchselection.hpp"
#include "../registerhelper.hpp"

namespace cvv{ namespace qtutil{

/**
 * @brief this class can use diffrent MatchSelection
 * you can register functions which take a std::vector<cv::DMatch> as argument.
 */
class MatchSelectionSelector:public MatchSelection,public RegisterHelper<MatchSelection,std::vector<cv::DMatch>>{

	Q_OBJECT

public:
	/**
	 * @brief the constructor
	 */
	MatchSelectionSelector(const std::vector<cv::DMatch>& univers,QWidget * parent=nullptr);

	/**
	 * @brief select matches of the given selection
	 * @return the selected matches
	 */
31
    std::vector<cv::DMatch> select(const std::vector<cv::DMatch>& selection) CV_OVERRIDE;
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69

public slots:
	/**
	 * @brief emits the signal remove with this.
	 */
	void removeMe()
		{emit remove(this);}

signals:
	/**
	 * @brief this signal contains a KeyPointSelectionSelector which should be removed. Normally the argumen is this.
	 */
	void remove(MatchSelectionSelector*);

private slots:

	/**
	 * @brief swap the current MatchSelection if the user choose another.
	 */
	virtual void changeSelector();

private:
	MatchSelection * selection_=nullptr;
	std::vector<cv::DMatch> univers_;
	QLayout *layout_;
};
template <class Selection>
bool registerMatchSelection(const QString &name)
{
	return MatchSelectionSelector::registerElement(
	    name, [](std::vector<cv::DMatch> univers)
	{
		    return std::unique_ptr<MatchSelection>{ new Selection{univers}};
	});
}
}}

#endif