app_debug.cpp 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. #include "app_debug.h"
  2. #include "GLFW/glfw3.h"
  3. #include <opencv2/imgcodecs.hpp>
  4. #include <opencv2/cudastereo.hpp>
  5. #include <opencv2/cudaimgproc.hpp>
  6. //app_debug::app_debug(const create_config &conf) {
  7. //
  8. // auto left_path = "/home/tpx/project/DepthGuide/cmake-build-debug/Left.png";
  9. // auto right_path = "/home/tpx/project/DepthGuide/cmake-build-debug/Right.png";
  10. //
  11. // auto left_img = cv::imread(left_path);
  12. // auto right_img = cv::imread(right_path);
  13. //
  14. // auto left_img_cuda = cv::cuda::GpuMat();
  15. // auto right_img_cuda = cv::cuda::GpuMat();
  16. //
  17. // left_img_cuda.upload(left_img);
  18. // right_img_cuda.upload(right_img);
  19. //
  20. // // covert to gray
  21. // cv::cuda::cvtColor(left_img_cuda, left_img_cuda, cv::COLOR_RGB2GRAY);
  22. // cv::cuda::cvtColor(right_img_cuda, right_img_cuda, cv::COLOR_RGB2GRAY);
  23. //
  24. // auto disparity_cuda = cv::cuda::GpuMat();
  25. // auto stereo = cv::cuda::createStereoSGM();
  26. // stereo->setNumDisparities(128);
  27. //// stereo->setMode(cv::StereoSGBM::MODE_HH);
  28. // stereo->compute(left_img_cuda, right_img_cuda, disparity_cuda);
  29. //
  30. // auto filter = cv::cuda::createDisparityBilateralFilter();
  31. // filter->setNumDisparities(128);
  32. // filter->setRadius(5);
  33. // filter->setNumIters(3);
  34. // filter->apply(disparity_cuda, left_img_cuda, disparity_cuda);
  35. //
  36. // auto disparity = cv::Mat();
  37. // disparity_cuda.download(disparity);
  38. //
  39. // double min_val, max_val;
  40. // cv::minMaxLoc(disparity, &min_val, &max_val);
  41. // SPDLOG_INFO("Min: {}, Max: {}", min_val, max_val);
  42. //
  43. // auto tmp = cv::Mat();
  44. // disparity.convertTo(tmp, CV_32FC1);
  45. // tmp = (tmp - min_val) / (max_val - min_val) * 255.f;
  46. // tmp.convertTo(disparity, CV_8UC1);
  47. // cv::imwrite("disparity.png", disparity);
  48. //
  49. // glfwSetWindowShouldClose(glfwGetCurrentContext(), true);
  50. //}
  51. #include "image_process/camera_calibrator.h"
  52. #include "module/experiment/calib_eval.h"
  53. app_debug::app_debug(const create_config &conf) {
  54. auto cam_info = camera_calibrator::result_type();
  55. auto calib_conf = camera_calibrator::create_config{
  56. .pattern_size = cv::Size(11, 8),
  57. .corner_distance = 5,
  58. .cb_func = [&](auto info) { cam_info = info; },
  59. };
  60. auto calib = std::make_unique<camera_calibrator>(calib_conf);
  61. auto sim_info = camera_calibrator::simulate_info_type{
  62. .data_path = "/home/tpx/project/DepthGuide/cmake-build-debug/exp-20240605/calib/calib_data_c1.txt",
  63. .img_size = cv::Size(1920, 1080),
  64. };
  65. calib->simulate_process(sim_info);
  66. std::string eval_path_list[] = {
  67. "/home/tpx/project/DepthGuide/cmake-build-debug/exp-20240605_bak/videos/Stable_Pose_1_1717595907048131",
  68. "/home/tpx/project/DepthGuide/cmake-build-debug/exp-20240605_bak/videos/Stable_Pose_2_1717596106615177",
  69. "/home/tpx/project/DepthGuide/cmake-build-debug/exp-20240605_bak/videos/Stable_Pose_3_1717596157508744",
  70. "/home/tpx/project/DepthGuide/cmake-build-debug/exp-20240605_bak/videos/Stable_Pose_4_1717596214643474",
  71. "/home/tpx/project/DepthGuide/cmake-build-debug/exp-20240605_bak/videos/Stable_Pose_5_1717596236889051",
  72. "/home/tpx/project/DepthGuide/cmake-build-debug/exp-20240605_bak/videos/Stable_Pose_6_1717596274604857",
  73. "/home/tpx/project/DepthGuide/cmake-build-debug/exp-20240605_bak/videos/Stable_Pose_7_1717596308077328",
  74. "/home/tpx/project/DepthGuide/cmake-build-debug/exp-20240605_bak/videos/Stable_Pose_8_1717596347701421",
  75. "/home/tpx/project/DepthGuide/cmake-build-debug/exp-20240605_bak/videos/Dynamic_Pose_1_1717596522706273"
  76. };
  77. auto eval = std::make_unique<calib_eval>(calib_eval::record_config{});
  78. auto eval_info = calib_eval::simulate_info_type::from_yaml(
  79. conf.ext_conf["eval_points"]);
  80. eval_info.cam = cam_info;
  81. for (auto &path: eval_path_list) {
  82. eval_info.save_folder = path;
  83. eval->simulate_eval(eval_info);
  84. }
  85. glfwSetWindowShouldClose(glfwGetCurrentContext(), true);
  86. }