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.

utils.h 1.4KB

2 years ago
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. #pragma once
  2. #include <opencv2/opencv.hpp>
  3. #include <cmath>
  4. #define _USE_MATH_DEFINES
  5. #include <math.h>
  6. using namespace cv;
  7. using namespace std;
  8. class LFRPoint
  9. {
  10. private:
  11. /* data */
  12. public:
  13. double x, y;
  14. LFRPoint(/* args */);
  15. LFRPoint(double x, double y);
  16. ~LFRPoint();
  17. LFRPoint operator-(const LFRPoint& pt){return LFRPoint(x-pt.x, y-pt.y);}
  18. LFRPoint operator+(const LFRPoint& pt){return LFRPoint(x+pt.x, y+pt.y);}
  19. };
  20. class LFRVector : public LFRPoint
  21. {
  22. private:
  23. /* data */
  24. public:
  25. LFRVector(/* args */);
  26. LFRVector(double x, double y);
  27. LFRVector(const LFRPoint& pt);
  28. ~LFRVector();
  29. double angle(const LFRVector& other) const;
  30. double dot(const LFRVector& other) const;
  31. double norm() const;
  32. };
  33. class LFRLine
  34. {
  35. private:
  36. /* data */
  37. public:
  38. LFRPoint start;
  39. LFRVector dir;
  40. LFRLine(/* args */);
  41. LFRLine(LFRPoint start, LFRVector dir);
  42. LFRLine(LFRPoint start, LFRPoint end);
  43. ~LFRLine();
  44. };
  45. class Calcs{
  46. private:
  47. public:
  48. static int calcAngle(int deltaX, int deltaY);
  49. };
  50. class FrameData
  51. {
  52. public:
  53. std::vector<std::vector<cv::Point>> contours;
  54. std::vector<cv::Rect> boundingBoxes;
  55. std::vector<cv::Point> leftEdges;
  56. std::vector<cv::Point> middlePoints;
  57. double angle; //Angle of the contour the robot has to follow to
  58. int index; //Index of the contour the robot has to follow to
  59. FrameData(): contours(), boundingBoxes(), leftEdges(), middlePoints() {}
  60. };