From cb545049c297d6aebb6ee8c1d0269ae66e1bedb0 Mon Sep 17 00:00:00 2001 From: hesuicong Date: Mon, 19 Jan 2026 09:49:32 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E8=B7=AF=E5=BE=84=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- libs/MVS/mask_face_occlusion.py | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/libs/MVS/mask_face_occlusion.py b/libs/MVS/mask_face_occlusion.py index e5905fa..84279fd 100755 --- a/libs/MVS/mask_face_occlusion.py +++ b/libs/MVS/mask_face_occlusion.py @@ -4,7 +4,8 @@ import os import numpy as np from scipy.spatial.transform import Rotation import sys -sys.path.append("/home/algo/Documents/openMVS/openMVS/libs/MVS/utils") +# sys.path.append("/home/algo/Documents/openMVS/openMVS/libs/MVS/utils") +sys.path.append("/root/code/openMVS/openMVS/libs/MVS/utils") from colmap_loader import read_cameras_text, read_images_text, read_int_text, write_int_text, read_indices_from_file # from get_pose_matrix import get_w2c import argparse @@ -33,6 +34,7 @@ from typing import Dict, List, Set import struct import math # import os +from pathlib import Path CameraModel = collections.namedtuple( "CameraModel", ["model_id", "model_name", "num_params"] @@ -2199,9 +2201,12 @@ class ModelProcessor: for image_name, face_list in result3.items(): delete_edge_faces_map[image_name] = set(face_list) + # 保存 visible_faces_map try: - with open(base_path + "_visible_faces_map.txt", "w", encoding='utf-8') as map_file: + file_name = "_visible_faces_map.txt" + file_path = Path(base_path) / file_name + with open(file_path, "w", encoding='utf-8') as map_file: for image_name, face_set in visible_faces_map.items(): # 写入图像名称和所有面ID,用空格分隔 line = image_name + " " + " ".join(str(face) for face in face_set) + "\n" @@ -2211,7 +2216,9 @@ class ModelProcessor: # 保存 face_visible_relative try: - with open(base_path + "_face_visible_relative.txt", "w", encoding='utf-8') as relative_file: + file_name = "_face_visible_relative.txt" + file_path = Path(base_path) / file_name + with open(file_path, "w", encoding='utf-8') as relative_file: for face in face_visible_relative: relative_file.write(str(face) + "\n") except IOError as e: @@ -2219,7 +2226,9 @@ class ModelProcessor: # 保存 edge_faces_map try: - with open(base_path + "_edge_faces_map.txt", "w", encoding='utf-8') as map_file2: + file_name = "_edge_faces_map.txt" + file_path = Path(base_path) / file_name + with open(file_path, "w", encoding='utf-8') as map_file2: for image_name, face_set in edge_faces_map.items(): line = image_name + " " + " ".join(str(face) for face in face_set) + "\n" map_file2.write(line) @@ -2228,7 +2237,9 @@ class ModelProcessor: # 保存 delete_edge_faces_map try: - with open(base_path + "_delete_edge_faces_map.txt", "w", encoding='utf-8') as map_file3: + file_name = "_delete_edge_faces_map.txt" + file_path = Path(base_path) / file_name + with open(file_path, "w", encoding='utf-8') as map_file3: for image_name, face_set in delete_edge_faces_map.items(): line = image_name + " " + " ".join(str(face) for face in face_set) + "\n" map_file3.write(line)