| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596 |
- #include "app_debug.h"
- #include "GLFW/glfw3.h"
- #include <opencv2/imgcodecs.hpp>
- #include <opencv2/cudastereo.hpp>
- #include <opencv2/cudaimgproc.hpp>
- //app_debug::app_debug(const create_config &conf) {
- //
- // auto left_path = "/home/tpx/project/DepthGuide/cmake-build-debug/Left.png";
- // auto right_path = "/home/tpx/project/DepthGuide/cmake-build-debug/Right.png";
- //
- // auto left_img = cv::imread(left_path);
- // auto right_img = cv::imread(right_path);
- //
- // auto left_img_cuda = cv::cuda::GpuMat();
- // auto right_img_cuda = cv::cuda::GpuMat();
- //
- // left_img_cuda.upload(left_img);
- // right_img_cuda.upload(right_img);
- //
- // // covert to gray
- // cv::cuda::cvtColor(left_img_cuda, left_img_cuda, cv::COLOR_RGB2GRAY);
- // cv::cuda::cvtColor(right_img_cuda, right_img_cuda, cv::COLOR_RGB2GRAY);
- //
- // auto disparity_cuda = cv::cuda::GpuMat();
- // auto stereo = cv::cuda::createStereoSGM();
- // stereo->setNumDisparities(128);
- //// stereo->setMode(cv::StereoSGBM::MODE_HH);
- // stereo->compute(left_img_cuda, right_img_cuda, disparity_cuda);
- //
- // auto filter = cv::cuda::createDisparityBilateralFilter();
- // filter->setNumDisparities(128);
- // filter->setRadius(5);
- // filter->setNumIters(3);
- // filter->apply(disparity_cuda, left_img_cuda, disparity_cuda);
- //
- // auto disparity = cv::Mat();
- // disparity_cuda.download(disparity);
- //
- // double min_val, max_val;
- // cv::minMaxLoc(disparity, &min_val, &max_val);
- // SPDLOG_INFO("Min: {}, Max: {}", min_val, max_val);
- //
- // auto tmp = cv::Mat();
- // disparity.convertTo(tmp, CV_32FC1);
- // tmp = (tmp - min_val) / (max_val - min_val) * 255.f;
- // tmp.convertTo(disparity, CV_8UC1);
- // cv::imwrite("disparity.png", disparity);
- //
- // glfwSetWindowShouldClose(glfwGetCurrentContext(), true);
- //}
- #include "image_process/camera_calibrator.h"
- #include "module/experiment/calib_eval.h"
- app_debug::app_debug(const create_config &conf) {
- auto cam_info = camera_calibrator::result_type();
- auto calib_conf = camera_calibrator::create_config{
- .pattern_size = cv::Size(11, 8),
- .corner_distance = 5,
- .cb_func = [&](auto info) { cam_info = info; },
- };
- auto calib = std::make_unique<camera_calibrator>(calib_conf);
- auto sim_info = camera_calibrator::simulate_info_type{
- .data_path = "/home/tpx/project/DepthGuide/cmake-build-debug/exp-20240605/calib/calib_data_c1.txt",
- .img_size = cv::Size(1920, 1080),
- };
- calib->simulate_process(sim_info);
- std::string eval_path_list[] = {
- "/home/tpx/project/DepthGuide/cmake-build-debug/exp-20240605_bak/videos/Stable_Pose_1_1717595907048131",
- "/home/tpx/project/DepthGuide/cmake-build-debug/exp-20240605_bak/videos/Stable_Pose_2_1717596106615177",
- "/home/tpx/project/DepthGuide/cmake-build-debug/exp-20240605_bak/videos/Stable_Pose_3_1717596157508744",
- "/home/tpx/project/DepthGuide/cmake-build-debug/exp-20240605_bak/videos/Stable_Pose_4_1717596214643474",
- "/home/tpx/project/DepthGuide/cmake-build-debug/exp-20240605_bak/videos/Stable_Pose_5_1717596236889051",
- "/home/tpx/project/DepthGuide/cmake-build-debug/exp-20240605_bak/videos/Stable_Pose_6_1717596274604857",
- "/home/tpx/project/DepthGuide/cmake-build-debug/exp-20240605_bak/videos/Stable_Pose_7_1717596308077328",
- "/home/tpx/project/DepthGuide/cmake-build-debug/exp-20240605_bak/videos/Stable_Pose_8_1717596347701421",
- "/home/tpx/project/DepthGuide/cmake-build-debug/exp-20240605_bak/videos/Dynamic_Pose_1_1717596522706273"
- };
- auto eval = std::make_unique<calib_eval>(calib_eval::record_config{});
- auto eval_info = calib_eval::simulate_info_type::from_yaml(
- conf.ext_conf["eval_points"]);
- eval_info.cam = cam_info;
- for (auto &path: eval_path_list) {
- eval_info.save_folder = path;
- eval->simulate_eval(eval_info);
- }
- glfwSetWindowShouldClose(glfwGetCurrentContext(), true);
- }
|