Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 11 additions & 8 deletions src/qtAliceVision/FloatImageViewer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -589,16 +589,19 @@ QSGNode* FloatImageViewer::updatePaintNode(QSGNode* oldNode, [[maybe_unused]] QQ
{
_boundingRect = newBoundingRect;

const float windowRatio = static_cast<float>(_boundingRect.width()) / static_cast<float>(_boundingRect.height());
const float textureRatio = static_cast<float>(_textureSize.width()) / static_cast<float>(_textureSize.height());
QRectF geometryRect = _boundingRect;
if (windowRatio > textureRatio)
if (_boundingRect.height() > 0 && _textureSize.height() > 0)
{
geometryRect.setWidth(geometryRect.height() * textureRatio);
}
else
{
geometryRect.setHeight(geometryRect.width() / textureRatio);
const float windowRatio = static_cast<float>(_boundingRect.width()) / static_cast<float>(_boundingRect.height());
const float textureRatio = static_cast<float>(_textureSize.width()) / static_cast<float>(_textureSize.height());
if (windowRatio > textureRatio)
{
geometryRect.setWidth(geometryRect.height() * textureRatio);
}
else
{
geometryRect.setHeight(geometryRect.width() / textureRatio);
}
}
geometryRect.moveCenter(_boundingRect.center());

Expand Down
11 changes: 9 additions & 2 deletions src/qtAliceVision/FloatTexture.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,19 @@ FloatTexture::~FloatTexture()
void FloatTexture::setImage(std::shared_ptr<FloatImage>& image)
{
_srcImage = image;
_textureSize = {_srcImage->width(), _srcImage->height()};
if (_srcImage)
{
_textureSize = {_srcImage->width(), _srcImage->height()};
}
else
{
_textureSize = {};
}
_dirty = true;
_mipmapsGenerated = false;
}

bool FloatTexture::isValid() const { return _srcImage->width() != 0 && _srcImage->height() != 0; }
bool FloatTexture::isValid() const { return _srcImage && _srcImage->width() != 0 && _srcImage->height() != 0; }

qint64 FloatTexture::comparisonKey() const { return _rhiTexture ? _rhiTexture->nativeTexture().object : 0; }

Expand Down
4 changes: 3 additions & 1 deletion src/qtAliceVision/ImageCache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,9 @@ void ImageCache::cleanup(size_t requestedSize, const CacheKey& toAdd)
// After the frameId, the largest the difference, the highest its priority to delete
if (diff < 0)
{
diff = std::numeric_limits<int>::max() + diff;
// Wrap negative differences to sort them after positive ones.
// Use unsigned arithmetic to avoid signed integer overflow (UB).
diff = static_cast<int>(static_cast<unsigned int>(std::numeric_limits<int>::max()) + static_cast<unsigned int>(diff));
}

orderedKeys[diff] = &key;
Expand Down
9 changes: 9 additions & 0 deletions src/qtAliceVision/MSfMData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,11 @@ void MSfMData::load()

QString MSfMData::getUrlFromViewId(int viewId)
{
if (!_sfmData)
{
qWarning() << "[QtAliceVision] MSfMData::getUrlFromViewId: no SfMData loaded.";
return {};
}
return QString::fromUtf8(_sfmData->getView(aliceVision::IndexT(viewId)).getImage().getImagePath().c_str());
}

Expand Down Expand Up @@ -119,6 +124,10 @@ size_t MSfMData::nbCameras() const
QVariantList MSfMData::getViewsIds() const
{
QVariantList viewsIds;
if (!_sfmData || _status != Ready)
{
return viewsIds;
}
for (const auto& id : _sfmData->getValidViews())
{
viewsIds.append(id);
Expand Down
12 changes: 4 additions & 8 deletions src/qtAliceVision/MTracks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,11 @@ void TracksDirectIORunnable::run()

if (!aliceVision::track::loadTracks(*tracks, _filename))
{
if (tracks)
{
delete tracks;
}
delete tracks;
delete tracksPerView;

if (tracksPerView)
{
delete tracksPerView;
}
Q_EMIT resultReady(nullptr, nullptr);
return;
}

aliceVision::track::computeTracksPerView(*tracks, *tracksPerView);
Expand Down
18 changes: 12 additions & 6 deletions src/qtAliceVision/MViewStats.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ void MViewStats::fillResidualFullSerie(QXYSeries* residuals)

if (residualHistX.size() != residualHistY.size())
{
throw std::runtime_error("MViewStats::fillResidualFullSerie: residualHistX & residualHistY size mismatch.");
qWarning() << "[QtAliceVision] MViewStats::fillResidualFullSerie: residualHistX & residualHistY size mismatch.";
return;
}
QPen pen(Qt::red, 1, Qt::DashLine, Qt::FlatCap, Qt::BevelJoin);

Expand Down Expand Up @@ -69,7 +70,8 @@ void MViewStats::fillResidualViewSerie(QXYSeries* residuals)
std::vector<size_t> residualHistY = _residualHistogramView.GetHist();
if (residualHistX.size() != residualHistY.size())
{
throw std::runtime_error("MViewStats::fillResidualViewSerie: residualHistX & residualHistY size mismatch.");
qWarning() << "[QtAliceVision] MViewStats::fillResidualViewSerie: residualHistX & residualHistY size mismatch.";
return;
}
QPen pen(Qt::darkBlue, 3, Qt::SolidLine, Qt::FlatCap, Qt::BevelJoin);

Expand Down Expand Up @@ -104,7 +106,8 @@ void MViewStats::fillObservationsLengthsFullSerie(QXYSeries* observationsLengths
std::vector<size_t> observationsLengthsHistY = _observationsLengthsHistogramFull.GetHist();
if (observationsLengthsHistX.size() != observationsLengthsHistY.size())
{
throw std::runtime_error("MViewStats::fillObservationsLengthsFullSerie: observationsLengthsHistX & observationsLengthsHistY size mismatch.");
qWarning() << "[QtAliceVision] MViewStats::fillObservationsLengthsFullSerie: observationsLengthsHistX & observationsLengthsHistY size mismatch.";
return;
}
QPen pen(Qt::red, 1, Qt::DashLine, Qt::FlatCap, Qt::BevelJoin);

Expand Down Expand Up @@ -139,7 +142,8 @@ void MViewStats::fillObservationsLengthsViewSerie(QXYSeries* observationsLengths
std::vector<size_t> observationsLengthsHistY = _observationsLengthsHistogramView.GetHist();
if (observationsLengthsHistX.size() != observationsLengthsHistY.size())
{
throw std::runtime_error("MViewStats::fillObservationsLengthsViewSerie: observationsLengthsHistX & observationsLengthsHistY size mismatch.");
qWarning() << "[QtAliceVision] MViewStats::fillObservationsLengthsViewSerie: observationsLengthsHistX & observationsLengthsHistY size mismatch.";
return;
}
QPen pen(Qt::darkBlue, 3, Qt::SolidLine, Qt::FlatCap, Qt::BevelJoin);

Expand Down Expand Up @@ -174,7 +178,8 @@ void MViewStats::fillObservationsScaleFullSerie(QXYSeries* observationsScale)
std::vector<size_t> observationsScaleHistY = _observationsScaleHistogramFull.GetHist();
if (observationsScaleHistX.size() != observationsScaleHistY.size())
{
throw std::runtime_error("MViewStats::fillObservationsScaleFullSerie: observationsScaleHistX & observationsScaleHistY size mismatch.");
qWarning() << "[QtAliceVision] MViewStats::fillObservationsScaleFullSerie: observationsScaleHistX & observationsScaleHistY size mismatch.";
return;
}
QPen pen(Qt::red, 1, Qt::DashLine, Qt::FlatCap, Qt::BevelJoin);

Expand Down Expand Up @@ -209,7 +214,8 @@ void MViewStats::fillObservationsScaleViewSerie(QXYSeries* observationsScale)
std::vector<size_t> observationsScaleHistY = _observationsScaleHistogramView.GetHist();
if (observationsScaleHistX.size() != observationsScaleHistY.size())
{
throw std::runtime_error("MViewStats::fillObservationsScaleViewSerie: observationsScaleHistX & observationsScaleHistY size mismatch.");
qWarning() << "[QtAliceVision] MViewStats::fillObservationsScaleViewSerie: observationsScaleHistX & observationsScaleHistY size mismatch.";
return;
}
QPen pen(Qt::darkBlue, 3, Qt::SolidLine, Qt::FlatCap, Qt::BevelJoin);

Expand Down
2 changes: 1 addition & 1 deletion src/qtAliceVision/PhongImageViewer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ void PhongImageViewer::reload()
}

// check source and normal images dimensions
if (responseSourceImage.dim != responseSourceImage.dim)
if (responseSourceImage.dim != responseNormalImage.dim)
{
clearImages();
setStatus(EStatus::LOADING_ERROR);
Expand Down
2 changes: 1 addition & 1 deletion src/qtAliceVision/SequenceCache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ QPointF SequenceCache::getRamInfo() const
const auto memInfo = aliceVision::system::getMemoryInfo();

double availableRam = static_cast<double>(memInfo.availableRam) / (1024. * 1024. * 1024.);
double contentSize = static_cast<double>(_fetcher.getCacheSize()) / (1024. * 1024. * 1024. * 1024.);
double contentSize = static_cast<double>(_fetcher.getCacheSize()) / (1024. * 1024. * 1024.);

// Return in GB
return QPointF(availableRam, contentSize);
Expand Down
2 changes: 1 addition & 1 deletion src/qtAliceVision/Surface.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ class Surface : public QObject
bool _needToUseIntrinsic = true;

// Id View
aliceVision::IndexT _idView;
aliceVision::IndexT _idView = aliceVision::UndefinedIndexT;

// Viewer
EViewerType _viewerType = EViewerType::DEFAULT;
Expand Down
10 changes: 9 additions & 1 deletion src/qtAliceVisionImageIO/QtAliceVisionImageIOHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,15 @@

qDebug() << "[QtAliceVisionImageIO] Read image: " << path.c_str();
aliceVision::image::Image<aliceVision::image::RGBColor> img;
aliceVision::image::readImage(path, img, aliceVision::image::EImageColorSpace::SRGB);
try
{
aliceVision::image::readImage(path, img, aliceVision::image::EImageColorSpace::SRGB);
}
catch (const std::exception& e)

Check warning on line 86 in src/qtAliceVisionImageIO/QtAliceVisionImageIOHandler.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Catch a more specific exception instead of a generic one.

See more on https://sonarcloud.io/project/issues?id=alicevision_QtAliceVision&issues=AZ2u9fjbkb8XHn6chqeJ&open=AZ2u9fjbkb8XHn6chqeJ&pullRequest=96
{
qWarning() << "[QtAliceVisionImageIO] Failed to read image:" << e.what();
return false;
}

oiio::ImageBuf inBuf;
aliceVision::image::getBufferFromImage(img, inBuf);
Expand Down