mirror of
https://github.com/introlab/rtabmap.git
synced 2026-10-11 04:19:50 +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_GUI_IDENTIFIER "com.introlab.rtabmap"
|
||||||
MACOSX_BUNDLE_BUNDLE_NAME "${CMAKE_BUNDLE_NAME}")
|
MACOSX_BUNDLE_BUNDLE_NAME "${CMAKE_BUNDLE_NAME}")
|
||||||
ELSEIF(WIN32 AND BUILD_AS_BUNDLE)
|
ELSEIF(WIN32 AND BUILD_AS_BUNDLE)
|
||||||
# not using WIN32 keyword to see fatal errors in the console
|
ADD_EXECUTABLE(rtabmap_app WIN32 ${SRC_FILES})
|
||||||
# (in particular when zed's neural dlls are not found)
|
|
||||||
ADD_EXECUTABLE(rtabmap_app ${SRC_FILES})
|
|
||||||
ELSE()
|
ELSE()
|
||||||
ADD_EXECUTABLE(rtabmap_app ${SRC_FILES})
|
ADD_EXECUTABLE(rtabmap_app ${SRC_FILES})
|
||||||
ENDIF()
|
ENDIF()
|
||||||
|
|||||||
@@ -81,6 +81,15 @@ public:
|
|||||||
void postInterIMUPublic(const IMU & imu, double stamp);
|
void postInterIMUPublic(const IMU & imu, double stamp);
|
||||||
void setRightGrayScale(bool enabled = true);
|
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:
|
protected:
|
||||||
virtual SensorData captureImage(SensorCaptureInfo * info = 0);
|
virtual SensorData captureImage(SensorCaptureInfo * info = 0);
|
||||||
|
|
||||||
|
|||||||
@@ -454,6 +454,33 @@ CameraStereoZed::~CameraStereoZed()
|
|||||||
#endif
|
#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)
|
bool CameraStereoZed::init(const std::string & calibrationFolder, const std::string & cameraName)
|
||||||
{
|
{
|
||||||
UDEBUG("");
|
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 "
|
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 "
|
"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);
|
"(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;
|
zed_ = 0;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -532,7 +562,11 @@ bool CameraStereoZed::init(const std::string & calibrationFolder, const std::str
|
|||||||
|
|
||||||
if(r!=sl::ERROR_CODE::SUCCESS)
|
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());
|
UERROR("Camera initialization failed: \"%s\"", toString(r).c_str());
|
||||||
|
#endif
|
||||||
delete zed_;
|
delete zed_;
|
||||||
zed_ = 0;
|
zed_ = 0;
|
||||||
return false;
|
return false;
|
||||||
@@ -569,7 +603,11 @@ bool CameraStereoZed::init(const std::string & calibrationFolder, const std::str
|
|||||||
#endif
|
#endif
|
||||||
if(r!=sl::ERROR_CODE::SUCCESS)
|
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());
|
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)
|
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!");
|
UERROR("CameraStereoZed: Failed to grab images after 2 seconds!");
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -263,6 +263,9 @@ public:
|
|||||||
PreferencesDialog::Src getSourceDriver() const;
|
PreferencesDialog::Src getSourceDriver() const;
|
||||||
QString getSourceDriverStr() const;
|
QString getSourceDriverStr() const;
|
||||||
QString getSourceDevice() 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 getLidarSourceDriver() const;
|
||||||
PreferencesDialog::Src getOdomSourceDriver() const;
|
PreferencesDialog::Src getOdomSourceDriver() const;
|
||||||
|
|
||||||
|
|||||||
@@ -79,6 +79,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
#include <QFileDialog>
|
#include <QFileDialog>
|
||||||
#include <QProgressDialog>
|
#include <QProgressDialog>
|
||||||
|
#include <QLabel>
|
||||||
#include <QGraphicsEllipseItem>
|
#include <QGraphicsEllipseItem>
|
||||||
#include <QDockWidget>
|
#include <QDockWidget>
|
||||||
#include <QtCore/QBuffer>
|
#include <QtCore/QBuffer>
|
||||||
@@ -5936,7 +5937,20 @@ void MainWindow::startDetection()
|
|||||||
// Creating the sensors below opens the devices (createLidar/createCamera/createOdomSensor ->
|
// 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
|
// 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.
|
// => 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.setWindowModality(Qt::ApplicationModal);
|
||||||
progress.setCancelButton(0);
|
progress.setCancelButton(0);
|
||||||
progress.setMinimumDuration(0);
|
progress.setMinimumDuration(0);
|
||||||
|
|||||||
@@ -50,6 +50,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||||||
#include <QMainWindow>
|
#include <QMainWindow>
|
||||||
#include <QProgressDialog>
|
#include <QProgressDialog>
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
|
#include <QLabel>
|
||||||
#include <functional>
|
#include <functional>
|
||||||
#include <QScrollBar>
|
#include <QScrollBar>
|
||||||
#include <QStatusBar>
|
#include <QStatusBar>
|
||||||
@@ -6654,6 +6655,16 @@ QString PreferencesDialog::getSourceDriverStr() const
|
|||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString PreferencesDialog::getSourceInitWarningMsg() const
|
||||||
|
{
|
||||||
|
if(getSourceDriver() == kSrcStereoZed)
|
||||||
|
{
|
||||||
|
return QString::fromStdString(
|
||||||
|
CameraStereoZed::getNeuralModelWarning(_ui->comboBox_stereoZed_quality->currentIndex()));
|
||||||
|
}
|
||||||
|
return QString();
|
||||||
|
}
|
||||||
|
|
||||||
QString PreferencesDialog::getSourceDevice() const
|
QString PreferencesDialog::getSourceDevice() const
|
||||||
{
|
{
|
||||||
return _ui->lineEdit_sourceDevice->text();
|
return _ui->lineEdit_sourceDevice->text();
|
||||||
@@ -7747,10 +7758,20 @@ void PreferencesDialog::setSLAMMode(bool enabled)
|
|||||||
|
|
||||||
void PreferencesDialog::testOdometry()
|
void PreferencesDialog::testOdometry()
|
||||||
{
|
{
|
||||||
// One progress dialog, reused for both the (slow) camera init and the (slow) close.
|
QString startLabel = tr("Starting camera...");
|
||||||
// Declared here so it outlives cameraThread below and stays visible while cameraThread's
|
QString initWarn = getSourceInitWarningMsg();
|
||||||
// destructor closes the device at function scope end.
|
if(!initWarn.isEmpty())
|
||||||
QProgressDialog progress(tr("Starting camera..."), QString(), 0, 0, this);
|
{
|
||||||
|
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.setWindowModality(Qt::ApplicationModal);
|
||||||
progress.setCancelButton(0);
|
progress.setCancelButton(0);
|
||||||
progress.setMinimumDuration(0);
|
progress.setMinimumDuration(0);
|
||||||
@@ -7924,10 +7945,20 @@ void PreferencesDialog::testCamera()
|
|||||||
window->resize(1280, 480+QPushButton().minimumHeight());
|
window->resize(1280, 480+QPushButton().minimumHeight());
|
||||||
window->registerToEventsManager();
|
window->registerToEventsManager();
|
||||||
|
|
||||||
// One progress dialog, reused for both the (slow) camera init and the (slow) close.
|
QString startLabel = tr("Starting camera...");
|
||||||
// min==max==0 => indeterminate/busy bar. Declared in this outer scope so it outlives
|
QString initWarn = getSourceInitWarningMsg();
|
||||||
// cameraThread below and stays visible while cameraThread's destructor closes the device.
|
if(!initWarn.isEmpty())
|
||||||
QProgressDialog progress(tr("Starting camera..."), QString(), 0, 0, this);
|
{
|
||||||
|
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.setWindowModality(Qt::ApplicationModal);
|
||||||
progress.setCancelButton(0);
|
progress.setCancelButton(0);
|
||||||
progress.setMinimumDuration(0);
|
progress.setMinimumDuration(0);
|
||||||
@@ -8476,10 +8507,7 @@ void PreferencesDialog::testLidar()
|
|||||||
window->registerToEventsManager();
|
window->registerToEventsManager();
|
||||||
window->setDecimation(1);
|
window->setDecimation(1);
|
||||||
|
|
||||||
// One progress dialog, reused for both the (slow) sensor init and the (slow) close.
|
QProgressDialog progress(tr("Starting lidar..."), QString(), 0, 0, this);
|
||||||
// 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);
|
|
||||||
progress.setWindowModality(Qt::ApplicationModal);
|
progress.setWindowModality(Qt::ApplicationModal);
|
||||||
progress.setCancelButton(0);
|
progress.setCancelButton(0);
|
||||||
progress.setMinimumDuration(0);
|
progress.setMinimumDuration(0);
|
||||||
|
|||||||
Reference in New Issue
Block a user