From 0f36dd536c834289b88690c539b79cd1d275c7da Mon Sep 17 00:00:00 2001 From: hesuicong Date: Sat, 26 Jul 2025 16:58:55 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A4=84=E7=90=86=E8=89=B2=E5=B7=AE=E5=92=8C?= =?UTF-8?q?=E5=8D=B0=E6=9F=93=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- libs/MVS/SceneTexture.cpp | 38 +++++++++++++++++++++++--------------- 1 file changed, 23 insertions(+), 15 deletions(-) diff --git a/libs/MVS/SceneTexture.cpp b/libs/MVS/SceneTexture.cpp index edf3dff..ed780de 100644 --- a/libs/MVS/SceneTexture.cpp +++ b/libs/MVS/SceneTexture.cpp @@ -2959,7 +2959,7 @@ void MeshTexture::CreateVirtualFaces6(FaceDataViewArr& facesDatas, FaceDataViewA } float maxLuminance = 150.0f; - float minLuminance = 20.0f; + float minLuminance = 80.0f; if (bHasInvalidView) { if (validViews.size()<=0) @@ -3000,28 +3000,47 @@ void MeshTexture::CreateVirtualFaces6(FaceDataViewArr& facesDatas, FaceDataViewA } } + //* + if (validIndices.empty()) { + for (int n = 0; n < nSize; ++n) { + const Color& viewColor = sortedViews[n].second; + float viewLuminance = MeshTexture::GetLuminance(viewColor); + + if ((viewLuminance<=maxLuminance)&& + (viewLuminance>=minLuminance)){ + validIndices.push_back(n); + } + } + } + //*/ + + /* + float maxColorDeviation2 = 0.05f; if (validIndices.empty()) { for (int n = 0; n < nSize; ++n) { const Color& viewColor = sortedViews[n].second; float colorDistance = cv::norm(avgColor - viewColor); - if (colorDistance <= maxColorDeviation) { + if (colorDistance <= maxColorDeviation2) { validIndices.push_back(n); } } } + //*/ + /* float totalLuminance = MeshTexture::GetLuminance(totalColor); float avgLuminance = totalLuminance / nSize; for (int n = 0; n < nSize; ++n) { const Color& viewColor = sortedViews[n].second; float viewLuminance = MeshTexture::GetLuminance(viewColor); float luminanceDistance = cv::norm(avgLuminance - viewLuminance); - // printf("luminanceDistance=%f\n", luminanceDistance); + if (luminanceDistance <= maxLuminanceDeviation) { - // validIndices.push_back(n); + validIndices.push_back(n); } } + //*/ // 如果所有视图都被排除,保留原始平均值 if (validIndices.empty()) { @@ -3029,17 +3048,6 @@ void MeshTexture::CreateVirtualFaces6(FaceDataViewArr& facesDatas, FaceDataViewA // virtualFaceData.color = avgColor; // virtualFaceData.quality = avgQuality; // virtualFaceData.color = sortedLuminViews[0].second; - - for (int n = 0; n < nSize; ++n) { - float lumin = sortedLuminViews[n].first; - - if (lumin>=minLuminance&&lumin<=maxLuminance) - { - // virtualFaceData.quality = avgQuality; - // virtualFaceData.color = sortedLuminViews[0].second; - break; - } - } } else { // 使用过滤后的视图重新计算平均值