平坦区域虚拟面增长优化
This commit is contained in:
1 parent
068a06820d
commit
715bf75c74
1 file changed
+39
-7
@@ -471,7 +471,7 @@ struct MeshTexture {
|
||||
*/
|
||||
|
||||
public:
|
||||
MeshTexture(Scene& _scene, unsigned _nResolutionLevel=0, unsigned _nMinResolution=640);
|
||||
MeshTexture(Scene& _scene, unsigned _nResolutionLevel=0, unsigned _nMinResolution=640, Mesh::FaceIdxArr* _curvatureRegions=nullptr);
|
||||
~MeshTexture();
|
||||
|
||||
void ListVertexFaces();
|
||||
@@ -512,6 +512,8 @@ public:
|
||||
float ComputeAverageQuality(const FaceDataArr& virtualFaceData) const;
|
||||
FaceDataArr MergeFaceData(const FaceDataArr& data1, const FaceDataArr& data2) const;
|
||||
|
||||
bool ShouldStopGrowthByCurvature(FIndex currentFace, FIndex seedFace, float centerCurvature) const;
|
||||
|
||||
bool CreateVirtualFaces7(FaceDataViewArr& facesDatas, FaceDataViewArr& virtualFacesDatas, VirtualFaceIdxsArr& virtualFaces, std::vector<bool>& isVirtualFace, unsigned minCommonCameras=2, float thMaxNormalDeviation=25.f) const;
|
||||
IIndexArr SelectBestViews(const FaceDataArr& faceDatas, FIndex fid, unsigned minCommonCameras, float ratioAngleToQuality) const;
|
||||
IIndexArr SelectBestViews2(const FaceDataArr& faceDatas, FIndex fid, unsigned minCommonCameras, float ratioAngleToQuality, FaceDataViewArr& facesDatas) const;
|
||||
@@ -731,6 +733,7 @@ public:
|
||||
ImageArr& images;
|
||||
|
||||
Scene& scene; // the mesh vertices and faces
|
||||
Mesh::FaceIdxArr* curvatureRegions;
|
||||
};
|
||||
|
||||
// creating an invalid mask for the given image corresponding to
|
||||
@@ -764,7 +767,7 @@ static Image8U DetectInvalidImageRegions(const Image8U3& image)
|
||||
return mask;
|
||||
}
|
||||
|
||||
MeshTexture::MeshTexture(Scene& _scene, unsigned _nResolutionLevel, unsigned _nMinResolution)
|
||||
MeshTexture::MeshTexture(Scene& _scene, unsigned _nResolutionLevel, unsigned _nMinResolution, Mesh::FaceIdxArr* _curvatureRegions)
|
||||
:
|
||||
nResolutionLevel(_nResolutionLevel),
|
||||
nMinResolution(_nMinResolution),
|
||||
@@ -778,7 +781,8 @@ MeshTexture::MeshTexture(Scene& _scene, unsigned _nResolutionLevel, unsigned _nM
|
||||
faces(_scene.mesh.faces),
|
||||
images(_scene.images),
|
||||
scene(_scene),
|
||||
alternativeTexture(nullptr)
|
||||
alternativeTexture(nullptr),
|
||||
curvatureRegions(nullptr)
|
||||
{
|
||||
}
|
||||
MeshTexture::~MeshTexture()
|
||||
@@ -4307,6 +4311,28 @@ float MeshTexture::ComputeAverageQuality(const FaceDataArr& virtualFaceData) con
|
||||
|
||||
return count > 0 ? totalQuality / static_cast<float>(count) : 0.0f;
|
||||
}
|
||||
|
||||
bool MeshTexture::ShouldStopGrowthByCurvature(FIndex currentFace, FIndex seedFace, float centerCurvature) const
|
||||
{
|
||||
// 软化逻辑(同上)
|
||||
const float curvCurrent = meshCurvatures[currentFace];
|
||||
const float curvSeed = meshCurvatures[seedFace];
|
||||
const float curvDiff = std::abs(curvCurrent - curvSeed);
|
||||
|
||||
float threshold;
|
||||
if (centerCurvature < 0.1f) {
|
||||
threshold = 0.3f;
|
||||
} else if (centerCurvature < 0.2f) {
|
||||
threshold = 0.15f;
|
||||
} else if (centerCurvature < 0.4f) {
|
||||
threshold = 0.08f;
|
||||
} else {
|
||||
threshold = 0.03f;
|
||||
}
|
||||
|
||||
return curvDiff > threshold;
|
||||
}
|
||||
|
||||
MeshTexture::FaceDataArr MeshTexture::MergeFaceData(const FaceDataArr& data1, const FaceDataArr& data2) const
|
||||
{
|
||||
FaceDataArr mergedData;
|
||||
@@ -6368,8 +6394,14 @@ bool MeshTexture::CreateVirtualFaces65(FaceDataViewArr& facesDatas, FaceDataView
|
||||
if (cosFaceToCenter < dynamicCosTh)
|
||||
continue;
|
||||
|
||||
if (meshCurvatures[currentFaceId] > 0.2f)
|
||||
continue;
|
||||
// if (meshCurvatures[currentFaceId] > 0.2f)
|
||||
// continue;
|
||||
|
||||
// 软化曲率检查
|
||||
const float centerCurvature = meshCurvatures[virtualFaceCenterFaceID];
|
||||
if (ShouldStopGrowthByCurvature(currentFaceId, virtualFaceCenterFaceID, centerCurvature)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// check if current face is seen by all cameras in selectedCams
|
||||
ASSERT(!selectedCams.empty());
|
||||
@@ -12801,6 +12833,7 @@ bool Scene::TextureMesh(unsigned nResolutionLevel, unsigned nMinResolution, unsi
|
||||
int nIgnoreMaskLabel, int maxTextureSize, const IIndexArr& views, const SEACAVE::String& baseFileName, bool bOriginFaceview,
|
||||
const std::string& inputFileName, const std::string& meshFileName)
|
||||
{
|
||||
Mesh::FaceIdxArr regionMap;
|
||||
if (!bOriginFaceview)
|
||||
{
|
||||
// 确保网格拓扑结构已计算
|
||||
@@ -12819,11 +12852,10 @@ bool Scene::TextureMesh(unsigned nResolutionLevel, unsigned nMinResolution, unsi
|
||||
mesh.ListBoundaryVertices(); // 计算边界顶点
|
||||
}
|
||||
|
||||
Mesh::FaceIdxArr regionMap;
|
||||
this->SegmentMeshBasedOnCurvature(regionMap, 0.2f); // 曲率阈值设为0.2
|
||||
}
|
||||
|
||||
MeshTexture texture(*this, nResolutionLevel, nMinResolution);
|
||||
MeshTexture texture(*this, nResolutionLevel, nMinResolution, ®ionMap);
|
||||
|
||||
// printf("baseFileName=%s\n", baseFileName.c_str());
|
||||
|
||||
|
||||
Reference in new issue
Block a user