配置文件处理
This commit is contained in:
1 parent
74b5bbd255
commit
ca6e3819b8
8 files changed
+103
-20
No files matched your search
+2
-1
@@ -168,7 +168,8 @@ public:
|
||||
// Mesh texturing
|
||||
bool TextureMesh(unsigned nResolutionLevel, unsigned nMinResolution, unsigned minCommonCameras=0, float fOutlierThreshold=0.f, float fRatioDataSmoothness=0.3f,
|
||||
bool bGlobalSeamLeveling=true, bool bLocalSeamLeveling=true, unsigned nTextureSizeMultiple=0, unsigned nRectPackingHeuristic=3, Pixel8U colEmpty=Pixel8U(255,127,39),
|
||||
float fSharpnessWeight=0.5f, int ignoreMaskLabel=-1, int maxTextureSize=0, const IIndexArr& views=IIndexArr(), const SEACAVE::String& basename = "", bool bOriginFaceview = false);
|
||||
float fSharpnessWeight=0.5f, int ignoreMaskLabel=-1, int maxTextureSize=0, const IIndexArr& views=IIndexArr(), const SEACAVE::String& basename = "", bool bOriginFaceview = false,
|
||||
const std::string& inputFileName = "", const std::string& meshFileName = "");
|
||||
|
||||
bool is_face_visible(const std::string& image_name, int face_index);
|
||||
bool is_face_visible_relative(int face_index);
|
||||
|
||||
@@ -39,6 +39,8 @@
|
||||
|
||||
#include <pybind11/embed.h>
|
||||
#include <pybind11/stl.h>
|
||||
#include "ConfigEnv.h"
|
||||
|
||||
namespace py = pybind11;
|
||||
|
||||
using namespace MVS;
|
||||
@@ -8598,7 +8600,8 @@ bool Scene::LoadVisibleFacesData(std::map<std::string, std::unordered_set<int>>&
|
||||
// - nIgnoreMaskLabel: label value to ignore in the image mask, stored in the MVS scene or next to each image with '.mask.png' extension (-1 - auto estimate mask for lens distortion, -2 - disabled)
|
||||
bool Scene::TextureMesh(unsigned nResolutionLevel, unsigned nMinResolution, unsigned minCommonCameras, float fOutlierThreshold, float fRatioDataSmoothness,
|
||||
bool bGlobalSeamLeveling, bool bLocalSeamLeveling, unsigned nTextureSizeMultiple, unsigned nRectPackingHeuristic, Pixel8U colEmpty, float fSharpnessWeight,
|
||||
int nIgnoreMaskLabel, int maxTextureSize, const IIndexArr& views, const SEACAVE::String& baseFileName, bool bOriginFaceview)
|
||||
int nIgnoreMaskLabel, int maxTextureSize, const IIndexArr& views, const SEACAVE::String& baseFileName, bool bOriginFaceview,
|
||||
const std::string& inputFileName, const std::string& meshFileName)
|
||||
{
|
||||
if (!bOriginFaceview)
|
||||
{
|
||||
@@ -8624,7 +8627,7 @@ bool Scene::TextureMesh(unsigned nResolutionLevel, unsigned nMinResolution, unsi
|
||||
|
||||
MeshTexture texture(*this, nResolutionLevel, nMinResolution);
|
||||
|
||||
printf("baseFileName=%s\n", baseFileName.c_str());
|
||||
// printf("baseFileName=%s\n", baseFileName.c_str());
|
||||
|
||||
/*
|
||||
std::filesystem::path path(baseFileName.c_str());
|
||||
@@ -8668,6 +8671,39 @@ bool Scene::TextureMesh(unsigned nResolutionLevel, unsigned nMinResolution, unsi
|
||||
|
||||
#ifdef MASK_FACE_OCCLUSION
|
||||
|
||||
/*
|
||||
// 创建遮挡数据
|
||||
std::cout << "inputFileName: " << inputFileName << std::endl;
|
||||
std::cout << "meshFileName: " << meshFileName << std::endl;
|
||||
try {
|
||||
py::scoped_interpreter guard{}; // 自动管理解释器生命周期
|
||||
py::module_ sys = py::module_::import("sys");
|
||||
// 设置命令行参数(模拟Python的argparse)
|
||||
py::list argv;
|
||||
argv.append("program_name");
|
||||
argv.append("--sparse_dir");
|
||||
argv.append(static_cast<std::string>(inputFileName));
|
||||
argv.append("--mesh_path");
|
||||
argv.append(static_cast<std::string>(meshFileName));
|
||||
// argv.append("--mask_image");
|
||||
// argv.append("63_2");
|
||||
sys.attr("argv") = argv;
|
||||
|
||||
py::print(sys.attr("version")); // 打印Python版本
|
||||
sys.attr("path").attr("append")("/root/miniconda3/lib/python3.10/site-packages");
|
||||
sys.attr("path").attr("append")("/root/code/openMVS/libs/MVS");
|
||||
// 调用自定义函数
|
||||
py::module_ mymodule = py::module_::import("mask_face_occlusion");
|
||||
|
||||
// 获取ModelProcessor类
|
||||
py::object ModelProcessor = mymodule.attr("ModelProcessor");
|
||||
|
||||
py::object processor = ModelProcessor();
|
||||
py::dict result = processor.attr("process")().cast<py::dict>();
|
||||
|
||||
printf("result size=%d\n", result.size());
|
||||
*/
|
||||
|
||||
std::string basePath = "";
|
||||
size_t lastSlash = baseFileName.find_last_of('/');
|
||||
size_t secondLastSlash = baseFileName.find_last_of('/', lastSlash - 1);
|
||||
@@ -8693,13 +8729,22 @@ bool Scene::TextureMesh(unsigned nResolutionLevel, unsigned nMinResolution, unsi
|
||||
argv.append("--id");
|
||||
// argv.append("274658"); // 274658 7613212046
|
||||
argv.append(id);
|
||||
// argv.append("--mask_image");
|
||||
// argv.append("63_2");
|
||||
argv.append("--base_path");
|
||||
argv.append(basePath.c_str());
|
||||
argv.append("--mesh_path");
|
||||
argv.append(meshFileName.c_str());
|
||||
argv.append("--sparse_dir");
|
||||
argv.append(inputFileName.c_str());
|
||||
sys.attr("argv") = argv;
|
||||
|
||||
|
||||
py::print(sys.attr("version")); // 打印Python版本
|
||||
sys.attr("path").attr("append")("/home/algo/.conda/envs/py310_pyt210/lib/python3.10/site-packages");
|
||||
sys.attr("path").attr("append")("/home/algo/Documents/openMVS/openMVS/libs/MVS");
|
||||
|
||||
printf("PYTHON_PATH=%s\n", PYTHON_PATH.c_str());
|
||||
printf("MVS_PATH=%s\n", MVS_PATH.c_str());
|
||||
// sys.attr("path").attr("append")("/home/algo/.conda/envs/py310_pyt210/lib/python3.10/site-packages");
|
||||
// sys.attr("path").attr("append")("/home/algo/Documents/openMVS/openMVS/libs/MVS");
|
||||
sys.attr("path").attr("append")(PYTHON_PATH.c_str());
|
||||
sys.attr("path").attr("append")(MVS_PATH.c_str());
|
||||
// 调用自定义函数
|
||||
py::module_ mymodule = py::module_::import("mask_face_occlusion");
|
||||
|
||||
|
||||
Binary file not shown.
@@ -21,27 +21,45 @@ class ModelProcessor:
|
||||
required=True,
|
||||
)
|
||||
|
||||
# parser.add_argument(
|
||||
# "--mask_image",
|
||||
# type=str,
|
||||
# default="74_8" # 74_8 123_8 75_8 72_8 44_8 104_8 96_8
|
||||
# )
|
||||
#"""
|
||||
parser.add_argument(
|
||||
"--base_path",
|
||||
type=str,
|
||||
required=True,
|
||||
)
|
||||
|
||||
parser.add_argument(
|
||||
"--mesh_path",
|
||||
type=str,
|
||||
required=True,
|
||||
)
|
||||
|
||||
parser.add_argument(
|
||||
"--sparse_dir",
|
||||
type=str,
|
||||
required=True,
|
||||
)
|
||||
#"""
|
||||
|
||||
# print("ModelProcessor Init", args.input_file, self.pose_path)
|
||||
args = parser.parse_args()
|
||||
|
||||
self.id = args.id
|
||||
# self.mask_image = args.mask_image
|
||||
|
||||
self.mesh = None
|
||||
self.asset_dir = f"/home/algo/Documents/openMVS/data/{self.id}"
|
||||
|
||||
self.pose_path = f"{self.asset_dir}/sparse/"
|
||||
# self.asset_dir = f"/home/algo/Documents/openMVS/data/{self.id}"
|
||||
self.asset_dir = args.base_path
|
||||
self.mesh_path = args.mesh_path
|
||||
# self.pose_path = f"{self.asset_dir}/sparse/"
|
||||
self.pose_path = args.sparse_dir
|
||||
if not os.path.exists(self.pose_path):
|
||||
raise FileNotFoundError(f"Camera data not found: {self.pose_path}")
|
||||
|
||||
self.mesh = None
|
||||
|
||||
def load_model(self):
|
||||
"""加载并初始化3D模型"""
|
||||
model_path = f"{self.asset_dir}/repair.ply"
|
||||
# model_path = f"{self.asset_dir}/repair.ply"
|
||||
model_path = self.mesh_path
|
||||
if not os.path.exists(model_path):
|
||||
raise FileNotFoundError(f"Model file not found: {model_path}")
|
||||
|
||||
|
||||
Reference in new issue
Block a user