Fixed slow BRISK
git-svn-id: http://find-object.googlecode.com/svn/trunk/find_object@340 620bd6b2-0a58-f614-fd9a-1bd335dccda9
This commit is contained in:
parent
83e932eae3
commit
4347951c57
@ -27,6 +27,10 @@ AddObjectDialog::AddObjectDialog(Camera * camera, const cv::Mat & image, bool mi
|
|||||||
ui_ = new Ui_addObjectDialog();
|
ui_ = new Ui_addObjectDialog();
|
||||||
ui_->setupUi(this);
|
ui_->setupUi(this);
|
||||||
|
|
||||||
|
detector_ = Settings::createFeaturesDetector();
|
||||||
|
extractor_ = Settings::createDescriptorsExtractor();
|
||||||
|
Q_ASSERT(detector_ != 0 && extractor_ != 0);
|
||||||
|
|
||||||
connect(ui_->pushButton_cancel, SIGNAL(clicked()), this, SLOT(cancel()));
|
connect(ui_->pushButton_cancel, SIGNAL(clicked()), this, SLOT(cancel()));
|
||||||
connect(ui_->pushButton_back, SIGNAL(clicked()), this, SLOT(back()));
|
connect(ui_->pushButton_back, SIGNAL(clicked()), this, SLOT(back()));
|
||||||
connect(ui_->pushButton_next, SIGNAL(clicked()), this, SLOT(next()));
|
connect(ui_->pushButton_next, SIGNAL(clicked()), this, SLOT(next()));
|
||||||
@ -50,6 +54,8 @@ AddObjectDialog::AddObjectDialog(Camera * camera, const cv::Mat & image, bool mi
|
|||||||
|
|
||||||
AddObjectDialog::~AddObjectDialog()
|
AddObjectDialog::~AddObjectDialog()
|
||||||
{
|
{
|
||||||
|
delete detector_;
|
||||||
|
delete extractor_;
|
||||||
if(object_)
|
if(object_)
|
||||||
{
|
{
|
||||||
delete object_;
|
delete object_;
|
||||||
@ -272,9 +278,7 @@ void AddObjectDialog::setState(int state)
|
|||||||
{
|
{
|
||||||
// Extract keypoints
|
// Extract keypoints
|
||||||
selectedKeypoints.clear();
|
selectedKeypoints.clear();
|
||||||
cv::FeatureDetector * detector = Settings::createFeaturesDetector();
|
detector_->detect(imgRoi, selectedKeypoints);
|
||||||
detector->detect(imgRoi, selectedKeypoints);
|
|
||||||
delete detector;
|
|
||||||
}
|
}
|
||||||
ui_->objectView->setData(selectedKeypoints, cv::Mat(), imgRoi, Settings::currentDetectorType(), "");
|
ui_->objectView->setData(selectedKeypoints, cv::Mat(), imgRoi, Settings::currentDetectorType(), "");
|
||||||
ui_->objectView->setMinimumSize(roi.width, roi.height);
|
ui_->objectView->setMinimumSize(roi.width, roi.height);
|
||||||
@ -298,9 +302,7 @@ void AddObjectDialog::setState(int state)
|
|||||||
if(keypoints.size())
|
if(keypoints.size())
|
||||||
{
|
{
|
||||||
// Extract descriptors
|
// Extract descriptors
|
||||||
cv::DescriptorExtractor * extractor = Settings::createDescriptorsExtractor();
|
extractor_->compute(ui_->objectView->cvImage(), keypoints, descriptors);
|
||||||
extractor->compute(ui_->objectView->cvImage(), keypoints, descriptors);
|
|
||||||
delete extractor;
|
|
||||||
|
|
||||||
if(keypoints.size() != (unsigned int)descriptors.rows)
|
if(keypoints.size() != (unsigned int)descriptors.rows)
|
||||||
{
|
{
|
||||||
@ -336,10 +338,8 @@ void AddObjectDialog::update(const cv::Mat & image)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Extract keypoints
|
// Extract keypoints
|
||||||
cv::FeatureDetector * detector = Settings::createFeaturesDetector();
|
|
||||||
cv::vector<cv::KeyPoint> keypoints;
|
cv::vector<cv::KeyPoint> keypoints;
|
||||||
detector->detect(cvImage_, keypoints);
|
detector_->detect(cvImage_, keypoints);
|
||||||
delete detector;
|
|
||||||
|
|
||||||
ui_->cameraView->setData(keypoints, cv::Mat(), cvImage_, Settings::currentDetectorType(), "");
|
ui_->cameraView->setData(keypoints, cv::Mat(), cvImage_, Settings::currentDetectorType(), "");
|
||||||
ui_->cameraView->update();
|
ui_->cameraView->update();
|
||||||
|
|||||||
@ -47,6 +47,8 @@ private:
|
|||||||
Camera * camera_;
|
Camera * camera_;
|
||||||
ObjWidget * object_;
|
ObjWidget * object_;
|
||||||
cv::Mat cvImage_;
|
cv::Mat cvImage_;
|
||||||
|
cv::FeatureDetector * detector_;
|
||||||
|
cv::DescriptorExtractor * extractor_;
|
||||||
|
|
||||||
enum State{kTakePicture, kSelectFeatures, kVerifySelection, kClosing};
|
enum State{kTakePicture, kSelectFeatures, kVerifySelection, kClosing};
|
||||||
int state_;
|
int state_;
|
||||||
|
|||||||
@ -51,7 +51,9 @@ MainWindow::MainWindow(Camera * camera, const QString & settings, QWidget * pare
|
|||||||
inliersCurve_(0),
|
inliersCurve_(0),
|
||||||
lowestRefreshRate_(99),
|
lowestRefreshRate_(99),
|
||||||
objectsModified_(false),
|
objectsModified_(false),
|
||||||
tcpServer_(0)
|
tcpServer_(0),
|
||||||
|
detector_(0),
|
||||||
|
extractor_(0)
|
||||||
{
|
{
|
||||||
ui_ = new Ui_mainWindow();
|
ui_ = new Ui_mainWindow();
|
||||||
ui_->setupUi(this);
|
ui_->setupUi(this);
|
||||||
@ -113,6 +115,10 @@ MainWindow::MainWindow(Camera * camera, const QString & settings, QWidget * pare
|
|||||||
ui_->toolBox->getParameterWidget(Settings::kFeature2D_SURF_gpu())->setEnabled(false);
|
ui_->toolBox->getParameterWidget(Settings::kFeature2D_SURF_gpu())->setEnabled(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
detector_ = Settings::createFeaturesDetector();
|
||||||
|
extractor_ = Settings::createDescriptorsExtractor();
|
||||||
|
Q_ASSERT(detector_ != 0 && extractor_ != 0);
|
||||||
|
|
||||||
connect((QDoubleSpinBox*)ui_->toolBox->getParameterWidget(Settings::kCamera_4imageRate()),
|
connect((QDoubleSpinBox*)ui_->toolBox->getParameterWidget(Settings::kCamera_4imageRate()),
|
||||||
SIGNAL(editingFinished()),
|
SIGNAL(editingFinished()),
|
||||||
camera_,
|
camera_,
|
||||||
@ -202,6 +208,8 @@ MainWindow::~MainWindow()
|
|||||||
{
|
{
|
||||||
disconnect(camera_, SIGNAL(imageReceived(const cv::Mat &)), this, SLOT(update(const cv::Mat &)));
|
disconnect(camera_, SIGNAL(imageReceived(const cv::Mat &)), this, SLOT(update(const cv::Mat &)));
|
||||||
camera_->stop();
|
camera_->stop();
|
||||||
|
delete detector_;
|
||||||
|
delete extractor_;
|
||||||
objectsDescriptors_.clear();
|
objectsDescriptors_.clear();
|
||||||
qDeleteAll(objects_.begin(), objects_.end());
|
qDeleteAll(objects_.begin(), objects_.end());
|
||||||
objects_.clear();
|
objects_.clear();
|
||||||
@ -1302,9 +1310,6 @@ void MainWindow::update(const cv::Mat & image)
|
|||||||
|
|
||||||
if(!image.empty())
|
if(!image.empty())
|
||||||
{
|
{
|
||||||
QTime time;
|
|
||||||
time.start();
|
|
||||||
|
|
||||||
//Convert to grayscale
|
//Convert to grayscale
|
||||||
cv::Mat grayscaleImg;
|
cv::Mat grayscaleImg;
|
||||||
if(image.channels() != 1 || image.depth() != CV_8U)
|
if(image.channels() != 1 || image.depth() != CV_8U)
|
||||||
@ -1316,11 +1321,12 @@ void MainWindow::update(const cv::Mat & image)
|
|||||||
grayscaleImg = image;
|
grayscaleImg = image;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QTime time;
|
||||||
|
time.start();
|
||||||
|
|
||||||
// EXTRACT KEYPOINTS
|
// EXTRACT KEYPOINTS
|
||||||
cv::FeatureDetector * detector = Settings::createFeaturesDetector();
|
|
||||||
std::vector<cv::KeyPoint> keypoints;
|
std::vector<cv::KeyPoint> keypoints;
|
||||||
detector->detect(grayscaleImg, keypoints);
|
detector_->detect(grayscaleImg, keypoints);
|
||||||
delete detector;
|
|
||||||
ui_->label_timeDetection->setNum(time.restart());
|
ui_->label_timeDetection->setNum(time.restart());
|
||||||
|
|
||||||
cv::Mat descriptors;
|
cv::Mat descriptors;
|
||||||
@ -1335,9 +1341,7 @@ void MainWindow::update(const cv::Mat & image)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// EXTRACT DESCRIPTORS
|
// EXTRACT DESCRIPTORS
|
||||||
cv::DescriptorExtractor * extractor = Settings::createDescriptorsExtractor();
|
extractor_->compute(grayscaleImg, keypoints, descriptors);
|
||||||
extractor->compute(grayscaleImg, keypoints, descriptors);
|
|
||||||
delete extractor;
|
|
||||||
if((int)keypoints.size() != descriptors.rows)
|
if((int)keypoints.size() != descriptors.rows)
|
||||||
{
|
{
|
||||||
printf("ERROR : kpt=%d != descriptors=%d\n", (int)keypoints.size(), descriptors.rows);
|
printf("ERROR : kpt=%d != descriptors=%d\n", (int)keypoints.size(), descriptors.rows);
|
||||||
@ -1658,6 +1662,7 @@ void MainWindow::update(const cv::Mat & image)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
ui_->label_timeHomographies->setNum(time.restart());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -1769,7 +1774,6 @@ void MainWindow::update(const cv::Mat & image)
|
|||||||
|
|
||||||
ui_->label_nfeatures->setNum((int)keypoints.size());
|
ui_->label_nfeatures->setNum((int)keypoints.size());
|
||||||
ui_->imageView_source->update();
|
ui_->imageView_source->update();
|
||||||
ui_->label_timeGui->setNum(time.restart());
|
|
||||||
}
|
}
|
||||||
ui_->label_detectorDescriptorType->setText(QString("%1/%2").arg(Settings::currentDetectorType()).arg(Settings::currentDescriptorType()));
|
ui_->label_detectorDescriptorType->setText(QString("%1/%2").arg(Settings::currentDetectorType()).arg(Settings::currentDescriptorType()));
|
||||||
|
|
||||||
@ -1836,6 +1840,16 @@ void MainWindow::notifyParametersChanged(const QStringList & paramChanged)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(detectorDescriptorParamsChanged)
|
||||||
|
{
|
||||||
|
//Re-init detector and extractor
|
||||||
|
delete detector_;
|
||||||
|
delete extractor_;
|
||||||
|
detector_ = Settings::createFeaturesDetector();
|
||||||
|
extractor_ = Settings::createDescriptorsExtractor();
|
||||||
|
Q_ASSERT(detector_ != 0 && extractor_ != 0);
|
||||||
|
}
|
||||||
|
|
||||||
if(Settings::getGeneral_autoUpdateObjects())
|
if(Settings::getGeneral_autoUpdateObjects())
|
||||||
{
|
{
|
||||||
if(detectorDescriptorParamsChanged)
|
if(detectorDescriptorParamsChanged)
|
||||||
|
|||||||
@ -105,6 +105,8 @@ private:
|
|||||||
QMap<int, QByteArray> imagesMap_;
|
QMap<int, QByteArray> imagesMap_;
|
||||||
TcpServer * tcpServer_;
|
TcpServer * tcpServer_;
|
||||||
QMap<QString, QVariant> lastObjectsUpdateParameters_; // ParametersMap
|
QMap<QString, QVariant> lastObjectsUpdateParameters_; // ParametersMap
|
||||||
|
cv::FeatureDetector * detector_;
|
||||||
|
cv::DescriptorExtractor * extractor_;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* MainWindow_H_ */
|
#endif /* MainWindow_H_ */
|
||||||
|
|||||||
@ -7,7 +7,7 @@
|
|||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>826</width>
|
<width>826</width>
|
||||||
<height>488</height>
|
<height>506</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
@ -200,7 +200,7 @@
|
|||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>826</width>
|
<width>826</width>
|
||||||
<height>22</height>
|
<height>25</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<widget class="QMenu" name="menuFile">
|
<widget class="QMenu" name="menuFile">
|
||||||
@ -255,7 +255,7 @@
|
|||||||
<property name="minimumSize">
|
<property name="minimumSize">
|
||||||
<size>
|
<size>
|
||||||
<width>360</width>
|
<width>360</width>
|
||||||
<height>100</height>
|
<height>156</height>
|
||||||
</size>
|
</size>
|
||||||
</property>
|
</property>
|
||||||
<property name="floating">
|
<property name="floating">
|
||||||
@ -285,8 +285,8 @@
|
|||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>348</width>
|
<width>360</width>
|
||||||
<height>76</height>
|
<height>73</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<attribute name="label">
|
<attribute name="label">
|
||||||
@ -343,8 +343,8 @@
|
|||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>199</width>
|
<width>198</width>
|
||||||
<height>361</height>
|
<height>376</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_objects">
|
<layout class="QVBoxLayout" name="verticalLayout_objects">
|
||||||
@ -448,6 +448,20 @@
|
|||||||
<property name="verticalSpacing">
|
<property name="verticalSpacing">
|
||||||
<number>0</number>
|
<number>0</number>
|
||||||
</property>
|
</property>
|
||||||
|
<item row="3" column="2">
|
||||||
|
<widget class="QLabel" name="label_9">
|
||||||
|
<property name="text">
|
||||||
|
<string>ms</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="4" column="2">
|
||||||
|
<widget class="QLabel" name="label_10">
|
||||||
|
<property name="text">
|
||||||
|
<string>ms</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
<item row="3" column="0">
|
<item row="3" column="0">
|
||||||
<widget class="QLabel" name="label_8">
|
<widget class="QLabel" name="label_8">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
@ -469,20 +483,6 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="3" column="2">
|
|
||||||
<widget class="QLabel" name="label_9">
|
|
||||||
<property name="text">
|
|
||||||
<string>ms</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="4" column="2">
|
|
||||||
<widget class="QLabel" name="label_10">
|
|
||||||
<property name="text">
|
|
||||||
<string>ms</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="5" column="2">
|
<item row="5" column="2">
|
||||||
<widget class="QLabel" name="label_12">
|
<widget class="QLabel" name="label_12">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
@ -525,13 +525,6 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="5" column="1">
|
|
||||||
<widget class="QLabel" name="label_timeGui">
|
|
||||||
<property name="text">
|
|
||||||
<string>000</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="2" column="0">
|
<item row="2" column="0">
|
||||||
<widget class="QLabel" name="label_2">
|
<widget class="QLabel" name="label_2">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
@ -658,6 +651,13 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item row="5" column="1">
|
||||||
|
<widget class="QLabel" name="label_timeHomographies">
|
||||||
|
<property name="text">
|
||||||
|
<string>000</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user