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
17
app/main.cpp
17
app/main.cpp
@ -102,9 +102,12 @@ void showUsage()
|
|||||||
" --object \"path\" Path to an object to detect.\n"
|
" --object \"path\" Path to an object to detect.\n"
|
||||||
" --objects \"path\" Directory of the objects to detect (--object is ignored).\n"
|
" --objects \"path\" Directory of the objects to detect (--object is ignored).\n"
|
||||||
" --config \"path\" Path to configuration file (default: %s).\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"
|
" --scene \"path\" Path to a scene image file.\n"
|
||||||
" --debug Show debug log.\n"
|
" --debug Show debug log.\n"
|
||||||
" --params Show all parameters.\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"
|
" --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"
|
" It will override the one in --config. Example to set 4 threads:\n"
|
||||||
" $ find_object --General/threads 4\n"
|
" $ find_object --General/threads 4\n"
|
||||||
@ -216,7 +219,7 @@ int main(int argc, char* argv[])
|
|||||||
{
|
{
|
||||||
configPath.replace('~', QDir::homePath());
|
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());
|
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("Options:");
|
||||||
UINFO(" GUI mode = %s", guiMode?"true":"false");
|
UINFO(" GUI mode = %s", guiMode?"true":"false");
|
||||||
|
if(!objectsPath.isEmpty())
|
||||||
|
{
|
||||||
UINFO(" Objects path: \"%s\"", objectsPath.toStdString().c_str());
|
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());
|
UINFO(" Scene path: \"%s\"", scenePath.toStdString().c_str());
|
||||||
UINFO(" Settings path: \"%s\"", configPath.toStdString().c_str());
|
if(!guiMode)
|
||||||
|
{
|
||||||
UINFO(" JSON path: \"%s\"", jsonPath.toStdString().c_str());
|
UINFO(" JSON path: \"%s\"", jsonPath.toStdString().c_str());
|
||||||
|
}
|
||||||
|
UINFO(" Settings path: \"%s\"", configPath.toStdString().c_str());
|
||||||
|
|
||||||
for(find_object::ParametersMap::iterator iter= customParameters.begin(); iter!=customParameters.end(); ++iter)
|
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, 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, 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, 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.");
|
PARAMETER(Camera, 9queueSize, int, 1, "Maximum images buffered from TCP. If 0, all images are buffered.");
|
||||||
|
|
||||||
//List format : [Index:item0;item1;item3;...]
|
//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, 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, 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, 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(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.");
|
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 iniDefaultFileName() {return "config.ini";}
|
||||||
static QString iniPath();
|
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 loadSettings(const QString & fileName = QString());
|
||||||
static void loadWindowSettings(QByteArray & windowGeometry, QByteArray & windowState, 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();
|
unsigned int threadCounts = Settings::getGeneral_threads();
|
||||||
if(threadCounts == 0)
|
if(threadCounts == 0)
|
||||||
{
|
{
|
||||||
threadCounts = tilts.size();
|
threadCounts = (unsigned int)tilts.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
for(unsigned int i=0; i<tilts.size(); i+=threadCounts)
|
for(unsigned int i=0; i<tilts.size(); i+=threadCounts)
|
||||||
|
|||||||
@ -146,7 +146,7 @@ void ObjWidget::setId(int id)
|
|||||||
void ObjWidget::setGraphicsViewMode(bool on)
|
void ObjWidget::setGraphicsViewMode(bool on)
|
||||||
{
|
{
|
||||||
graphicsViewMode_->setChecked(on);
|
graphicsViewMode_->setChecked(on);
|
||||||
graphicsView_->setVisible(on);
|
graphicsView_->setVisible(on && graphicsView_->scene()->items().size());
|
||||||
autoScale_->setEnabled(on);
|
autoScale_->setEnabled(on);
|
||||||
//update items' color
|
//update items' color
|
||||||
if(on)
|
if(on)
|
||||||
@ -172,6 +172,7 @@ void ObjWidget::setGraphicsViewMode(bool on)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
graphicsView_->resetTransform();
|
graphicsView_->resetTransform();
|
||||||
|
graphicsView_->setTransform(QTransform().scale(this->isMirrorView()?-1.0:1.0, 1.0));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -187,6 +188,7 @@ void ObjWidget::setAutoScale(bool autoScale)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
graphicsView_->resetTransform();
|
graphicsView_->resetTransform();
|
||||||
|
graphicsView_->setTransform(QTransform().scale(this->isMirrorView()?-1.0:1.0, 1.0));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -747,10 +749,10 @@ void ObjWidget::setupGraphicsView()
|
|||||||
{
|
{
|
||||||
if(!pixmap_.isNull())
|
if(!pixmap_.isNull())
|
||||||
{
|
{
|
||||||
|
graphicsView_->setVisible(true);
|
||||||
graphicsView_->scene()->setSceneRect(pixmap_.rect());
|
graphicsView_->scene()->setSceneRect(pixmap_.rect());
|
||||||
QList<KeypointItem*> items;
|
QList<KeypointItem*> items;
|
||||||
if(pixmap_.width() > 0 && pixmap_.height() > 0)
|
|
||||||
{
|
|
||||||
QRectF sceneRect = graphicsView_->sceneRect();
|
QRectF sceneRect = graphicsView_->sceneRect();
|
||||||
|
|
||||||
QGraphicsPixmapItem * pixmapItem = graphicsView_->scene()->addPixmap(pixmap_);
|
QGraphicsPixmapItem * pixmapItem = graphicsView_->scene()->addPixmap(pixmap_);
|
||||||
@ -766,9 +768,12 @@ void ObjWidget::setupGraphicsView()
|
|||||||
{
|
{
|
||||||
graphicsView_->fitInView(sceneRect, Qt::KeepAspectRatio);
|
graphicsView_->fitInView(sceneRect, Qt::KeepAspectRatio);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
graphicsViewInitialized_ = true;
|
graphicsViewInitialized_ = true;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
graphicsView_->setVisible(false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace find_object
|
} // namespace find_object
|
||||||
|
|||||||
@ -77,10 +77,6 @@ QString Settings::iniPath()
|
|||||||
void Settings::init(const QString & fileName)
|
void Settings::init(const QString & fileName)
|
||||||
{
|
{
|
||||||
iniPath_ = fileName;
|
iniPath_ = fileName;
|
||||||
if(fileName.isEmpty())
|
|
||||||
{
|
|
||||||
iniPath_ = iniDefaultPath();
|
|
||||||
}
|
|
||||||
loadSettings(iniPath_);
|
loadSettings(iniPath_);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -91,6 +87,8 @@ void Settings::loadSettings(const QString & fileName)
|
|||||||
{
|
{
|
||||||
path = iniPath();
|
path = iniPath();
|
||||||
}
|
}
|
||||||
|
if(!path.isEmpty())
|
||||||
|
{
|
||||||
QSettings ini(path, QSettings::IniFormat);
|
QSettings ini(path, QSettings::IniFormat);
|
||||||
for(ParametersMap::const_iterator iter = defaultParameters_.begin(); iter!=defaultParameters_.end(); ++iter)
|
for(ParametersMap::const_iterator iter = defaultParameters_.begin(); iter!=defaultParameters_.end(); ++iter)
|
||||||
{
|
{
|
||||||
@ -112,6 +110,13 @@ void Settings::loadSettings(const QString & fileName)
|
|||||||
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)
|
if(cv::gpu::getCudaEnabledDeviceCount() == 0)
|
||||||
{
|
{
|
||||||
@ -119,8 +124,6 @@ void Settings::loadSettings(const QString & fileName)
|
|||||||
Settings::setFeature2D_Fast_gpu(false);
|
Settings::setFeature2D_Fast_gpu(false);
|
||||||
Settings::setFeature2D_ORB_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)
|
void Settings::loadWindowSettings(QByteArray & windowGeometry, QByteArray & windowState, const QString & fileName)
|
||||||
@ -131,6 +134,8 @@ void Settings::loadWindowSettings(QByteArray & windowGeometry, QByteArray & wind
|
|||||||
path = iniPath();
|
path = iniPath();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(!path.isEmpty())
|
||||||
|
{
|
||||||
QSettings ini(path, QSettings::IniFormat);
|
QSettings ini(path, QSettings::IniFormat);
|
||||||
|
|
||||||
QVariant value = ini.value("windowGeometry", QVariant());
|
QVariant value = ini.value("windowGeometry", QVariant());
|
||||||
@ -147,6 +152,7 @@ void Settings::loadWindowSettings(QByteArray & windowGeometry, QByteArray & wind
|
|||||||
|
|
||||||
UINFO("Window settings loaded from %s", path.toStdString().c_str());
|
UINFO("Window settings loaded from %s", path.toStdString().c_str());
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void Settings::saveSettings(const QString & fileName)
|
void Settings::saveSettings(const QString & fileName)
|
||||||
{
|
{
|
||||||
@ -155,6 +161,8 @@ void Settings::saveSettings(const QString & fileName)
|
|||||||
{
|
{
|
||||||
path = iniPath();
|
path = iniPath();
|
||||||
}
|
}
|
||||||
|
if(!path.isEmpty())
|
||||||
|
{
|
||||||
QSettings ini(path, QSettings::IniFormat);
|
QSettings ini(path, QSettings::IniFormat);
|
||||||
for(ParametersMap::const_iterator iter = parameters_.begin(); iter!=parameters_.end(); ++iter)
|
for(ParametersMap::const_iterator iter = parameters_.begin(); iter!=parameters_.end(); ++iter)
|
||||||
{
|
{
|
||||||
@ -170,6 +178,7 @@ void Settings::saveSettings(const QString & fileName)
|
|||||||
}
|
}
|
||||||
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)
|
void Settings::saveWindowSettings(const QByteArray & windowGeometry, const QByteArray & windowState, const QString & fileName)
|
||||||
{
|
{
|
||||||
@ -178,6 +187,8 @@ void Settings::saveWindowSettings(const QByteArray & windowGeometry, const QByte
|
|||||||
{
|
{
|
||||||
path = iniPath();
|
path = iniPath();
|
||||||
}
|
}
|
||||||
|
if(!path.isEmpty())
|
||||||
|
{
|
||||||
QSettings ini(path, QSettings::IniFormat);
|
QSettings ini(path, QSettings::IniFormat);
|
||||||
if(!windowGeometry.isEmpty())
|
if(!windowGeometry.isEmpty())
|
||||||
{
|
{
|
||||||
@ -189,6 +200,7 @@ void Settings::saveWindowSettings(const QByteArray & windowGeometry, const QByte
|
|||||||
}
|
}
|
||||||
UINFO("Window settings saved to %s", path.toStdString().c_str());
|
UINFO("Window settings saved to %s", path.toStdString().c_str());
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
class GPUFeature2D
|
class GPUFeature2D
|
||||||
{
|
{
|
||||||
|
|||||||
@ -40,7 +40,8 @@ void showUsage()
|
|||||||
" \"in\" is the port from which the detection is received.\n"
|
" \"in\" is the port from which the detection is received.\n"
|
||||||
" Options:\n"
|
" Options:\n"
|
||||||
" --host #.#.#.# Set host address.\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);
|
exit(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -126,6 +127,12 @@ int main(int argc, char * argv[])
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(strcmp(argv[i], "-help") == 0 ||
|
||||||
|
strcmp(argv[i], "--help") == 0)
|
||||||
|
{
|
||||||
|
showUsage();
|
||||||
|
}
|
||||||
|
|
||||||
printf("Unrecognized option: %s\n", argv[i]);
|
printf("Unrecognized option: %s\n", argv[i]);
|
||||||
showUsage();
|
showUsage();
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user