Using default parameters when [ --config "" ] is used.
Updated default: sendNoObjDetectedEvents = true. fixed mirror view when autoScale is set on/off git-svn-id: http://find-object.googlecode.com/svn/trunk/find_object@397 620bd6b2-0a58-f614-fd9a-1bd335dccda9
This commit is contained in:
parent
17d5f4141a
commit
91c70ef181
19
app/main.cpp
19
app/main.cpp
@ -102,9 +102,12 @@ void showUsage()
|
||||
" --object \"path\" Path to an object to detect.\n"
|
||||
" --objects \"path\" Directory of the objects to detect (--object is ignored).\n"
|
||||
" --config \"path\" Path to configuration file (default: %s).\n"
|
||||
" If set to \"\", default parameters are used "
|
||||
" without saving modified parameters on closing.\n"
|
||||
" --scene \"path\" Path to a scene image file.\n"
|
||||
" --debug Show debug log.\n"
|
||||
" --params Show all parameters.\n"
|
||||
" --defaults Use default parameters (--config is ignored).\n"
|
||||
" --My/Parameter \"value\" Set find-Object's parameter (look --params for parameters' name).\n"
|
||||
" It will override the one in --config. Example to set 4 threads:\n"
|
||||
" $ find_object --General/threads 4\n"
|
||||
@ -216,7 +219,7 @@ int main(int argc, char* argv[])
|
||||
{
|
||||
configPath.replace('~', QDir::homePath());
|
||||
}
|
||||
if(!QFile::exists(configPath))
|
||||
if(!configPath.isEmpty() && !QFile::exists(configPath))
|
||||
{
|
||||
UWARN("Configuration file \"%s\" doesn't exist, it will be created with default values...", configPath.toStdString().c_str());
|
||||
}
|
||||
@ -310,10 +313,20 @@ int main(int argc, char* argv[])
|
||||
|
||||
UINFO("Options:");
|
||||
UINFO(" GUI mode = %s", guiMode?"true":"false");
|
||||
UINFO(" Objects path: \"%s\"", objectsPath.toStdString().c_str());
|
||||
if(!objectsPath.isEmpty())
|
||||
{
|
||||
UINFO(" Objects path: \"%s\"", objectsPath.toStdString().c_str());
|
||||
}
|
||||
else if(!objectPath.isEmpty())
|
||||
{
|
||||
UINFO(" Object path: \"%s\"", objectPath.toStdString().c_str());
|
||||
}
|
||||
UINFO(" Scene path: \"%s\"", scenePath.toStdString().c_str());
|
||||
if(!guiMode)
|
||||
{
|
||||
UINFO(" JSON path: \"%s\"", jsonPath.toStdString().c_str());
|
||||
}
|
||||
UINFO(" Settings path: \"%s\"", configPath.toStdString().c_str());
|
||||
UINFO(" JSON path: \"%s\"", jsonPath.toStdString().c_str());
|
||||
|
||||
for(find_object::ParametersMap::iterator iter= customParameters.begin(); iter!=customParameters.end(); ++iter)
|
||||
{
|
||||
|
||||
@ -90,7 +90,7 @@ class FINDOBJECT_EXP Settings
|
||||
PARAMETER(Camera, 4imageRate, double, 2.0, "Image rate in Hz (0 Hz means as fast as possible)."); // Hz
|
||||
PARAMETER(Camera, 5mediaPath, QString, "", "Video file or directory of images. If set, the camera is not used. See General->videoFormats and General->imageFormats for available formats.");
|
||||
PARAMETER(Camera, 6useTcpCamera, bool, false, "Use TCP/IP input camera.");
|
||||
PARAMETER(Camera, 8port, int, 5000, "The images server's port when useTcpCamera is checked. Only one client at the same time is allowed.");
|
||||
PARAMETER(Camera, 8port, int, 0, "The images server's port when useTcpCamera is checked. Only one client at the same time is allowed.");
|
||||
PARAMETER(Camera, 9queueSize, int, 1, "Maximum images buffered from TCP. If 0, all images are buffered.");
|
||||
|
||||
//List format : [Index:item0;item1;item3;...]
|
||||
@ -219,7 +219,7 @@ class FINDOBJECT_EXP Settings
|
||||
PARAMETER(General, autoScroll, bool, true, "Auto scroll to detected object in Objects panel.");
|
||||
PARAMETER(General, vocabularyIncremental, bool, false, "The vocabulary is created incrementally. When new objects are added, their descriptors are compared to those already in vocabulary to find if the visual word already exist or not. \"NearestNeighbor/nndrRatio\" is used to compare descriptors.");
|
||||
PARAMETER(General, vocabularyUpdateMinWords, int, 2000, "When the vocabulary is incremental (see \"General/vocabularyIncremental\"), after X words added to vocabulary, the internal index is updated with new words. This parameter lets avoiding to reconstruct the whole nearest neighbor index after each time descriptors of an object are added to vocabulary. 0 means no incremental update.");
|
||||
PARAMETER(General, sendNoObjDetectedEvents, bool, false, "When there are no objects detected, send an empty object detection event.");
|
||||
PARAMETER(General, sendNoObjDetectedEvents, bool, true, "When there are no objects detected, send an empty object detection event.");
|
||||
PARAMETER(General, autoPauseOnDetection, bool, false, "Auto pause the camera when an object is detected.");
|
||||
|
||||
PARAMETER(Homography, homographyComputed, bool, true, "Compute homography? On ROS, this is required to publish objects detected.");
|
||||
@ -239,7 +239,7 @@ public:
|
||||
static QString iniDefaultFileName() {return "config.ini";}
|
||||
static QString iniPath();
|
||||
|
||||
static void init(const QString & fileName = QString());
|
||||
static void init(const QString & fileName);
|
||||
|
||||
static void loadSettings(const QString & fileName = QString());
|
||||
static void loadWindowSettings(QByteArray & windowGeometry, QByteArray & windowState, const QString & fileName = QString());
|
||||
|
||||
@ -441,7 +441,7 @@ protected:
|
||||
unsigned int threadCounts = Settings::getGeneral_threads();
|
||||
if(threadCounts == 0)
|
||||
{
|
||||
threadCounts = tilts.size();
|
||||
threadCounts = (unsigned int)tilts.size();
|
||||
}
|
||||
|
||||
for(unsigned int i=0; i<tilts.size(); i+=threadCounts)
|
||||
|
||||
@ -146,7 +146,7 @@ void ObjWidget::setId(int id)
|
||||
void ObjWidget::setGraphicsViewMode(bool on)
|
||||
{
|
||||
graphicsViewMode_->setChecked(on);
|
||||
graphicsView_->setVisible(on);
|
||||
graphicsView_->setVisible(on && graphicsView_->scene()->items().size());
|
||||
autoScale_->setEnabled(on);
|
||||
//update items' color
|
||||
if(on)
|
||||
@ -172,6 +172,7 @@ void ObjWidget::setGraphicsViewMode(bool on)
|
||||
else
|
||||
{
|
||||
graphicsView_->resetTransform();
|
||||
graphicsView_->setTransform(QTransform().scale(this->isMirrorView()?-1.0:1.0, 1.0));
|
||||
}
|
||||
}
|
||||
|
||||
@ -187,6 +188,7 @@ void ObjWidget::setAutoScale(bool autoScale)
|
||||
else
|
||||
{
|
||||
graphicsView_->resetTransform();
|
||||
graphicsView_->setTransform(QTransform().scale(this->isMirrorView()?-1.0:1.0, 1.0));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -747,28 +749,31 @@ void ObjWidget::setupGraphicsView()
|
||||
{
|
||||
if(!pixmap_.isNull())
|
||||
{
|
||||
graphicsView_->setVisible(true);
|
||||
graphicsView_->scene()->setSceneRect(pixmap_.rect());
|
||||
QList<KeypointItem*> items;
|
||||
if(pixmap_.width() > 0 && pixmap_.height() > 0)
|
||||
|
||||
QRectF sceneRect = graphicsView_->sceneRect();
|
||||
|
||||
QGraphicsPixmapItem * pixmapItem = graphicsView_->scene()->addPixmap(pixmap_);
|
||||
pixmapItem->setVisible(this->isImageShown());
|
||||
this->drawKeypoints();
|
||||
|
||||
for(int i=0; i<rectItems_.size(); ++i)
|
||||
{
|
||||
QRectF sceneRect = graphicsView_->sceneRect();
|
||||
graphicsView_->scene()->addItem(rectItems_.at(i));
|
||||
}
|
||||
|
||||
QGraphicsPixmapItem * pixmapItem = graphicsView_->scene()->addPixmap(pixmap_);
|
||||
pixmapItem->setVisible(this->isImageShown());
|
||||
this->drawKeypoints();
|
||||
|
||||
for(int i=0; i<rectItems_.size(); ++i)
|
||||
{
|
||||
graphicsView_->scene()->addItem(rectItems_.at(i));
|
||||
}
|
||||
|
||||
if(autoScale_->isChecked())
|
||||
{
|
||||
graphicsView_->fitInView(sceneRect, Qt::KeepAspectRatio);
|
||||
}
|
||||
if(autoScale_->isChecked())
|
||||
{
|
||||
graphicsView_->fitInView(sceneRect, Qt::KeepAspectRatio);
|
||||
}
|
||||
graphicsViewInitialized_ = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
graphicsView_->setVisible(false);
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace find_object
|
||||
|
||||
114
src/Settings.cpp
114
src/Settings.cpp
@ -77,10 +77,6 @@ QString Settings::iniPath()
|
||||
void Settings::init(const QString & fileName)
|
||||
{
|
||||
iniPath_ = fileName;
|
||||
if(fileName.isEmpty())
|
||||
{
|
||||
iniPath_ = iniDefaultPath();
|
||||
}
|
||||
loadSettings(iniPath_);
|
||||
}
|
||||
|
||||
@ -91,26 +87,35 @@ void Settings::loadSettings(const QString & fileName)
|
||||
{
|
||||
path = iniPath();
|
||||
}
|
||||
QSettings ini(path, QSettings::IniFormat);
|
||||
for(ParametersMap::const_iterator iter = defaultParameters_.begin(); iter!=defaultParameters_.end(); ++iter)
|
||||
if(!path.isEmpty())
|
||||
{
|
||||
const QString & key = iter.key();
|
||||
QVariant value = ini.value(key, QVariant());
|
||||
if(value.isValid())
|
||||
QSettings ini(path, QSettings::IniFormat);
|
||||
for(ParametersMap::const_iterator iter = defaultParameters_.begin(); iter!=defaultParameters_.end(); ++iter)
|
||||
{
|
||||
QString str = value.toString();
|
||||
if(str.contains(";") && str.size() != getParameter(key).toString().size())
|
||||
const QString & key = iter.key();
|
||||
QVariant value = ini.value(key, QVariant());
|
||||
if(value.isValid())
|
||||
{
|
||||
// If a string list is modified, update the value
|
||||
// (assuming that index < 10... one character for index)
|
||||
QChar index = str.at(0);
|
||||
str = getParameter(key).toString();
|
||||
str[0] = index.toAscii();
|
||||
value = QVariant(str);
|
||||
UINFO("Updated list of parameter \"%s\"", key.toStdString().c_str());
|
||||
QString str = value.toString();
|
||||
if(str.contains(";") && str.size() != getParameter(key).toString().size())
|
||||
{
|
||||
// If a string list is modified, update the value
|
||||
// (assuming that index < 10... one character for index)
|
||||
QChar index = str.at(0);
|
||||
str = getParameter(key).toString();
|
||||
str[0] = index.toAscii();
|
||||
value = QVariant(str);
|
||||
UINFO("Updated list of parameter \"%s\"", key.toStdString().c_str());
|
||||
}
|
||||
setParameter(key, value);
|
||||
}
|
||||
setParameter(key, value);
|
||||
}
|
||||
UINFO("Settings loaded from %s.", path.toStdString().c_str());
|
||||
}
|
||||
else
|
||||
{
|
||||
parameters_ = defaultParameters_;
|
||||
UINFO("Settings set to defaults.");
|
||||
}
|
||||
|
||||
if(cv::gpu::getCudaEnabledDeviceCount() == 0)
|
||||
@ -119,8 +124,6 @@ void Settings::loadSettings(const QString & fileName)
|
||||
Settings::setFeature2D_Fast_gpu(false);
|
||||
Settings::setFeature2D_ORB_gpu(false);
|
||||
}
|
||||
|
||||
UINFO("Settings loaded from %s", path.toStdString().c_str());
|
||||
}
|
||||
|
||||
void Settings::loadWindowSettings(QByteArray & windowGeometry, QByteArray & windowState, const QString & fileName)
|
||||
@ -131,21 +134,24 @@ void Settings::loadWindowSettings(QByteArray & windowGeometry, QByteArray & wind
|
||||
path = iniPath();
|
||||
}
|
||||
|
||||
QSettings ini(path, QSettings::IniFormat);
|
||||
|
||||
QVariant value = ini.value("windowGeometry", QVariant());
|
||||
if(value.isValid())
|
||||
if(!path.isEmpty())
|
||||
{
|
||||
windowGeometry = value.toByteArray();
|
||||
}
|
||||
QSettings ini(path, QSettings::IniFormat);
|
||||
|
||||
value = ini.value("windowState", QVariant());
|
||||
if(value.isValid())
|
||||
{
|
||||
windowState = value.toByteArray();
|
||||
}
|
||||
QVariant value = ini.value("windowGeometry", QVariant());
|
||||
if(value.isValid())
|
||||
{
|
||||
windowGeometry = value.toByteArray();
|
||||
}
|
||||
|
||||
UINFO("Window settings loaded from %s", path.toStdString().c_str());
|
||||
value = ini.value("windowState", QVariant());
|
||||
if(value.isValid())
|
||||
{
|
||||
windowState = value.toByteArray();
|
||||
}
|
||||
|
||||
UINFO("Window settings loaded from %s", path.toStdString().c_str());
|
||||
}
|
||||
}
|
||||
|
||||
void Settings::saveSettings(const QString & fileName)
|
||||
@ -155,20 +161,23 @@ void Settings::saveSettings(const QString & fileName)
|
||||
{
|
||||
path = iniPath();
|
||||
}
|
||||
QSettings ini(path, QSettings::IniFormat);
|
||||
for(ParametersMap::const_iterator iter = parameters_.begin(); iter!=parameters_.end(); ++iter)
|
||||
if(!path.isEmpty())
|
||||
{
|
||||
QString type = Settings::getParametersType().value(iter.key());
|
||||
if(type.compare("float") == 0)
|
||||
QSettings ini(path, QSettings::IniFormat);
|
||||
for(ParametersMap::const_iterator iter = parameters_.begin(); iter!=parameters_.end(); ++iter)
|
||||
{
|
||||
ini.setValue(iter.key(), QString::number(iter.value().toFloat(),'g',6));
|
||||
}
|
||||
else
|
||||
{
|
||||
ini.setValue(iter.key(), iter.value());
|
||||
QString type = Settings::getParametersType().value(iter.key());
|
||||
if(type.compare("float") == 0)
|
||||
{
|
||||
ini.setValue(iter.key(), QString::number(iter.value().toFloat(),'g',6));
|
||||
}
|
||||
else
|
||||
{
|
||||
ini.setValue(iter.key(), iter.value());
|
||||
}
|
||||
}
|
||||
UINFO("Settings saved to %s", path.toStdString().c_str());
|
||||
}
|
||||
UINFO("Settings saved to %s", path.toStdString().c_str());
|
||||
}
|
||||
|
||||
void Settings::saveWindowSettings(const QByteArray & windowGeometry, const QByteArray & windowState, const QString & fileName)
|
||||
@ -178,16 +187,19 @@ void Settings::saveWindowSettings(const QByteArray & windowGeometry, const QByte
|
||||
{
|
||||
path = iniPath();
|
||||
}
|
||||
QSettings ini(path, QSettings::IniFormat);
|
||||
if(!windowGeometry.isEmpty())
|
||||
if(!path.isEmpty())
|
||||
{
|
||||
ini.setValue("windowGeometry", windowGeometry);
|
||||
QSettings ini(path, QSettings::IniFormat);
|
||||
if(!windowGeometry.isEmpty())
|
||||
{
|
||||
ini.setValue("windowGeometry", windowGeometry);
|
||||
}
|
||||
if(!windowState.isEmpty())
|
||||
{
|
||||
ini.setValue("windowState", windowState);
|
||||
}
|
||||
UINFO("Window settings saved to %s", path.toStdString().c_str());
|
||||
}
|
||||
if(!windowState.isEmpty())
|
||||
{
|
||||
ini.setValue("windowState", windowState);
|
||||
}
|
||||
UINFO("Window settings saved to %s", path.toStdString().c_str());
|
||||
}
|
||||
|
||||
class GPUFeature2D
|
||||
|
||||
@ -40,7 +40,8 @@ void showUsage()
|
||||
" \"in\" is the port from which the detection is received.\n"
|
||||
" Options:\n"
|
||||
" --host #.#.#.# Set host address.\n"
|
||||
" --json \"path\" Path to an output JSON file.\n");
|
||||
" --json \"path\" Path to an output JSON file.\n"
|
||||
" --help Show this help.\n");
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
@ -126,6 +127,12 @@ int main(int argc, char * argv[])
|
||||
continue;
|
||||
}
|
||||
|
||||
if(strcmp(argv[i], "-help") == 0 ||
|
||||
strcmp(argv[i], "--help") == 0)
|
||||
{
|
||||
showUsage();
|
||||
}
|
||||
|
||||
printf("Unrecognized option: %s\n", argv[i]);
|
||||
showUsage();
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user