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 756B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. #include "lfr.h"
  2. const int threshold_binary = 110;
  3. LFR::LFR() : iAmLooping(false), input(), processing(), controlModule(), interpreter(), intersectionHandler()
  4. {
  5. }
  6. LFR::~LFR()
  7. {
  8. if(iAmLooping)
  9. {
  10. this->endLoop();
  11. }
  12. }
  13. void LFR::loop()
  14. {
  15. namedWindow("Display window");
  16. while(iAmLooping)
  17. {
  18. Mat image = input.readWebcam();
  19. processing.calculate_binaray(image, threshold_binary);
  20. imshow("Display window", image);
  21. char c = (char)waitKey(1);
  22. }
  23. destroyWindow("Display window");
  24. input.freeWebcam();
  25. }
  26. void LFR::startLoop()
  27. {
  28. iAmLooping = true;
  29. this->loopThread=thread(&LFR::loop, this);
  30. }
  31. void LFR::endLoop()
  32. {
  33. iAmLooping = false;
  34. this->loopThread.join();
  35. return;
  36. }