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.

lfr.h 1.6KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. #pragma once
  2. #include <iostream>
  3. #include <future>
  4. #include <thread>
  5. #include <functional>
  6. #include <opencv2/opencv.hpp>
  7. #include <input.h>
  8. #include <processing.h>
  9. #include <control_module.h>
  10. #include <interpreter.h>
  11. #include <intersection_handler.h>
  12. using namespace cv;
  13. struct LFR_Result
  14. {
  15. cv::Mat rawImage;
  16. cv::Mat processedImage;
  17. FrameData data;
  18. };
  19. class LFR
  20. {
  21. public:
  22. using ListenerKey = void const*;
  23. using ExceptionCallback = std::function<bool(std::exception const &ex)>;
  24. using ListenerCallback = std::function<void(LFR_Result)>;
  25. private:
  26. using ListenerPair = std::pair<ListenerKey, ListenerCallback>;
  27. using ListenerVector = std::vector<ListenerPair>;
  28. Input input;
  29. Processing processing;
  30. ControlModule controlModule;
  31. Interpreter interpreter;
  32. IntersectionHandler intersectionHandler;
  33. int thresholdBinary;
  34. int gaussKernelSize;
  35. ListenerVector listeners;
  36. ExceptionCallback cb;
  37. bool stop;
  38. std::unique_ptr<std::thread> thread;
  39. mutable std::mutex mutex;
  40. //void provideOutput(Mat originalImage, Mat processedImage, const FrameData& frameData, const Rect& roi);
  41. void createThread();
  42. void setStop(bool val);
  43. public:
  44. LFR() = delete;
  45. LFR(int videoHeight, int videoWidth, int thresholdBinary, int gaussKernelSize, ExceptionCallback cb);
  46. ~LFR();
  47. void startLoop();
  48. void endLoop();
  49. void addListener(ListenerCallback cv, ListenerKey key);
  50. void removeListener(ListenerKey key);
  51. void isStopped() const noexcept;
  52. Mat provideOutput(Mat originalImage, Mat processedImage, const FrameData& frameData, const Rect& roi);
  53. };