Added "--session" argument to load a session on startup
git-svn-id: http://find-object.googlecode.com/svn/trunk/find_object@419 620bd6b2-0a58-f614-fd9a-1bd335dccda9
This commit is contained in:
parent
02e31c2e69
commit
5d1f30cc09
44
app/main.cpp
44
app/main.cpp
@ -99,6 +99,7 @@ void showUsage()
|
|||||||
" --console Don't use the GUI (by default the camera will be\n"
|
" --console Don't use the GUI (by default the camera will be\n"
|
||||||
" started automatically). Option --objects must also be\n"
|
" started automatically). Option --objects must also be\n"
|
||||||
" used with valid objects.\n"
|
" used with valid objects.\n"
|
||||||
|
" --session \"path\" Path to a session to load (*.bin).\n"
|
||||||
" --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"
|
||||||
@ -129,6 +130,7 @@ int main(int argc, char* argv[])
|
|||||||
// parse options BEGIN
|
// parse options BEGIN
|
||||||
//////////////////////////
|
//////////////////////////
|
||||||
bool guiMode = true;
|
bool guiMode = true;
|
||||||
|
QString sessionPath = "";
|
||||||
QString objectsPath = "";
|
QString objectsPath = "";
|
||||||
QString objectPath = "";
|
QString objectPath = "";
|
||||||
QString scenePath = "";
|
QString scenePath = "";
|
||||||
@ -170,6 +172,29 @@ int main(int argc, char* argv[])
|
|||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
if(strcmp(argv[i], "-session") == 0 ||
|
||||||
|
strcmp(argv[i], "--session") == 0)
|
||||||
|
{
|
||||||
|
++i;
|
||||||
|
if(i < argc)
|
||||||
|
{
|
||||||
|
sessionPath = argv[i];
|
||||||
|
if(sessionPath.contains('~'))
|
||||||
|
{
|
||||||
|
sessionPath.replace('~', QDir::homePath());
|
||||||
|
}
|
||||||
|
if(!QFile(sessionPath).exists())
|
||||||
|
{
|
||||||
|
UERROR("Session path not valid : %s", sessionPath.toStdString().c_str());
|
||||||
|
showUsage();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
showUsage();
|
||||||
|
}
|
||||||
|
continue;
|
||||||
|
}
|
||||||
if(strcmp(argv[i], "-object") == 0 ||
|
if(strcmp(argv[i], "-object") == 0 ||
|
||||||
strcmp(argv[i], "--object") == 0)
|
strcmp(argv[i], "--object") == 0)
|
||||||
{
|
{
|
||||||
@ -329,7 +354,11 @@ 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())
|
if(!sessionPath.isEmpty())
|
||||||
|
{
|
||||||
|
UINFO(" Session path: \"%s\"", sessionPath.toStdString().c_str());
|
||||||
|
}
|
||||||
|
else if(!objectsPath.isEmpty())
|
||||||
{
|
{
|
||||||
UINFO(" Objects path: \"%s\"", objectsPath.toStdString().c_str());
|
UINFO(" Objects path: \"%s\"", objectsPath.toStdString().c_str());
|
||||||
}
|
}
|
||||||
@ -367,7 +396,18 @@ int main(int argc, char* argv[])
|
|||||||
|
|
||||||
// Load objects if path is set
|
// Load objects if path is set
|
||||||
int objectsLoaded = 0;
|
int objectsLoaded = 0;
|
||||||
if(!objectsPath.isEmpty())
|
if(!sessionPath.isEmpty())
|
||||||
|
{
|
||||||
|
if(!findObject->loadSession(sessionPath))
|
||||||
|
{
|
||||||
|
UERROR("Could not load session \"%s\"", sessionPath.toStdString().c_str());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
objectsLoaded = findObject->objects().size();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if(!objectsPath.isEmpty())
|
||||||
{
|
{
|
||||||
objectsLoaded = findObject->loadObjects(objectsPath);
|
objectsLoaded = findObject->loadObjects(objectsPath);
|
||||||
if(!objectsLoaded)
|
if(!objectsLoaded)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user