From b566dffd6a53831d76a7caaa2165ed4d04c7d9d1 Mon Sep 17 00:00:00 2001 From: Timo Menzel Date: Thu, 14 Sep 2023 11:46:06 +0200 Subject: [PATCH] Handle empty dirichlet mask filename. --- src/apps/main.cpp | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/src/apps/main.cpp b/src/apps/main.cpp index a03d2ad..b60f2b2 100644 --- a/src/apps/main.cpp +++ b/src/apps/main.cpp @@ -30,7 +30,10 @@ int main (int argc, char** argv) mesh.read(argv[1]); std::cout << "Compute PIE" << std::endl; - start_texture_merge_pie(argv[2], argv[3], argv[4], argv[5], mesh); + if(argc == 6) + start_texture_merge_pie(argv[2], argv[3], argv[4], argv[5], mesh); + else if (argc == 5) + start_texture_merge_pie(argv[2], argv[3], argv[4], "", mesh); std::cout << "Write result" << std::endl; } @@ -49,8 +52,14 @@ start_texture_merge_pie(std::string src_fn, cv::Mat dst = cv::imread(dst_fn, cv::IMREAD_COLOR); std::cout << "Load " << mask_fn << std::endl; cv::Mat mask = cv::imread(mask_fn, cv::IMREAD_GRAYSCALE); - std::cout << "Load " << dirichlet_mask_fn << std::endl; - cv::Mat dirichlet_mask = cv::imread(dirichlet_mask_fn, cv::IMREAD_GRAYSCALE); + + cv::Mat dirichlet_mask; + if (!dirichlet_mask_fn.empty()) { + std::cout << "Load " << dirichlet_mask_fn << std::endl; + dirichlet_mask = cv::imread(dirichlet_mask_fn, cv::IMREAD_GRAYSCALE); + } else { + std::cout << "No dirichlet mask specified " << std::endl; + } std::cout << "Save " << src_fn << std::endl; cv::imwrite("src.jpg", src); @@ -58,8 +67,13 @@ start_texture_merge_pie(std::string src_fn, cv::imwrite("dst.jpg", dst); std::cout << "Save " << mask_fn << std::endl; cv::imwrite("mask.jpg", mask); - std::cout << "Save " << dirichlet_mask_fn << std::endl; - cv::imwrite("dirichlet_mask.jpg", dirichlet_mask); + + if (!dirichlet_mask_fn.empty()) { + dirichlet_mask = cv::imread(dirichlet_mask_fn, cv::IMREAD_GRAYSCALE); + std::cout << "Save " << dirichlet_mask_fn << std::endl; + cv::imwrite("dirichlet_mask.jpg", dirichlet_mask); + } + cv::Mat face_id_tex = cv::Mat::zeros(src.size(), CV_32SC1); face_id_map(mesh, face_id_tex);