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)",