Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stereo Photometry: Add robustness to unexpected inputs #1452

Merged
merged 17 commits into from
Jun 12, 2023
Merged
Show file tree
Hide file tree
Changes from 15 commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
3f75ddd
[lightingEstimation] Formatting: Use 4-space indentation
cbentejac Jun 5, 2023
d17e608
[lightingEstimation] Add safeguards for images that have no sphere
cbentejac Jun 5, 2023
171c423
[sphereDetection] Exclude images with no sphere from the JSON file
cbentejac Jun 5, 2023
7e1596e
[photometricStereo] Replace "downscaleImageInplace" with "resizeImage"
cbentejac Jun 5, 2023
0002848
[image] Resampling: Remove the "downscaleImageInplace" method
cbentejac Jun 5, 2023
983f489
[photometricStereo] Do not make up mask name when it is not provided
cbentejac Jun 5, 2023
5b6b992
[photometricStereo] Prevent crash when no sphere was detected for an …
cbentejac Jun 5, 2023
42b8bb9
[photometricStereo] Issue warning if no image shared the same pose ID
cbentejac Jun 5, 2023
0b59454
[photometricStereo] Formatting: Split lines that were too long
cbentejac Jun 5, 2023
d3161e0
[lightingEstimation] Formatting: Split lines that were too long
cbentejac Jun 5, 2023
98df912
[sphereDetection] Formatting: Split lines that were too long
cbentejac Jun 5, 2023
df7dcbb
[pipeline] StereoPhotometry: Formatting: Split descriptions in cmdline
cbentejac Jun 5, 2023
622041f
[pipeline] StereoPhotometry: Fix logs and return EXIT_SUCCESS instead…
cbentejac Jun 5, 2023
af519ce
[pipeline] StereoPhotometry: Add timer and log time spent in the task
cbentejac Jun 5, 2023
fab8be1
[sphereDetection] Use CamelCase for the "Prediction" structure
cbentejac Jun 5, 2023
44782b8
[sphereDetection] Add constness and pre-increment
cbentejac Jun 5, 2023
d0144ea
[lightingCalibration] Add constness, use pre-increment and fix warnings
cbentejac Jun 5, 2023
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
31 changes: 0 additions & 31 deletions src/aliceVision/image/resampling.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,37 +47,6 @@ namespace image {
}
}

template <typename ImageType>
void downscaleImageInplace(ImageType& inout, int downscale)
{
if(downscale <= 1)
return;
ALICEVISION_LOG_TRACE("downscaleImageInplace in: " << inout.Width() << "x" << inout.Height());

{
// Rely on OpenImageIO to do the downscaling
const unsigned int w = inout.Width();
const unsigned int h = inout.Height();
const unsigned int nchannels = inout.Channels();

const unsigned int nw = (unsigned int)(floor(float(w) / downscale));
const unsigned int nh = (unsigned int)(floor(float(h) / downscale));

ImageType rescaled(nw, nh);

const oiio::ImageSpec imageSpecOrigin(w, h, nchannels, ColorTypeInfo<typename ImageType::Tpixel>::typeDesc);
const oiio::ImageSpec imageSpecResized(nw, nh, nchannels, ColorTypeInfo<typename ImageType::Tpixel>::typeDesc);

const oiio::ImageBuf inBuf(imageSpecOrigin, inout.data());
oiio::ImageBuf outBuf(imageSpecResized, rescaled.data());

oiio::ImageBufAlgo::resize(outBuf, inBuf);

inout.swap(rescaled);
}
ALICEVISION_LOG_TRACE("downscaleImageInplace out: " << inout.Width() << "x" << inout.Height());
}

