diff --git a/src/qtAliceVision/SequenceCache.cpp b/src/qtAliceVision/SequenceCache.cpp index b494f952..d56df479 100644 --- a/src/qtAliceVision/SequenceCache.cpp +++ b/src/qtAliceVision/SequenceCache.cpp @@ -10,6 +10,8 @@ #include #include #include +#include +#include namespace qtAliceVision { @@ -53,25 +55,33 @@ void SequenceCache::setSequence(const QVariantList& paths) // Fill sequence vector for (const auto& var : paths) { - // Initialize frame data - FrameData data; - data.path = var.toString().toStdString(); + try + { + // Initialize frame data + FrameData data; + data.path = var.toString().toStdString(); - // Retrieve metadata from disk - int width, height; - auto metadata = aliceVision::image::readImageMetadata(data.path, width, height); + // Retrieve metadata from disk + int width, height; + auto metadata = aliceVision::image::readImageMetadata(data.path, width, height); - // Store original image dimensions - data.dim = QSize(width, height); + // Store original image dimensions + data.dim = QSize(width, height); - // Copy metadata into a QVariantMap - for (const auto& item : metadata) + // Copy metadata into a QVariantMap + for (const auto& item : metadata) + { + data.metadata[QString::fromStdString(item.name().string())] = QString::fromStdString(item.get_string()); + } + + // Add to sequence + _sequence.push_back(data); + } + catch (const std::runtime_error& e) { - data.metadata[QString::fromStdString(item.name().string())] = QString::fromStdString(item.get_string()); + // Log error + std::cerr << e.what() << std::endl; } - - // Add to sequence - _sequence.push_back(data); } // Sort sequence by filepaths @@ -313,10 +323,18 @@ void PrefetchingIORunnable::run() } // Load image in cache - const bool cachedOnly = false; - const bool lazyCleaning = false; - _cache->get(data.path, 1, cachedOnly, lazyCleaning); - filled += memSize; + try + { + const bool cachedOnly = false; + const bool lazyCleaning = false; + _cache->get(data.path, 1, cachedOnly, lazyCleaning); + filled += memSize; + } + catch (const std::runtime_error& e) + { + // Log error message + std::cerr << e.what() << std::endl; + } // Wait a few milliseconds in case another thread needs to query the cache std::this_thread::sleep_for(1ms); diff --git a/src/qtAliceVision/SingleImageLoader.cpp b/src/qtAliceVision/SingleImageLoader.cpp index 28c8291a..12f1484c 100644 --- a/src/qtAliceVision/SingleImageLoader.cpp +++ b/src/qtAliceVision/SingleImageLoader.cpp @@ -2,6 +2,9 @@ #include +#include +#include + namespace qtAliceVision { namespace imgserve { @@ -63,22 +66,30 @@ void SingleImageLoadingIORunnable::run() { Response response; - // Retrieve metadata from disk - int width, height; - auto metadata = aliceVision::image::readImageMetadata(_path, width, height); - - // Store original image dimensions - response.dim = QSize(width, height); - - // Copy metadata into a QVariantMap - for (const auto& item : metadata) + try { - response.metadata[QString::fromStdString(item.name().string())] = QString::fromStdString(item.get_string()); + // Retrieve metadata from disk + int width, height; + auto metadata = aliceVision::image::readImageMetadata(_path, width, height); + + // Store original image dimensions + response.dim = QSize(width, height); + + // Copy metadata into a QVariantMap + for (const auto& item : metadata) + { + response.metadata[QString::fromStdString(item.name().string())] = QString::fromStdString(item.get_string()); + } + + // Load image + response.img = std::make_shared>(); + aliceVision::image::readImage(_path, *(response.img), aliceVision::image::EImageColorSpace::LINEAR); + } + catch (const std::runtime_error& e) + { + // Log error message + std::cerr << e.what() << std::endl; } - - // Load image - response.img = std::make_shared>(); - aliceVision::image::readImage(_path, *(response.img), aliceVision::image::EImageColorSpace::LINEAR); // Notify listeners that loading is finished Q_EMIT done(QString::fromStdString(_path), response);