Added General/autoScreenshotPath option

This commit is contained in:
matlabbe 2017-03-15 11:48:36 -04:00
parent 1f44524b9d
commit dc042fe418
2 changed files with 26 additions and 1 deletions

View File

@ -283,6 +283,7 @@ class FINDOBJECT_EXP Settings
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, true, "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(General, autoScreenshotPath, QString, "", "Path to a directory to save screenshot of the current camera view when there is a detection.");
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.");
PARAMETER(Homography, method, QString, "1:LMEDS;RANSAC;RHO", "Type of the robust estimation algorithm: least-median algorithm or RANSAC algorithm."); PARAMETER(Homography, method, QString, "1:LMEDS;RANSAC;RHO", "Type of the robust estimation algorithm: least-median algorithm or RANSAC algorithm.");

View File

@ -1362,7 +1362,7 @@ void MainWindow::update(const cv::Mat & image)
} }
} }
if(camera_->isRunning() && Settings::getGeneral_autoPauseOnDetection() && info.objDetected_.size()) if(info.objDetected_.size() && camera_->isRunning() && Settings::getGeneral_autoPauseOnDetection())
{ {
this->pauseProcessing(); this->pauseProcessing();
} }
@ -1426,6 +1426,30 @@ void MainWindow::update(const cv::Mat & image)
} }
} }
// save screenshot of the detection
if(info.objDetected_.size() && !Settings::getGeneral_autoScreenshotPath().isEmpty())
{
QDir dir(Settings::getGeneral_autoScreenshotPath());
if(!dir.exists())
{
QMessageBox::warning(this, tr("Screenshot on detection"), tr("Directory \"%1\" doesn't "
"exist, screenshot of the detection cannot be taken. Parameter \"%2\" is cleared.").arg(Settings::getGeneral_autoScreenshotPath()).arg(Settings::kGeneral_autoScreenshotPath()));
Settings::setGeneral_autoScreenshotPath("");
ui_->toolBox->updateParameter(Settings::kGeneral_autoScreenshotPath());
}
else
{
QString path = Settings::getGeneral_autoScreenshotPath() + QDir::separator() + (QDateTime::currentDateTime().toString("yyMMddhhmmsszzz") + ".jpg");
if(!ui_->imageView_source->getSceneAsPixmap().save(path))
{
UDEBUG("Failed to save screenshot \"%s\"! (%s is set)", path.toStdString().c_str(), Settings::kGeneral_autoScreenshotPath().toStdString().c_str());
}
else
{
UINFO("Save screenshot \"%s\"! (%s is set)", path.toStdString().c_str(), Settings::kGeneral_autoScreenshotPath().toStdString().c_str());
}
}
}
//update likelihood plot //update likelihood plot
UDEBUG("Set likelihood score curve values (%d)", scores.size()); UDEBUG("Set likelihood score curve values (%d)", scores.size());