Webcam Tracker  V1.0
Using openCV and an Arduino Uno
Button.h
Go to the documentation of this file.
1 
8 #pragma once
9 
10 #include <opencv2/highgui.hpp>
11 #include <opencv2/core/core.hpp>
12 #include <opencv2/features2d/features2d.hpp>
13 #include <opencv2/imgproc.hpp>
14 
18 class Button
19 {
20 private:
21  cv::Point startPoint;
22  cv::Size size;
23  cv::String text;
24  bool clicked;
25  cv::Mat* img;
26 
28  struct STYLE
29  {
30  int fontFace = cv::FONT_HERSHEY_SIMPLEX;
31  float fontScale = 1;
32  cv::Scalar fontColor = cv::Scalar(205, 205, 205);
33  cv::Scalar lineColor = cv::Scalar(113, 101, 99);
34  cv::Scalar lineColorClicked = cv::Scalar(0, 255, 0);
35  cv::Scalar fillColor = cv::Scalar(87, 73, 71);
36  int lineThickness = 1;
37  int cornerRadius = 3;
38  }style;
39 
49  void roundedRectangle(cv::Mat* img, cv::Point topLeft, cv::Point bottomRight,
50  const cv::Scalar lineColor, const cv::Scalar fillColor, const int thickness, const int cornerRadius);
51 
52 public:
54  Button();
55 
60  Button(cv::Point startPoint, int height, cv::String text);
61 
65  void draw(cv::Mat* img);
66 
70  void setStartPoint(cv::Point startPoint);
71 
75  void checkClick(int x, int y);
76 
79  int getWidth();
80 
83  bool getClick();
84 };
A button that can be clicked. Member of GUI classes Graphic group.
Definition: Button.h:19
struct Button::STYLE style
button style information
void setStartPoint(cv::Point startPoint)
Sets the topleft corner of the button.
Definition: Button.cpp:73
cv::String text
Button Text.
Definition: Button.h:23
Button()
Default constructor.
Definition: Button.cpp:13
bool clicked
Button state.
Definition: Button.h:24
void draw(cv::Mat *img)
Draws the button to the image matrix.
Definition: Button.cpp:58
int getWidth()
Gets the width of the button.
Definition: Button.cpp:84
void checkClick(int x, int y)
Checks if a mouse-click event happened inside the button.
Definition: Button.cpp:77
cv::Size size
Height and Width of the button in pixels.
Definition: Button.h:22
void roundedRectangle(cv::Mat *img, cv::Point topLeft, cv::Point bottomRight, const cv::Scalar lineColor, const cv::Scalar fillColor, const int thickness, const int cornerRadius)
creates a rectangle with rounded corners
Definition: Button.cpp:29
bool getClick()
Gets the button state.
Definition: Button.cpp:88
cv::Mat * img
Pointer to the img where the button should be drawn.
Definition: Button.h:25
cv::Point startPoint
X and Y coordinate of the topleft corner in pixels.
Definition: Button.h:21
Button style information.
Definition: Button.h:29
cv::Scalar lineColor
Line color (black)
Definition: Button.h:33
int fontFace
Font type
Definition: Button.h:30
cv::Scalar fillColor
Fill color (grey)
Definition: Button.h:35
cv::Scalar fontColor
Font color (white)
Definition: Button.h:32
float fontScale
Font size.
Definition: Button.h:31
int lineThickness
Line thickness in pixels.
Definition: Button.h:36
cv::Scalar lineColorClicked
Line color when clicked (green)
Definition: Button.h:34
int cornerRadius
Radius of the corner in pixels.
Definition: Button.h:37