app_debug.cpp 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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. app_debug::app_debug(const create_config &conf) {
  53. auto calib_conf = camera_calibrator::create_config{
  54. .pattern_size = cv::Size(11, 8),
  55. .corner_distance = 5,
  56. };
  57. auto calib = std::make_unique<camera_calibrator>(calib_conf);
  58. auto sim_info = camera_calibrator::simulate_info_type{
  59. .data_path = "/home/tpx/project/DepthGuide/cmake-build-debug/exp-20240605/calib/calib_data_c5.txt",
  60. .img_size = cv::Size(1920, 1080),
  61. };
  62. calib->simulate_process(sim_info);
  63. }