Skip to content

Commit

Permalink
feature files can have arbitrary names
Browse files Browse the repository at this point in the history
  • Loading branch information
ovysotska committed Nov 14, 2017
1 parent ebc8658 commit fe1fc48
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 78 deletions.
2 changes: 1 addition & 1 deletion src/database/list_dir.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ std::vector<std::string> listDir(const std::string &dir_name) {
struct dirent *ent;
/* print all the files and directories within directory */
while ((ent = readdir(dir)) != NULL) {
file_names.push_back(ent->d_name);
file_names.push_back( dir_name + ent->d_name);
}
std::sort(file_names.begin(), file_names.end());
closedir(dir);
Expand Down
8 changes: 3 additions & 5 deletions src/database/online_database.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,9 @@ double OnlineDatabase::getCost(int quId, int refId) {
}

void OnlineDatabase::setQuFeaturesFolder(const std::string &path2folder) {
_quFeaturesFolder = path2folder;
_quFeaturesNames = listDir(path2folder);
}
void OnlineDatabase::setRefFeaturesFolder(const std::string &path2folder) {
_refFeaturesFolder = path2folder;
_refFeaturesNames = listDir(path2folder);
}

Expand Down Expand Up @@ -121,7 +119,7 @@ double OnlineDatabase::computeMatchCost(int quId, int refId) {
} else {
// We cannot directly set const pointers, so set them through a proxy.
auto tempFeaturePtr = _featureFactory.createFeature();
tempFeaturePtr->loadFromFile(_quFeaturesFolder + _quFeaturesNames[quId]);
tempFeaturePtr->loadFromFile( _quFeaturesNames[quId]);
quFeaturePtr = tempFeaturePtr;
_quBuff.addFeature(quId, quFeaturePtr);
}
Expand All @@ -131,7 +129,7 @@ double OnlineDatabase::computeMatchCost(int quId, int refId) {
} else {
// We cannot directly set const pointers, so set them through a proxy.
auto tempFeaturePtr = _featureFactory.createFeature();
tempFeaturePtr->loadFromFile(_refFeaturesFolder + _refFeaturesNames[refId]);
tempFeaturePtr->loadFromFile(_refFeaturesNames[refId]);
refFeaturePtr = tempFeaturePtr;
_refBuff.addFeature(refId, refFeaturePtr);
}
Expand Down Expand Up @@ -163,7 +161,7 @@ iFeature::ConstPtr OnlineDatabase::getQueryFeature(int quId) {
} else {
// We cannot directly set const pointers, so set them through a proxy.
auto tempFeaturePtr = _featureFactory.createFeature();
tempFeaturePtr->loadFromFile(_quFeaturesFolder + _quFeaturesNames[quId]);
tempFeaturePtr->loadFromFile(_quFeaturesNames[quId]);
quFeaturePtr = tempFeaturePtr;
_quBuff.addFeature(quId, quFeaturePtr);
}
Expand Down
2 changes: 0 additions & 2 deletions src/database/online_database.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,6 @@ class OnlineDatabase : public iDatabase {

protected:
MatchMap _matchMap;
std::string _quFeaturesFolder = "";
std::string _refFeaturesFolder = "";
std::vector<std::string> _quFeaturesNames, _refFeaturesNames;
FeatureFactory _featureFactory;

Expand Down
61 changes: 18 additions & 43 deletions src/visualizer/match_viewer.cpp
Original file line number Diff line number Diff line change
@@ -1,40 +1,23 @@
/** vpr_relocalization: a library for visual place recognition in changing
** environments with efficient relocalization step.
** Copyright (c) 2017 O. Vysotska, C. Stachniss, University of Bonn
**
** Permission is hereby granted, free of charge, to any person obtaining a copy
** of this software and associated documentation files (the "Software"), to deal
** in the Software without restriction, including without limitation the rights
** to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
** copies of the Software, and to permit persons to whom the Software is
** furnished to do so, subject to the following conditions:
**
** The above copyright notice and this permission notice shall be included in
** all copies or substantial portions of the Software.
**
** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
** IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
** FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
** AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
** LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
** OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
** SOFTWARE.
**/
/* Copyright Olga Vysotska, year 2017.
** In case of any problems with the code please contact me.
** Email: [email protected].
*/

#include "visualizer/match_viewer.h"

#include <QDebug>
#include <QScrollBar>
#include <string>
#include <vector>
#include <database/list_dir.h>

MatchViewer::MatchViewer() {}

bool MatchViewer::init(int width, int height) {
// if (_queryImages.empty() || _refImages.empty()) {
// printf("[ERROR][MatchViewer] Images were not set\n");
// return false;
// }
if (_queryImages.empty() || _refImages.empty()) {
printf("[ERROR][MatchViewer] Images were not set\n");
return false;
}
this->setDragMode(QGraphicsView::ScrollHandDrag);
this->setTransformationAnchor(QGraphicsView::AnchorUnderMouse);
// this->setScene(&_scene);
Expand Down Expand Up @@ -102,12 +85,7 @@ void MatchViewer::wheelEvent(QWheelEvent *event) {
void MatchViewer::receivedMatch(int quId, int refId, bool hidden) {
// printf("Received match %d %d \n", quId, refId);
std::string qu_path, ref_path;

qu_path = _database->getQuFeatureName(quId);
qu_path = _quImagesFolder + qu_path;
// chop out '-feature.txt' -> 12 symbols
qu_path.erase(qu_path.end() - 12, qu_path.end());
qu_path += _imgExt;
qu_path = _queryImages[quId];

QPixmap img_qu;
img_qu.load(qu_path.c_str());
Expand All @@ -132,11 +110,8 @@ void MatchViewer::receivedMatch(int quId, int refId, bool hidden) {
_textItem->setZValue(1);
} else {
_textItem->setVisible(false);
ref_path = _database->getRefFeatureName(refId);
ref_path = _refImagesFolder + ref_path;
// chop out '-feature.txt' -> 12 symbols
ref_path.erase(ref_path.end() - 12, ref_path.end());
ref_path += _imgExt;

ref_path = _refImages[refId];

QPixmap img_ref;
// printf("[MatchViewer] reading image %s\n", ref_path.c_str());
Expand All @@ -158,11 +133,11 @@ bool MatchViewer::isReady() const {
printf("[ERROR][MatchViewer] Database is not set\n");
return false;
}
if (_quImagesFolder.empty()) {
if (_queryImages.empty()) {
printf("[ERROR][MatchViewer] Folder for query images is not set\n");
return false;
}
if (_refImagesFolder.empty()) {
if (_refImages.empty()) {
printf("[ERROR][MatchViewer] Folder for reference images is not set\n");
return false;
}
Expand All @@ -174,10 +149,10 @@ bool MatchViewer::isReady() const {
return true;
}

void MatchViewer::setQuImageDirectory(const std::string &folder) {
_quImagesFolder = folder;
void MatchViewer::setQueryImages(const std::string &folder) {
_queryImages = listDir(folder);
}
void MatchViewer::setRefImageDirectory(const std::string &folder) {
_refImagesFolder = folder;
void MatchViewer::setRefImages(const std::string &folder) {
_refImages = listDir(folder);
}
void MatchViewer::setImageExtension(const std::string &ext) { _imgExt = ext; }
37 changes: 10 additions & 27 deletions src/visualizer/match_viewer.h
Original file line number Diff line number Diff line change
@@ -1,25 +1,7 @@
/** vpr_relocalization: a library for visual place recognition in changing
** environments with efficient relocalization step.
** Copyright (c) 2017 O. Vysotska, C. Stachniss, University of Bonn
**
** Permission is hereby granted, free of charge, to any person obtaining a copy
** of this software and associated documentation files (the "Software"), to deal
** in the Software without restriction, including without limitation the rights
** to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
** copies of the Software, and to permit persons to whom the Software is
** furnished to do so, subject to the following conditions:
**
** The above copyright notice and this permission notice shall be included in
** all copies or substantial portions of the Software.
**
** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
** IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
** FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
** AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
** LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
** OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
** SOFTWARE.
**/
/* Copyright Olga Vysotska, year 2017.
** In case of any problems with the code please contact me.
** Email: [email protected].
*/

#ifndef SRC_VISUALIZER_MATCH_VIEWER_H_
#define SRC_VISUALIZER_MATCH_VIEWER_H_
Expand All @@ -31,6 +13,7 @@
#include <QGridLayout>
#include <QtGui>
#include <string>
#include <vector>

#include "database/online_database.h"
#include "online_localizer/online_localizer.h"
Expand All @@ -47,10 +30,10 @@ class MatchViewer : public QGraphicsView {

MatchViewer();
~MatchViewer();

bool setDatabase(OnlineDatabase::Ptr database);
void setQuImageDirectory(const std::string &folder);
void setRefImageDirectory(const std::string &folder);
void setQueryImages(const std::string &folder);
void setRefImages(const std::string &folder);
void setImageExtension(const std::string &ext);

bool isReady() const;
Expand All @@ -62,8 +45,8 @@ class MatchViewer : public QGraphicsView {
void receivedMatch(int quId, int refId, bool hidden);

private:
std::string _refImagesFolder = "";
std::string _quImagesFolder = "";
std::vector<std::string> _refImages;
std::vector<std::string> _queryImages;
std::string _imgExt = "";

// variable for storing two single images
Expand Down

0 comments on commit fe1fc48

Please sign in to comment.