/**
** Half sample an image (ie reduce its size by a factor 2) using bilinear interpolation
** @param[in] src input image
Expand Down
231 changes: 115 additions & 116 deletions src/aliceVision/lightingEstimation/augmentedNormals.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,125 +25,124 @@ using Eigen::MatrixXf;
*/
class AugmentedNormal : public Eigen::Matrix<float, 9, 1, 0, 9, 1>
{
using T = float;
typedef Eigen::Matrix<T, 9, 1, 0, 9, 1> BaseMatrix;
typedef T TBase;
public:
using T = float;
typedef Eigen::Matrix<T, 9, 1, 0, 9, 1> BaseMatrix;
typedef T TBase;

AugmentedNormal() = default;

/**
* @brief Constructor from a normal value
*/
inline AugmentedNormal(T nx, T ny, T nz)
{
(*this)(0) = nx;
(*this)(1) = ny;
(*this)(2) = nz;
(*this)(3) = 1;
(*this)(4) = nx*ny;
(*this)(5) = nx*nz;
(*this)(6) = ny*nz;
(*this)(7) = nx*nx - ny*ny;
(*this)(8) = 3 * nz * nz - 1;
}

/**
* @brief Constructor from eigen Matrix
*/
explicit inline AugmentedNormal(const BaseMatrix& m)
: BaseMatrix(m)
{
}

explicit inline AugmentedNormal(const Eigen::Matrix<T, 3, 1, 0, 3, 1>& m)
: AugmentedNormal(m(0), m(1), m(2))
{
}

inline const T& nx() const
{
return ( *this )( 0 );
}
inline T& nx()
{
return ( *this )( 0 );
}

inline const T& ny() const
{
return ( *this )( 1 );
}
inline T& ny()
{
return ( *this )( 1 );
}

inline const T& nz() const
{
return ( *this )( 2 );
}
inline T& nz()
{
return ( *this )( 2 );
}

inline const T& nambiant() const
{
return ( *this )( 3 );
}
inline T& nambiant()
{
return ( *this )( 3 );
}

inline const T& nx_ny() const
{
return ( *this )( 4 );
}
inline T& nx_ny()
{
return ( *this )( 4 );
}

inline const T& nx_nz() const
{
return ( *this )( 5 );
}
inline T& nx_nz()
{
return ( *this )( 5 );
}

inline const T& ny_nz() const
{
return ( *this )( 6 );
}
inline T& ny_nz()
{
return ( *this )( 6 );
}

inline const T& nx2_ny2() const
{
return ( *this )( 7 );
}
inline T& nx2_ny2()
{
return ( *this )( 7 );
}

inline const T& nz2() const
{
return ( *this )( 8 );
}
inline T& nz2()
{
return ( *this )( 8 );
}
public:

AugmentedNormal() = default;

/**
* @brief Constructor from a normal value
*/
inline AugmentedNormal(T nx, T ny, T nz)
{
(*this)(0) = nx;
(*this)(1) = ny;
(*this)(2) = nz;
(*this)(3) = 1;
(*this)(4) = nx * ny;
(*this)(5) = nx * nz;
(*this)(6) = ny * nz;
(*this)(7) = nx * nx - ny * ny;
(*this)(8) = 3 * nz * nz - 1;
}

/**
* @brief Constructor from eigen Matrix
*/
explicit inline AugmentedNormal(const BaseMatrix& m)
: BaseMatrix(m)
{
}

explicit inline AugmentedNormal(const Eigen::Matrix<T, 3, 1, 0, 3, 1>& m)
: AugmentedNormal(m(0), m(1), m(2))
{
}

inline const T& nx() const
{
return (*this)(0);
}
inline T& nx()
{
return (*this)(0);
}

inline const T& ny() const
{
return (*this)(1);
}
inline T& ny()
{
return (*this)(1);
}

inline const T& nz() const
{
return (*this)(2);
}
inline T& nz()
{
return (*this)(2);
}

inline const T& nambiant() const
{
return (*this)(3);
}
inline T& nambiant()
{
return (*this)(3);
}

inline const T& nx_ny() const
{
return (*this)(4);
}
inline T& nx_ny()
{
return (*this)(4);
}

inline const T& nx_nz() const
{
return (*this)(5);
}
inline T& nx_nz()
{
return (*this)(5);
}

inline const T& ny_nz() const
{
return (*this)(6);
}
inline T& ny_nz()
{
return (*this)(6);
}

inline const T& nx2_ny2() const
{
return (*this)(7);
}
inline T& nx2_ny2()
{
return (*this)(7);
}

inline const T& nz2() const
{
return (*this)(8);
}
inline T& nz2()
{
return (*this)(8);
}
};


}
}
Loading