Skip to content

Commit

Permalink
common: add saveMVSInterface() in python
Browse files Browse the repository at this point in the history
(cherry picked from commit 29d5afbc828bf30ddf4e6ae67998c067f182590d)
  • Loading branch information
cdcseacave committed Oct 1, 2024
1 parent 208a441 commit 5a2c24d
Show file tree
Hide file tree
Showing 5 changed files with 276 additions and 98 deletions.
2 changes: 1 addition & 1 deletion libs/Common/Types.h
Original file line number Diff line number Diff line change
Expand Up @@ -1637,7 +1637,7 @@ class TDMatrix : public cv::Mat_<TYPE>
/// What is the elem stride of the matrix?
inline size_t elem_stride() const { ASSERT(dims == 2 && step[1] == sizeof(TYPE)); return step[1]; }
/// Compute the area of the 2D matrix
inline int area() const { ASSERT(dims == 2); return cols*rows; }
inline int area() const { ASSERT(dims == 0 || dims == 2); return cols*rows; }
/// Compute the memory size of this matrix (in bytes)
inline size_t memory_size() const { return cv::Mat::total() * cv::Mat::elemSize(); }

Expand Down
4 changes: 3 additions & 1 deletion libs/MVS/DepthMap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1613,7 +1613,7 @@ bool MVS::LoadConfidenceMap(const String& fileName, ConfidenceMap& confMap)
// export depth map as an image (dark - far depth, light - close depth)
Image8U3 MVS::DepthMap2Image(const DepthMap& depthMap, Depth minDepth, Depth maxDepth)
{
ASSERT(!depthMap.empty());
ASSERT(!depthMap.empty() && depthMap.isContinuous());
// find min and max values
if (minDepth == FLT_MAX && maxDepth == 0) {
cList<Depth,Depth,0> depths(0, depthMap.area());
Expand Down Expand Up @@ -1653,6 +1653,7 @@ bool MVS::ExportNormalMap(const String& fileName, const NormalMap& normalMap)
{
if (normalMap.empty())
return false;
ASSERT(normalMap.isContinuous());
Image8U3 img(normalMap.size());
for (int i=normalMap.area(); --i >= 0; ) {
img[i] = [](const Normal& n) {
Expand All @@ -1673,6 +1674,7 @@ bool MVS::ExportNormalMap(const String& fileName, const NormalMap& normalMap)
bool MVS::ExportConfidenceMap(const String& fileName, const ConfidenceMap& confMap)
{
// find min and max values
ASSERT(confMap.empty() || confMap.isContinuous());
FloatArr confs(0, confMap.area());
for (int i=confMap.area(); --i >= 0; ) {
const float conf = confMap[i];
Expand Down
2 changes: 2 additions & 0 deletions libs/MVS/Mesh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1461,6 +1461,8 @@ bool Mesh::LoadGLTF(const String& fileName, bool bBinary)
// export the mesh to the given file
bool Mesh::Save(const String& fileName, const cList<String>& comments, bool bBinary) const
{
if (IsEmpty())
return false;
TD_TIMER_STARTD();
const String ext(Util::getFileExt(fileName).ToLower());
bool ret;
Expand Down
2 changes: 1 addition & 1 deletion libs/MVS/PointCloud.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,7 @@ bool PointCloud::Load(const String& fileName)
// save the dense point cloud as PLY file
bool PointCloud::Save(const String& fileName, bool bViews, bool bLegacyTypes, bool bBinary) const
{
if (points.empty())
if (IsEmpty())
return false;
TD_TIMER_STARTD();

Expand Down
Loading

0 comments on commit 5a2c24d

Please sign in to comment.