配置文件处理
This commit is contained in:
1 parent
74b5bbd255
commit
ca6e3819b8
8 files changed
+103
-20
No files matched your search
@@ -51,6 +51,14 @@ ENDIF()
|
||||
# ${OpenMVS_BINARY_DIR}.
|
||||
PROJECT(OpenMVS)
|
||||
|
||||
SET(ENV_PYTHON_PATH "/home/algo/.conda/envs/py310_pyt210/lib/python3.10/site-packages")
|
||||
SET(ENV_MVS_PATH "/home/algo/Documents/openMVS/openMVS/libs/MVS")
|
||||
|
||||
CONFIGURE_FILE(
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/build/Templates/ConfigEnv.h.in"
|
||||
"${CMAKE_BINARY_DIR}/ConfigEnv.h"
|
||||
)
|
||||
|
||||
SET(OpenMVS_MAJOR_VERSION 2)
|
||||
SET(OpenMVS_MINOR_VERSION 3)
|
||||
SET(OpenMVS_PATCH_VERSION 0)
|
||||
|
||||
@@ -1133,7 +1133,8 @@ int main(int argc, LPCTSTR* argv)
|
||||
TD_TIMER_START();
|
||||
if (!scene.TextureMesh(OPT::nResolutionLevel, OPT::nMinResolution, OPT::minCommonCameras, OPT::fOutlierThreshold, OPT::fRatioDataSmoothness,
|
||||
OPT::bGlobalSeamLeveling, OPT::bLocalSeamLeveling, OPT::nTextureSizeMultiple, OPT::nRectPackingHeuristic, Pixel8U(OPT::nColEmpty),
|
||||
OPT::fSharpnessWeight, OPT::nIgnoreMaskLabel, OPT::nMaxTextureSize, views, baseFileName, OPT::bOriginFaceview))
|
||||
OPT::fSharpnessWeight, OPT::nIgnoreMaskLabel, OPT::nMaxTextureSize, views, baseFileName, OPT::bOriginFaceview,
|
||||
OPT::strInputFileName, OPT::strMeshFileName))
|
||||
return EXIT_FAILURE;
|
||||
VERBOSE("Mesh texturing completed: %u vertices, %u faces (%s)", scene.mesh.vertices.GetSize(), scene.mesh.faces.GetSize(), TD_TIMER_GET_FMT().c_str());
|
||||
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
|
||||
// 从环境变量获取的路径
|
||||
const std::string PYTHON_PATH = "@ENV_PYTHON_PATH@";
|
||||
const std::string MVS_PATH = "@ENV_MVS_PATH@";
|
||||
@@ -1,3 +1,5 @@
|
||||
#include <string>
|
||||
|
||||
// OpenMVS version
|
||||
#define OpenMVS_MAJOR_VERSION ${OpenMVS_MAJOR_VERSION}
|
||||
#define OpenMVS_MINOR_VERSION ${OpenMVS_MINOR_VERSION}
|
||||
@@ -64,3 +66,4 @@
|
||||
|
||||
// SSE support
|
||||
#cmakedefine _USE_SSE
|
||||
|
||||
+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