修改参数
This commit is contained in:
1 parent
2434c4140d
commit
46bf872bac
2 files changed
+177
-22
No files matched your search
@@ -85,9 +85,9 @@ class FillMeshGenerator:
|
||||
# ======================================================================
|
||||
# 参数配置
|
||||
# ======================================================================
|
||||
IN_OBJ = "632723.obj"
|
||||
IN_IDX = "index.txt"
|
||||
OUT_FILL = "fill_mesh.obj"
|
||||
OBJ = "632723.obj"
|
||||
INDEX = "index.txt"
|
||||
OUT = "fill_mesh.obj"
|
||||
OUT_MERGED = "632723_filled.obj"
|
||||
OUT_PREVIEW = "fill_preview.png"
|
||||
|
||||
@@ -109,15 +109,15 @@ class FillMeshGenerator:
|
||||
BLAM = 0.6 # 边界平滑系数
|
||||
TOL = 1e-4 # Jacobi 收敛阈值
|
||||
|
||||
def __init__(self, in_obj=None, in_idx=None, out_fill=None):
|
||||
if in_obj:
|
||||
self.IN_OBJ = in_obj
|
||||
if in_idx:
|
||||
self.IN_IDX = in_idx
|
||||
if out_fill:
|
||||
self.OUT_FILL = out_fill
|
||||
def __init__(self, obj=None, index=None, out=None):
|
||||
if obj:
|
||||
self.OBJ = obj
|
||||
if index:
|
||||
self.INDEX = index
|
||||
if out:
|
||||
self.OUT = out
|
||||
# 根据 OUT_FILL 自动推导 OUT_MERGED 和 OUT_PREVIEW
|
||||
base, ext = os.path.splitext(self.OUT_FILL)
|
||||
base, ext = os.path.splitext(self.OUT)
|
||||
self.OUT_MERGED = base + "_filled" + ext
|
||||
self.OUT_PREVIEW = base.replace("mesh", "preview") + ".png"
|
||||
if self.OUT_PREVIEW == base + ".png":
|
||||
@@ -353,8 +353,8 @@ class FillMeshGenerator:
|
||||
def load_and_classify(self):
|
||||
"""加载模型, 通过边连通主分量提取真眼镜物体"""
|
||||
self.log("== 1. 读入模型 ==")
|
||||
V, F = self.parse_obj(self.IN_OBJ)
|
||||
idx = np.loadtxt(self.IN_IDX, dtype=np.int64) - 1
|
||||
V, F = self.parse_obj(self.OBJ)
|
||||
idx = np.loadtxt(self.INDEX, dtype=np.int64) - 1
|
||||
ism = np.zeros(len(V), bool)
|
||||
ism[idx] = True
|
||||
face_g = ism[F].any(1)
|
||||
@@ -1597,7 +1597,7 @@ class FillMeshGenerator:
|
||||
self.log(f" {self.OUT_FILL}: {len(Pall)} 顶点, {len(Ff)} 面")
|
||||
|
||||
# 输出合并模型
|
||||
with open(self.IN_OBJ) as f:
|
||||
with open(self.OBJ) as f:
|
||||
orig = f.read()
|
||||
with open(self.OUT_MERGED, "w") as f:
|
||||
f.write(orig.rstrip("\n") + "\n")
|
||||
@@ -1754,11 +1754,11 @@ def diagnose_indices(obj_path, idx_path):
|
||||
# ======================================================================
|
||||
if __name__ == "__main__":
|
||||
parser = argparse.ArgumentParser(description="眼镜-脸部填充网格生成器")
|
||||
parser.add_argument("--in_obj", type=str, default="632723.obj",
|
||||
parser.add_argument("--obj", type=str, default="632723.obj",
|
||||
help="输入 OBJ 模型文件路径 (默认: 632723.obj)")
|
||||
parser.add_argument("--in_idx", type=str, default="index.txt",
|
||||
parser.add_argument("--index", type=str, default="index.txt",
|
||||
help="眼镜顶点索引文件路径 (默认: index.txt)")
|
||||
parser.add_argument("--out_fill", type=str, default="fill_mesh.obj",
|
||||
parser.add_argument("--out", type=str, default="fill_mesh.obj",
|
||||
help="输出填充网格文件路径 (默认: fill_mesh.obj)")
|
||||
parser.add_argument("--diagnose", action="store_true",
|
||||
help="仅运行诊断,不生成填充网格")
|
||||
@@ -1766,13 +1766,13 @@ if __name__ == "__main__":
|
||||
args = parser.parse_args()
|
||||
|
||||
if args.diagnose:
|
||||
diagnose_indices(args.in_obj, args.in_idx)
|
||||
diagnose_indices(args.obj, args.index)
|
||||
else:
|
||||
gen = FillMeshGenerator(
|
||||
in_obj=args.in_obj,
|
||||
in_idx=args.in_idx,
|
||||
out_fill=args.out_fill
|
||||
obj=args.obj,
|
||||
index=args.index,
|
||||
out=args.out
|
||||
)
|
||||
gen.run()
|
||||
|
||||
# python generate_fill_mesh_hsc.py --in_obj 632723.obj --in_idx index.txt --out_fill fill_mesh.obj
|
||||
# python generate_fill_mesh_hsc.py --obj 632723.obj --index index.txt --out fill_mesh.obj
|
||||
Reference in new issue
Block a user