mirror of
https://github.com/introlab/rtabmap.git
synced 2026-10-04 17:17:47 +08:00
found a way to expose ZED model downloads
This commit is contained in:
@@ -42,9 +42,7 @@ IF(APPLE AND BUILD_AS_BUNDLE)
|
||||
MACOSX_BUNDLE_GUI_IDENTIFIER "com.introlab.rtabmap"
|
||||
MACOSX_BUNDLE_BUNDLE_NAME "${CMAKE_BUNDLE_NAME}")
|
||||
ELSEIF(WIN32 AND BUILD_AS_BUNDLE)
|
||||
# not using WIN32 keyword to see fatal errors in the console
|
||||
# (in particular when zed's neural dlls are not found)
|
||||
ADD_EXECUTABLE(rtabmap_app ${SRC_FILES})
|
||||
ADD_EXECUTABLE(rtabmap_app WIN32 ${SRC_FILES})
|
||||
ELSE()
|
||||
ADD_EXECUTABLE(rtabmap_app ${SRC_FILES})
|
||||
ENDIF()
|
||||
|
||||
@@ -81,6 +81,15 @@ public:
|
||||
void postInterIMUPublic(const IMU & imu, double stamp);
|
||||
void setRightGrayScale(bool enabled = true);
|
||||
|
||||
/**
|
||||
* If the given ZED depth mode (quality: same encoding as the constructor) is a NEURAL mode
|
||||
* whose AI model isn't yet downloaded/optimized for the GPU, returns a human-readable warning
|
||||
* that the first start will be slower (the ZED SDK downloads/optimizes the model during
|
||||
* init()). Returns an empty string when the model is ready, the mode isn't neural, or the
|
||||
* SDK/build doesn't support the check.
|
||||
*/
|
||||
static std::string getNeuralModelWarning(int quality);
|
||||
|
||||
protected:
|
||||
virtual SensorData captureImage(SensorCaptureInfo * info = 0);
|
||||
|
||||
|
||||
@@ -454,6 +454,33 @@ CameraStereoZed::~CameraStereoZed()
|
||||
#endif
|
||||
}
|
||||
|
||||
std::string CameraStereoZed::getNeuralModelWarning(int quality)
|
||||
{
|
||||
(void)quality;
|
||||
#if defined(RTABMAP_ZED) && ZED_SDK_MAJOR_VERSION >= 5
|
||||
sl::DEPTH_MODE depthMode = (sl::DEPTH_MODE)quality;
|
||||
if(depthMode == sl::DEPTH_MODE::NEURAL_LIGHT ||
|
||||
depthMode == sl::DEPTH_MODE::NEURAL ||
|
||||
depthMode == sl::DEPTH_MODE::NEURAL_PLUS)
|
||||
{
|
||||
sl::AI_MODELS aiModel =
|
||||
depthMode == sl::DEPTH_MODE::NEURAL_LIGHT ? sl::AI_MODELS::NEURAL_LIGHT_DEPTH :
|
||||
depthMode == sl::DEPTH_MODE::NEURAL_PLUS ? sl::AI_MODELS::NEURAL_PLUS_DEPTH :
|
||||
sl::AI_MODELS::NEURAL_DEPTH;
|
||||
sl::AI_Model_status status = sl::checkAIModelStatus(aiModel);
|
||||
if(!status.downloaded || !status.optimized)
|
||||
{
|
||||
return uFormat("The selected ZED NEURAL depth model is not ready yet (downloaded=%s, "
|
||||
"optimized=%s): the first start may take significantly longer while the "
|
||||
"ZED SDK downloads and/or optimizes the model for your GPU. Subsequent "
|
||||
"starts will be faster.",
|
||||
status.downloaded?"true":"false", status.optimized?"true":"false");
|
||||
}
|
||||
}
|
||||
#endif
|
||||
return std::string();
|
||||
}
|
||||
|
||||
bool CameraStereoZed::init(const std::string & calibrationFolder, const std::string & cameraName)
|
||||
{
|
||||
UDEBUG("");
|
||||
@@ -524,7 +551,10 @@ bool CameraStereoZed::init(const std::string & calibrationFolder, const std::str
|
||||
UERROR("ZED open() returned \"%s\": the optional NEURAL/TensorRT runtime files are "
|
||||
"likely missing. Install ZED SDK %d.%d, or select a non-NEURAL depth mode "
|
||||
"(e.g. PERFORMANCE).", toString(r).c_str(), ZED_SDK_MAJOR_VERSION, ZED_SDK_MINOR_VERSION);
|
||||
delete zed_;
|
||||
// Do NOT delete zed_ here: after a CORRUPTED_SDK_INSTALLATION open failure (NEURAL depth
|
||||
// mode selected but the TensorRT/neural runtime isn't installed) the ZED SDK is left in a
|
||||
// bad state and ~sl::Camera() crashes inside sl_zed64.dll. Leak the object (one-time,
|
||||
// terminal error path) so we fail gracefully with the message above instead of crashing.
|
||||
zed_ = 0;
|
||||
return false;
|
||||
}
|
||||
@@ -532,7 +562,11 @@ bool CameraStereoZed::init(const std::string & calibrationFolder, const std::str
|
||||
|
||||
if(r!=sl::ERROR_CODE::SUCCESS)
|
||||
{
|
||||
#if ZED_SDK_MAJOR_VERSION >= 4
|
||||
UERROR("Camera initialization failed: \"%s\": %s", toString(r).c_str(), toVerbose(r).c_str());
|
||||
#else
|
||||
UERROR("Camera initialization failed: \"%s\"", toString(r).c_str());
|
||||
#endif
|
||||
delete zed_;
|
||||
zed_ = 0;
|
||||
return false;
|
||||
@@ -569,7 +603,11 @@ bool CameraStereoZed::init(const std::string & calibrationFolder, const std::str
|
||||
#endif
|
||||
if(r!=sl::ERROR_CODE::SUCCESS)
|
||||
{
|
||||
#if ZED_SDK_MAJOR_VERSION >= 4
|
||||
UERROR("Camera tracking initialization failed: \"%s\": %s", toString(r).c_str(), toVerbose(r).c_str());
|
||||
#else
|
||||
UERROR("Camera tracking initialization failed: \"%s\"", toString(r).c_str());
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@@ -951,7 +989,11 @@ SensorData CameraStereoZed::captureImage(SensorCaptureInfo * info)
|
||||
}
|
||||
else if(src_ == CameraVideo::kUsbDevice)
|
||||
{
|
||||
#if ZED_SDK_MAJOR_VERSION >= 4
|
||||
UERROR("CameraStereoZed: Failed to grab images after 2 seconds! (%s: %s)", toString(res).c_str(), toVerbose(res).c_str());
|
||||
#else
|
||||
UERROR("CameraStereoZed: Failed to grab images after 2 seconds!");
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -263,6 +263,9 @@ public:
|
||||
PreferencesDialog::Src getSourceDriver() const;
|
||||
QString getSourceDriverStr() const;
|
||||
QString getSourceDevice() const;
|
||||
// Non-empty warning to show before opening the selected source when init() is expected to be
|
||||
// unusually slow; empty otherwise.
|
||||
QString getSourceInitWarningMsg() const;
|
||||
PreferencesDialog::Src getLidarSourceDriver() const;
|
||||
PreferencesDialog::Src getOdomSourceDriver() const;
|
||||
|
||||
|
||||
@@ -79,6 +79,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#include <QMessageBox>
|
||||
#include <QFileDialog>
|
||||
#include <QProgressDialog>
|
||||
#include <QLabel>
|
||||
#include <QGraphicsEllipseItem>
|
||||
#include <QDockWidget>
|
||||
#include <QtCore/QBuffer>
|
||||
@@ -5936,7 +5937,20 @@ void MainWindow::startDetection()
|
||||
// Creating the sensors below opens the devices (createLidar/createCamera/createOdomSensor ->
|
||||
// init(), a few seconds for ZED/RealSense) on the GUI thread; show a busy dialog (min==max==0
|
||||
// => indeterminate) so the window isn't just frozen. Hidden once all sensors are created below.
|
||||
QProgressDialog progress(tr("Starting sensor..."), QString(), 0, 0, this);
|
||||
QString startLabel = tr("Starting sensor...");
|
||||
QString initWarn = _preferencesDialog->getSourceInitWarningMsg();
|
||||
if(!initWarn.isEmpty())
|
||||
{
|
||||
startLabel += "\n\n" + initWarn;
|
||||
}
|
||||
QProgressDialog progress(startLabel, QString(), 0, 0, this);
|
||||
if(!initWarn.isEmpty())
|
||||
{
|
||||
QLabel * wrapLabel = new QLabel(startLabel);
|
||||
wrapLabel->setWordWrap(true);
|
||||
progress.setLabel(wrapLabel); // QProgressDialog takes ownership
|
||||
progress.setMinimumWidth(450);
|
||||
}
|
||||
progress.setWindowModality(Qt::ApplicationModal);
|
||||
progress.setCancelButton(0);
|
||||
progress.setMinimumDuration(0);
|
||||
|
||||
@@ -50,6 +50,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#include <QMainWindow>
|
||||
#include <QProgressDialog>
|
||||
#include <QApplication>
|
||||
#include <QLabel>
|
||||
#include <functional>
|
||||
#include <QScrollBar>
|
||||
#include <QStatusBar>
|
||||
@@ -6654,6 +6655,16 @@ QString PreferencesDialog::getSourceDriverStr() const
|
||||
return "";
|
||||
}
|
||||
|
||||
QString PreferencesDialog::getSourceInitWarningMsg() const
|
||||
{
|
||||
if(getSourceDriver() == kSrcStereoZed)
|
||||
{
|
||||
return QString::fromStdString(
|
||||
CameraStereoZed::getNeuralModelWarning(_ui->comboBox_stereoZed_quality->currentIndex()));
|
||||
}
|
||||
return QString();
|
||||
}
|
||||
|
||||
QString PreferencesDialog::getSourceDevice() const
|
||||
{
|
||||
return _ui->lineEdit_sourceDevice->text();
|
||||
@@ -7747,10 +7758,20 @@ void PreferencesDialog::setSLAMMode(bool enabled)
|
||||
|
||||
void PreferencesDialog::testOdometry()
|
||||
{
|
||||
// One progress dialog, reused for both the (slow) camera init and the (slow) close.
|
||||
// Declared here so it outlives cameraThread below and stays visible while cameraThread's
|
||||
// destructor closes the device at function scope end.
|
||||
QProgressDialog progress(tr("Starting camera..."), QString(), 0, 0, this);
|
||||
QString startLabel = tr("Starting camera...");
|
||||
QString initWarn = getSourceInitWarningMsg();
|
||||
if(!initWarn.isEmpty())
|
||||
{
|
||||
startLabel += "\n\n" + initWarn;
|
||||
}
|
||||
QProgressDialog progress(startLabel, QString(), 0, 0, this);
|
||||
if(!initWarn.isEmpty())
|
||||
{
|
||||
QLabel * wrapLabel = new QLabel(startLabel);
|
||||
wrapLabel->setWordWrap(true);
|
||||
progress.setLabel(wrapLabel); // QProgressDialog takes ownership
|
||||
progress.setMinimumWidth(450);
|
||||
}
|
||||
progress.setWindowModality(Qt::ApplicationModal);
|
||||
progress.setCancelButton(0);
|
||||
progress.setMinimumDuration(0);
|
||||
@@ -7924,10 +7945,20 @@ void PreferencesDialog::testCamera()
|
||||
window->resize(1280, 480+QPushButton().minimumHeight());
|
||||
window->registerToEventsManager();
|
||||
|
||||
// One progress dialog, reused for both the (slow) camera init and the (slow) close.
|
||||
// min==max==0 => indeterminate/busy bar. Declared in this outer scope so it outlives
|
||||
// cameraThread below and stays visible while cameraThread's destructor closes the device.
|
||||
QProgressDialog progress(tr("Starting camera..."), QString(), 0, 0, this);
|
||||
QString startLabel = tr("Starting camera...");
|
||||
QString initWarn = getSourceInitWarningMsg();
|
||||
if(!initWarn.isEmpty())
|
||||
{
|
||||
startLabel += "\n\n" + initWarn;
|
||||
}
|
||||
QProgressDialog progress(startLabel, QString(), 0, 0, this);
|
||||
if(!initWarn.isEmpty())
|
||||
{
|
||||
QLabel * wrapLabel = new QLabel(startLabel);
|
||||
wrapLabel->setWordWrap(true);
|
||||
progress.setLabel(wrapLabel); // QProgressDialog takes ownership
|
||||
progress.setMinimumWidth(450);
|
||||
}
|
||||
progress.setWindowModality(Qt::ApplicationModal);
|
||||
progress.setCancelButton(0);
|
||||
progress.setMinimumDuration(0);
|
||||
@@ -8476,10 +8507,7 @@ void PreferencesDialog::testLidar()
|
||||
window->registerToEventsManager();
|
||||
window->setDecimation(1);
|
||||
|
||||
// One progress dialog, reused for both the (slow) sensor init and the (slow) close.
|
||||
// Declared in this outer scope so it outlives lidarThread below and stays visible while
|
||||
// lidarThread's destructor closes the device.
|
||||
QProgressDialog progress(tr("Starting sensor..."), QString(), 0, 0, this);
|
||||
QProgressDialog progress(tr("Starting lidar..."), QString(), 0, 0, this);
|
||||
progress.setWindowModality(Qt::ApplicationModal);
|
||||
progress.setCancelButton(0);
|
||||
progress.setMinimumDuration(0);
|
||||
|
||||
Reference in New Issue
Block a user