1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
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
#include <QVBoxLayout>
#include <algorithm>
#include <iostream>
#include "keypointintervallselection.hpp"
#include "../../util/util.hpp"
namespace cvv{ namespace qtutil{
KeyPointIntervallSelector::KeyPointIntervallSelector(std::vector<cv::KeyPoint> keypoints, QWidget *parent):
KeyPointSelection{parent},
layout_{nullptr},
selector_{nullptr},
valueChooser_{nullptr},
keypoints_{keypoints}
{
auto layout=util::make_unique<QVBoxLayout>();
auto valueChooser=util::make_unique<KeyPointValueChooser>();
valueChooser_=valueChooser.get();
connect(valueChooser_,SIGNAL(valueChanged()),this,SLOT(changeSelecteValue()));
layout->setContentsMargins(0, 0, 0, 0);
layout_=layout.get();
layout->addWidget(valueChooser.release());
setLayout(layout.release());
changeSelecteValue();
}
std::vector<cv::KeyPoint> KeyPointIntervallSelector::select(const std::vector<cv::KeyPoint> &selection)
{
return selector_->select(selection, [&](const cv::KeyPoint& key)
{return this->valueChooser_->getChoosenValue(key);}
);
}
void KeyPointIntervallSelector::changeSelecteValue()
{
if(selector_){
layout_->removeWidget(selector_);
selector_->deleteLater();
}
double min=-1;
double max=0;
for(auto& key:keypoints_)
{
min=std::min(valueChooser_->getChoosenValue(key),min);
max=std::max(valueChooser_->getChoosenValue(key),max);
}
auto selector=util::make_unique<IntervallSelector>(min,max);
selector_=selector.get();
connect(&(selector->signalSettingsChanged()),SIGNAL(signal()),this,SIGNAL(settingsChanged()));
layout_->addWidget(selector.release());
}
}}