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.cpp 1.1KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. #include "lfr.h"
  2. LFR::LFR(int videoHeight, int videoWidth, int thresholdBinary, int gaussKernelSize)
  3. : iAmLooping(false), input(videoHeight, videoWidth), processing(), controlModule(), interpreter(), intersectionHandler()
  4. {
  5. this->iAmLooping = false;
  6. this->thresholdBinary = thresholdBinary;
  7. this->gaussKernelSize = gaussKernelSize;
  8. }
  9. LFR::~LFR()
  10. {
  11. if(iAmLooping)
  12. {
  13. this->endLoop();
  14. }
  15. }
  16. void LFR::loop()
  17. {
  18. namedWindow("Display window");
  19. while(iAmLooping)
  20. {
  21. Mat image = input.readFile("C:\\Line-Following-Robot\\Test_data");
  22. processing.processImage(image, this->thresholdBinary, this->gaussKernelSize);
  23. std::vector<LFRLine> lines = processing.calculateLineSegments(image);
  24. imshow("Display window", image);
  25. char c = (char)waitKey(1);
  26. }
  27. destroyWindow("Display window");
  28. input.freeWebcam();
  29. }
  30. void LFR::startLoop()
  31. {
  32. iAmLooping = true;
  33. this->loopThread=thread(&LFR::loop, this);
  34. }
  35. void LFR::endLoop()
  36. {
  37. iAmLooping = false;
  38. this->loopThread.join();
  39. return;
  40. }