1 
2 #include <algorithm>
3 
4 #include <QHBoxLayout>
5 
6 #include "../qtutil/accordion.hpp"
7 #include "../qtutil/matchview/matchscene.hpp"
8 #include "../qtutil/matchview/cvvkeypoint.hpp"
9 #include "../qtutil/matchview/cvvmatch.hpp"
10 #include "../qtutil/matchview/singlecolorkeypointpen.hpp"
11 #include "../qtutil/matchview/matchmanagement.hpp"
12 #include "../qtutil/matchview/matchsettingsselector.hpp"
13 #include "../qtutil/matchview/showinrawviewwidget.hpp"
14 #include "../util/util.hpp"
15 
16 #include "linematchview.hpp"
17 
18 namespace cvv
19 {
20 namespace view
21 {
22 
LineMatchView(std::vector<cv::KeyPoint> leftKeyPoints,std::vector<cv::KeyPoint> rightKeyPoints,std::vector<cv::DMatch> matches,cv::Mat leftIm,cv::Mat rightIm,bool usetrainIdx,QWidget * parent)23 LineMatchView::LineMatchView(std::vector<cv::KeyPoint> leftKeyPoints,
24 			     std::vector<cv::KeyPoint> rightKeyPoints,
25 			     std::vector<cv::DMatch> matches, cv::Mat leftIm,
26 			     cv::Mat rightIm, bool usetrainIdx, QWidget *parent)
27     : MatchView( parent )
28 {
29 	std::vector<cv::KeyPoint> allkeypoints;
30 	for(auto key:rightKeyPoints)
31 	{
32 		allkeypoints.push_back(key);
33 	}
34 
35 	for(auto key:leftKeyPoints){
36 		allkeypoints.push_back(key);
37 	}
38 
39 	auto layout = util::make_unique<QHBoxLayout>();
40 	auto accor = util::make_unique<qtutil::Accordion>();
41 	auto matchscene = util::make_unique<qtutil::MatchScene>(leftIm, rightIm);
42 	auto matchmnt = util::make_unique<qtutil::MatchManagement>(matches);
43 	auto keyPointmnt = util::make_unique<qtutil::KeyPointManagement>(allkeypoints);
44 
45 	qtutil::MatchScene *matchscene_ptr = matchscene.get();
46 	int updateAreaDelay=std::min(std::max(matches.size(),
47 					      std::max(leftKeyPoints.size(),
48                                    rightKeyPoints.size()))/(std::size_t)10,(std::size_t)50);
49 	matchscene_ptr->getLeftImage().setUpdateAreaDelay(updateAreaDelay);
50 	matchscene_ptr->getRightImage().setUpdateAreaDelay(updateAreaDelay);
51 
52 	matchManagment_ = matchmnt.get();
53 	keyManagment_ = keyPointmnt.get();
54 
55 	connect(&matchscene_ptr->getLeftImage(),SIGNAL(updateMouseHover(QPointF,QString,bool)),
56 		this,SLOT(updateMousHoverOver(QPointF,QString,bool)));
57 	connect(&matchscene_ptr->getRightImage(),SIGNAL(updateMouseHover(QPointF,QString,bool)),
58 		this,SLOT(updateMousHoverOver(QPointF,QString,bool)));
59 
60 	accor->setMinimumWidth(350);
61 	accor->setMaximumWidth(350);
62 
63 	std::vector<qtutil::CVVKeyPoint *> leftKeys;
64 	std::vector<qtutil::CVVKeyPoint *> rightKeys;
65 
66 	accor->insert("Match Settings", std::move(matchmnt));
67 	accor->insert("KeyPoint Settings", std::move(keyPointmnt));
68 	accor->insert("Show selection in rawview window",
69               util::make_unique<qtutil::ShowInRawView>(leftKeyPoints,
70 								 rightKeyPoints,
71 								 matches,
72 								 matchManagment_,
73                                  keyManagment_));
74 
75     accor->insert("Sync Zoom ", matchscene_ptr->getSyncZoomWidget());
76     accor->insert("Left Image ", matchscene_ptr->getLeftMatInfoWidget());
77     accor->insert("Right Image ", matchscene_ptr->getRightMatInfoWidget());
78 
79 	layout->addWidget(accor.release());
80 	layout->addWidget(matchscene.release());
81 
82 	setLayout(layout.release());
83 
84 	for (auto &keypoint : leftKeyPoints)
85 	{
86 		auto key = util::make_unique<qtutil::CVVKeyPoint>(keypoint);
87 		connect(keyManagment_, SIGNAL(settingsChanged(KeyPointSettings &)),
88 			key.get(), SLOT(updateSettings(KeyPointSettings &)));
89 
90 		leftKeys.push_back(key.get());
91 		matchscene_ptr->addLeftKeypoint(std::move(key));
92 	}
93 
94 	for (auto &keypoint : rightKeyPoints)
95 	{
96 		auto key = util::make_unique<qtutil::CVVKeyPoint>(keypoint);
97 		connect(keyManagment_, SIGNAL(settingsChanged(KeyPointSettings &)),
98 			key.get(), SLOT(updateSettings(KeyPointSettings &)));
99 
100 		rightKeys.push_back(key.get());
101 		matchscene_ptr->addRightKeyPoint(std::move(key));
102 	}
103 
104 	for (auto &match : matches)
105 	{
106 		auto cvmatch = util::make_unique<qtutil::CVVMatch>(
107 		    leftKeys.at(match.queryIdx),
108 		    rightKeys.at((usetrainIdx ? match.trainIdx : match.imgIdx)),
109 		    match);
110 
111 		connect(matchManagment_, SIGNAL(settingsChanged(MatchSettings &)),
112 			cvmatch.get(), SLOT(updateSettings(MatchSettings &)));
113 
114 		matchscene_ptr->addMatch(std::move(cvmatch));
115 	}
116 	matchManagment_->updateAll();
117 	keyManagment_->updateAll();
118 }
119 }
120 }
121