Projektarbeit Line Following Robot bei Prof. Chowanetz im WS22/23
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

spielwiese.cpp 2.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. #include <opencv2/core/utils/logger.hpp>
  2. #include <opencv2/opencv.hpp>
  3. #include <iostream>
  4. #include <input.h>
  5. #include <processing.h>
  6. #include <control_module.h>
  7. #include <interpreter.h>
  8. #include <intersection_handler.h>
  9. void sweep_em_all(int thresholdBinary, int videoHeight, int videoWidth, int gaussKernelSize, int thresholdCanny1, int thresholdCanny2, int apertureSizeCanny)
  10. {
  11. Input input(videoHeight, videoWidth);
  12. Processing processing;
  13. namedWindow("Display window");
  14. while(true)
  15. {
  16. Mat image = input.readFile("C:\\Users\\User\\Desktop\\Studium\\02_Master_MSY\\2. Semester Winter 22 23\\Projekt\\Line-Following-Robot\\Test_data");
  17. Mat processedImage = image;
  18. processing.processImage(processedImage, thresholdBinary, gaussKernelSize, thresholdCanny1, thresholdCanny2 ,apertureSizeCanny);
  19. std::vector<Vec4i> lines = processing.calculateLineSegments(processedImage);
  20. for( size_t i = 0; i < lines.size(); i++ )
  21. {
  22. line( image, Point(lines[i][0], lines[i][1]),
  23. Point( lines[i][2], lines[i][3]), (0,0,255), 1, 8 );
  24. }
  25. imshow("Display window", image);
  26. char c = (char)waitKey(1);
  27. }
  28. destroyWindow("Display window");
  29. }
  30. void in_depth_processing_chain(int thresholdBinary, int videoHeight, int videoWidth, int gaussKernelSize, int thresholdCanny1, int thresholdCanny2, int apertureSizeCanny)
  31. {
  32. std::string outputFolder = "C:\\Users\\User\\Desktop\\temp";
  33. Input input(videoHeight, videoWidth);
  34. Mat image = input.readFile("C:\\Users\\User\\Desktop\\Studium\\02_Master_MSY\\2. Semester Winter 22 23\\Projekt\\Line-Following-Robot\\Test_data");
  35. imwrite(outputFolder + "\\01_input.jpg", image);
  36. cvtColor(image, image, COLOR_BGR2GRAY);
  37. imwrite(outputFolder + "\\02_color_convert.jpg", image);
  38. GaussianBlur(image, image, Size(gaussKernelSize, gaussKernelSize), 0);
  39. imwrite(outputFolder + "\\03_gauss.jpg", image);
  40. threshold(image, image, thresholdBinary, 255, THRESH_BINARY);
  41. imwrite(outputFolder + "\\04_threshold.jpg", image);
  42. Canny(image, image, thresholdCanny1, thresholdCanny2, apertureSizeCanny);
  43. imwrite(outputFolder + "\\05_canny.jpg", image);
  44. }
  45. int main(void)
  46. {
  47. //Disable opencv logging messages
  48. cv::utils::logging::setLogLevel(cv::utils::logging::LOG_LEVEL_WARNING);
  49. const int thresholdBinary = 140;
  50. const int videoHeight = 720;
  51. const int videoWidth = 960;
  52. const int gaussKernelSize = 11;
  53. const int thresholdCanny1 = 50;
  54. const int thresholdCanny2 = 100;
  55. const int apertureSizeCanny = 3;
  56. //sweep_em_all(thresholdBinary, videoHeight, videoWidth, gaussKernelSize, thresholdCanny1, thresholdCanny2, apertureSizeCanny);
  57. in_depth_processing_chain(thresholdBinary, videoHeight, videoWidth, gaussKernelSize, thresholdCanny1, thresholdCanny2, apertureSizeCanny);
  58. }