From 73044aa5753320e98d8b5107093678fa4891985c Mon Sep 17 00:00:00 2001 From: hesuicong Date: Tue, 13 Oct 2026 11:22:57 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E8=AF=95=E9=AB=98=E4=BD=8E=E9=A2=91?= =?UTF-8?q?=E5=88=86=E7=A6=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- libs/MVS/SceneTexture.cpp | 39 +++++++++++++++++++++------------------ 1 file changed, 21 insertions(+), 18 deletions(-) diff --git a/libs/MVS/SceneTexture.cpp b/libs/MVS/SceneTexture.cpp index ecbfeb9..c406106 100644 --- a/libs/MVS/SceneTexture.cpp +++ b/libs/MVS/SceneTexture.cpp @@ -16468,6 +16468,7 @@ bool MeshTexture::RasterizeVirtualFaces( // ========== 合成:低频用多视图融合,高频用主视图细节 ========== cv::Mat finalPatch = lowFreqPatch + highFreq; // cv::Mat finalPatch = lowFreqPatch.clone(); + // finalPatch = cv::Mat::zeros(finalPatch.size(), finalPatch.type()); // 钳制到 [0, 1] cv::Mat clampedPatch; @@ -16494,9 +16495,9 @@ bool MeshTexture::RasterizeVirtualFaces( if (currentScore > m_texelScores[idx].score) { if (atlasY >= 0 && atlasY < atlas.rows && atlasX >= 0 && atlasX < atlas.cols) { cv::Vec3b& pixel = atlas.at(atlasY, atlasX); - pixel[0] = color[2]; + pixel[0] = color[0]; pixel[1] = color[1]; - pixel[2] = color[0]; + pixel[2] = color[2]; } m_texelScores[idx].score = currentScore; m_texelScores[idx].viewID = mainView; @@ -16572,6 +16573,8 @@ bool MeshTexture::RasterizeVirtualFaces( if (m_texelPatchID[i] != NO_ID) validPixels++; DEBUG_EXTRA("m_texelPatchID: %d valid pixels out of %zu", validPixels, m_texelPatchID.size()); + // cv::imwrite("/home/algo/Documents/openMVS/data/546893/out.546893/debug_atlas_before_return.png", atlas); + return true; } @@ -22582,24 +22585,24 @@ bool Scene::TextureMesh(unsigned nResolutionLevel, unsigned nMinResolution, unsi nTextureSizeMultiple, colEmpty, textures)) return false; - texture.MergeSameViewPatches(); - DEBUG_EXTRA("=== After MergeSameViewPatches, calling BuildStandardSeamData ==="); - // // ★★★ 新增:构建标准接缝数据 + 调用全局/局部接缝消除 ★★★ - // texture.BuildStandardSeamDataFromRCPatches( - // virtualFaceMap, texture.faceViews, nTextureSizeMultiple); + // texture.MergeSameViewPatches(); + // DEBUG_EXTRA("=== After MergeSameViewPatches, calling BuildStandardSeamData ==="); + // // // ★★★ 新增:构建标准接缝数据 + 调用全局/局部接缝消除 ★★★ + // // texture.BuildStandardSeamDataFromRCPatches( + // // virtualFaceMap, texture.faceViews, nTextureSizeMultiple); - // // 直接操作 atlas(不污染 images) - // texture.RunSeamLevelingOnAtlas(textures.back(), nTextureSizeMultiple); + // // // 直接操作 atlas(不污染 images) + // // texture.RunSeamLevelingOnAtlas(textures.back(), nTextureSizeMultiple); - // texture.RunGlobalColorOptimization(textures.back(), nTextureSizeMultiple, 0.1f); // λ=0.1 对齐 OpenMVS - // texture.GlobalAlignPatches(textures.back(), nTextureSizeMultiple); - // texture.LocalBlendSeams(textures.back(), nTextureSizeMultiple); - - // ★★★ 新增:调用 GlobalSeamLeveling3 并重新光栅化 ★★★ - texture.ApplyGlobalSeamLevelingOnRCPatches( - virtualFaceMap, - textures.back(), // atlas - nTextureSizeMultiple); // textureSize + // // texture.RunGlobalColorOptimization(textures.back(), nTextureSizeMultiple, 0.1f); // λ=0.1 对齐 OpenMVS + // // texture.GlobalAlignPatches(textures.back(), nTextureSizeMultiple); + // // texture.LocalBlendSeams(textures.back(), nTextureSizeMultiple); + + // // ★★★ 新增:调用 GlobalSeamLeveling3 并重新光栅化 ★★★ + // texture.ApplyGlobalSeamLevelingOnRCPatches( + // virtualFaceMap, + // textures.back(), // atlas + // nTextureSizeMultiple); // textureSize mesh.texturesDiffuse = std::move(textures); DEBUG_EXTRA("Existing UV texturing completed: %u faces (%s)",