Skip to content

Commit

Permalink
Merge pull request #774 from alicevision/dev/stats
Browse files Browse the repository at this point in the history
SfM statistics
  • Loading branch information
simogasp authored May 28, 2020
2 parents 7c31264 + 5e327d8 commit dc42aed
Show file tree
Hide file tree
Showing 43 changed files with 1,320 additions and 775 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
build:
runs-on: ubuntu-latest
container:
image: alicevision/alicevision-deps:ci-2020.05.12-centos7-cuda9.0
image: alicevision/alicevision-deps:ci-2020.05.16-centos7-cuda9.0
env:
DEPS_INSTALL_DIR: /opt/AliceVision_install
BUILD_TYPE: Release
Expand Down
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -514,7 +514,7 @@ if(AV_BUILD_CCTAG)
set(CCTAG_TARGET cctag)
ExternalProject_Add(${CCTAG_TARGET}
GIT_REPOSITORY https://github.com/alicevision/CCTag
GIT_TAG e73cd5e88b05b551e0d67c2607b1216937b938c9
GIT_TAG c8bebbbd15ba450bd7655f87aba34ab0c2d32f57
PREFIX ${BUILD_DIR}
BUILD_IN_SOURCE 0
BUILD_ALWAYS 0
Expand All @@ -533,7 +533,7 @@ if(AV_BUILD_POPSIFT)
set(POPSIFT_TARGET popsift)
ExternalProject_Add(${POPSIFT_TARGET}
GIT_REPOSITORY https://github.com/alicevision/popsift
GIT_TAG 3e624d203d660784ded087700dbe9cb41224c4e1
GIT_TAG 7fc809b73ff0313320013465e2f8b1af4f9d63a8
PREFIX ${BUILD_DIR}
BUILD_IN_SOURCE 0
BUILD_ALWAYS 0
Expand Down
12 changes: 12 additions & 0 deletions src/aliceVision/alicevision_omp.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,15 @@ inline void omp_destroy_lock(omp_lock_t *lock) {}
inline void omp_set_lock(omp_lock_t *lock) {}
inline void omp_unset_lock(omp_lock_t *lock) {}
#endif

// OpenMP >= 3.1 for advanced atomic clauses (https://software.intel.com/en-us/node/608160)
// OpenMP preprocessor version: https://github.com/jeffhammond/HPCInfo/wiki/Preprocessor-Macros
#if defined _OPENMP && _OPENMP >= 201107
#define OMP_ATOMIC_UPDATE _Pragma("omp atomic update")
#define OMP_ATOMIC_WRITE _Pragma("omp atomic write")
#define OMP_HAVE_MIN_MAX_REDUCTION
#else
#define OMP_ATOMIC_UPDATE _Pragma("omp atomic")
#define OMP_ATOMIC_WRITE _Pragma("omp atomic")
#endif

6 changes: 4 additions & 2 deletions src/aliceVision/colorHarmonization/CommonDataByPair.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@

#pragma once

#include "aliceVision/image/all.hpp"
#include "dependencies/histogram/histogram.hpp"
#include <aliceVision/image/all.hpp>
#include <aliceVision/utils/Histogram.hpp>

#include <string>


namespace aliceVision {
namespace colorHarmonization {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
#include <aliceVision/image/all.hpp>
#include <aliceVision/config.hpp>

#include "dependencies/histogram/histogram.hpp"
#include <aliceVision/utils/Histogram.hpp>
#include "dependencies/htmlDoc/htmlDoc.hpp"

#define BOOST_TEST_MODULE GainOffsetConstraintBuilder
Expand Down
11 changes: 11 additions & 0 deletions src/aliceVision/feature/FeaturesPerView.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,17 @@ class FeaturesPerView
return _data.at(viewId);
}

std::size_t getNbFeatures(IndexT viewId) const
{
MapFeaturesPerDesc f = getFeaturesPerDesc(viewId);
std::size_t count = 0;
for(const auto& it: f)
{
count += it.second.size();
}
return count;
}

const MapFeaturesPerDesc& getDataPerDesc(IndexT viewId) const
{
return _data.at(viewId);
Expand Down
2 changes: 1 addition & 1 deletion src/aliceVision/feature/cctag/ImageDescriber_CCTAG.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ bool ImageDescriber_CCTAG::describe(const image::Image<unsigned char>& image,
}
desc[cctag.id()] = (unsigned char) 255;
regionsCasted->Descriptors().push_back(desc);
const float scale = std::max(cctag.outerEllipse().a(), cctag.outerEllipse().b());
const float scale = std::max(cctag.rescaledOuterEllipse().a(), cctag.rescaledOuterEllipse().b());
regionsCasted->Features().push_back(PointFeature(cctag.x(), cctag.y(), scale, orientation));
}
}
Expand Down
11 changes: 0 additions & 11 deletions src/aliceVision/fuseCut/DelaunayGraphCut.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,6 @@
#include <boost/filesystem.hpp>
#include <boost/filesystem/operations.hpp>

// OpenMP >= 3.1 for advanced atomic clauses (https://software.intel.com/en-us/node/608160)
// OpenMP preprocessor version: https://github.com/jeffhammond/HPCInfo/wiki/Preprocessor-Macros
#if defined _OPENMP && _OPENMP >= 201107
#define OMP_ATOMIC_UPDATE _Pragma("omp atomic update")
#define OMP_ATOMIC_WRITE _Pragma("omp atomic write")
#define OMP_HAVE_MIN_MAX_REDUCTION
#else
#define OMP_ATOMIC_UPDATE _Pragma("omp atomic")
#define OMP_ATOMIC_WRITE _Pragma("omp atomic")
#endif

namespace aliceVision {
namespace fuseCut {

Expand Down
2 changes: 1 addition & 1 deletion src/aliceVision/multiview/rotationAveraging/l1.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -490,7 +490,7 @@ REAL RelRotationAvgError(const RelativeRotations& RelRs, const Matrix3x3Arr& Rs,
const RelativeRotation& relR = RelRs[i];
vec_err[i] = aliceVision::FrobeniusNorm(relR.Rij - (Rs[relR.j]*Rs[relR.i].transpose()));
}
MinMaxMeanMedian<float> stats(vec_err.begin(), vec_err.end());
BoxStats<float> stats(vec_err.begin(), vec_err.end());
if (pMin)
*pMin = stats.min;
if (pMax)
Expand Down
19 changes: 14 additions & 5 deletions src/aliceVision/numeric/numeric.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -452,12 +452,14 @@ inline int is_finite(const double val)
* values of an iterable sequence.
*/
template <typename Type>
struct MinMaxMeanMedian
struct BoxStats
{
Type min, max, mean, median;
Type min{}, max{}, mean{}, median{}, firstQuartile{}, thirdQuartile{};

BoxStats() = default;

template <typename DataInputIterator>
MinMaxMeanMedian(DataInputIterator begin, DataInputIterator end)
BoxStats(DataInputIterator begin, DataInputIterator end)
{
compute(begin, end);
}
Expand All @@ -471,6 +473,8 @@ struct MinMaxMeanMedian
max = 0;
mean = 0;
median = 0;
firstQuartile = 0;
thirdQuartile = 0;
return;
}

Expand All @@ -481,16 +485,21 @@ struct MinMaxMeanMedian
mean = accumulate(vec_val.begin(), vec_val.end(), Type(0))
/ static_cast<Type> (vec_val.size());
median = vec_val[vec_val.size() / 2];
firstQuartile = vec_val[vec_val.size() / 4];
thirdQuartile = vec_val[(vec_val.size() * 3) / 4];
}
};

template <typename Type>
inline std::ostream& operator<<(std::ostream& os, const MinMaxMeanMedian<Type> obj)
inline std::ostream& operator<<(std::ostream& os, const BoxStats<Type> obj)
{
os << "\t min: " << obj.min << "\n"
"\t mean: " << obj.mean << "\n"
"\t median: " << obj.median << "\n"
"\t max: " << obj.max;
"\t max: " << obj.max << "\n"
"\t first quartile: " << obj.firstQuartile << "\n"
"\t third quartile: " << obj.thirdQuartile;

return os;
}

Expand Down
2 changes: 2 additions & 0 deletions src/aliceVision/sfm/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ set(sfm_files_headers
generateReport.hpp
sfm.hpp
sfmFilters.hpp
sfmStatistics.hpp
sfmTriangulation.hpp
)

Expand All @@ -53,6 +54,7 @@ set(sfm_files_sources
FrustumFilter.cpp
generateReport.cpp
sfmFilters.cpp
sfmStatistics.cpp
sfmTriangulation.cpp
)

Expand Down
1 change: 1 addition & 0 deletions src/aliceVision/sfm/LocalBundleAdjustmentGraph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include <aliceVision/stl/stl.hpp>
#include <aliceVision/sfmData/SfMData.hpp>
#include <boost/filesystem.hpp>

#include <lemon/bfs.h>

#include <fstream>
Expand Down
5 changes: 4 additions & 1 deletion src/aliceVision/sfm/LocalBundleAdjustmentGraph.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,12 @@
#pragma once

#include <aliceVision/types.hpp>
#include <aliceVision/track/Track.hpp>
#include <aliceVision/track/TracksBuilder.hpp>
#include <aliceVision/sfm/BundleAdjustment.hpp>

#include <lemon/list_graph.h>


namespace aliceVision {

namespace sfmData {
Expand Down
4 changes: 2 additions & 2 deletions src/aliceVision/sfm/generateReport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
#include "generateReport.hpp"
#include <aliceVision/sfmData/SfMData.hpp>

#include <aliceVision/utils/Histogram.hpp>
#include <dependencies/htmlDoc/htmlDoc.hpp>
#include <dependencies/histogram/histogram.hpp>
#include <dependencies/vectorGraphics/svgDrawer.hpp>

#include <boost/filesystem.hpp>
Expand Down Expand Up @@ -103,7 +103,7 @@ bool generateSfMReport(const sfmData::SfMData& sfmData,
const std::vector<double>& residuals = residuals_per_view.at(id_view);
if(!residuals.empty())
{
MinMaxMeanMedian<double> stats(residuals.begin(), residuals.end());
BoxStats<double> stats(residuals.begin(), residuals.end());
os << sColBegin << residuals.size()/2 << sColEnd // #observations
<< sColBegin << stats.min << sColEnd
<< sColBegin << stats.median << sColEnd
Expand Down
2 changes: 1 addition & 1 deletion src/aliceVision/sfm/pipeline/RigSequence.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#pragma once

#include <aliceVision/sfmData/SfMData.hpp>
#include <aliceVision/track/Track.hpp>
#include <aliceVision/track/TracksBuilder.hpp>

namespace aliceVision {
namespace sfm {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#include <aliceVision/multiview/rotationAveraging/rotationAveraging.hpp>
#include <aliceVision/stl/mapUtils.hpp>

#include <dependencies/histogram/histogram.hpp>
#include <aliceVision/utils/Histogram.hpp>

namespace aliceVision {
namespace sfm {
Expand Down Expand Up @@ -239,7 +239,7 @@ void GlobalSfMRotationAveragingSolver::TripletRotationRejection(

// Display statistics about rotation triplets error:
ALICEVISION_LOG_DEBUG("Statistics about rotation triplets:");
ALICEVISION_LOG_DEBUG(MinMaxMeanMedian<float>(vec_errToIdentityPerTriplet.begin(), vec_errToIdentityPerTriplet.end()));
ALICEVISION_LOG_DEBUG(BoxStats<float>(vec_errToIdentityPerTriplet.begin(), vec_errToIdentityPerTriplet.end()));

std::sort(vec_errToIdentityPerTriplet.begin(), vec_errToIdentityPerTriplet.end());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
#include <aliceVision/multiview/translationAveraging/common.hpp>
#include <aliceVision/multiview/translationAveraging/solver.hpp>
#include <aliceVision/graph/graph.hpp>
#include <aliceVision/track/Track.hpp>
#include <aliceVision/track/TracksBuilder.hpp>
#include <aliceVision/stl/stl.hpp>
#include <aliceVision/system/Timer.hpp>
#include <aliceVision/linearProgramming/linearProgramming.hpp>
Expand All @@ -28,7 +28,7 @@
#include <aliceVision/config.hpp>
#include <aliceVision/alicevision_omp.hpp>

#include <dependencies/histogram/histogram.hpp>
#include <aliceVision/utils/Histogram.hpp>

#include <boost/progress.hpp>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#include <aliceVision/multiview/translationAveraging/common.hpp>
#include <aliceVision/feature/FeaturesPerView.hpp>
#include <aliceVision/sfm/pipeline/pairwiseMatchesIO.hpp>
#include <aliceVision/track/Track.hpp>
#include <aliceVision/track/TracksBuilder.hpp>
#include <aliceVision/graph/graph.hpp>

namespace aliceVision {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
#include <aliceVision/system/Timer.hpp>
#include <aliceVision/stl/stl.hpp>
#include <aliceVision/multiview/essential.hpp>
#include <aliceVision/track/Track.hpp>
#include <aliceVision/track/TracksBuilder.hpp>
#include <aliceVision/track/tracksUtils.hpp>
#include <aliceVision/config.hpp>

#include <dependencies/htmlDoc/htmlDoc.hpp>
Expand Down Expand Up @@ -276,7 +277,7 @@ bool ReconstructionEngine_globalSfM::Compute_Initial_Structure(matching::Pairwis
pose_supported_matches.insert(pairwiseMatchesIt);
}
}
tracksBuilder.Build(pose_supported_matches);
tracksBuilder.build(pose_supported_matches);
#else
// Use triplet validated matches
tracksBuilder.build(tripletWise_matches);
Expand Down Expand Up @@ -314,7 +315,7 @@ bool ReconstructionEngine_globalSfM::Compute_Initial_Structure(matching::Pairwis
// - number of images
// - number of tracks
std::set<size_t> set_imagesId;
tracksUtilsMap::imageIdInTracks(map_selectedTracks, set_imagesId);
imageIdInTracks(map_selectedTracks, set_imagesId);
osTrack << "------------------" << "\n"
<< "-- Tracks Stats --" << "\n"
<< " Tracks number: " << tracksBuilder.nbTracks() << "\n"
Expand All @@ -325,7 +326,7 @@ bool ReconstructionEngine_globalSfM::Compute_Initial_Structure(matching::Pairwis
osTrack << "\n------------------" << "\n";

std::map<size_t, size_t> map_Occurence_TrackLength;
tracksUtilsMap::tracksLength(map_selectedTracks, map_Occurence_TrackLength);
tracksLength(map_selectedTracks, map_Occurence_TrackLength);
osTrack << "TrackLength, Occurrence" << "\n";
for (std::map<size_t, size_t>::const_iterator iter = map_Occurence_TrackLength.begin();
iter != map_Occurence_TrackLength.end(); ++iter) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
#include <aliceVision/system/Timer.hpp>
#include <aliceVision/stl/stl.hpp>
#include <aliceVision/multiview/essential.hpp>
#include <aliceVision/track/Track.hpp>
#include <aliceVision/track/TracksBuilder.hpp>
#include <aliceVision/config.hpp>

#include <aliceVision/numeric/numeric.hpp>
Expand Down
Loading

0 comments on commit dc42aed

Please sign in to comment.