-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtext_box.cpp
More file actions
31 lines (27 loc) · 770 Bytes
/
text_box.cpp
File metadata and controls
31 lines (27 loc) · 770 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#include "text_box.h"
TextBox::TextBox(std::vector<cv::Point>& points, std::string text){
this->points = points;
this->text = text;
}
void TextBox::get_rectangle_box(cv::Point& p1, cv::Point& p2){
int minx = 100000, miny = 100000, maxx = 0, maxy = 0;
for(auto const& value: this->points){
minx = std::min(minx, value.x);
miny = std::min(miny, value.y);
maxx = std::max(maxx, value.x);
maxy = std::max(maxy, value.y);
}
p1.x = minx;
p1.y = miny;
p2.x = maxx;
p2.y = maxy;
}
std::ostream &operator<<(std::ostream &os, TextBox &m) {
std::vector<cv::Point> points = m.get_points();
os<<"oriented box: ";
for(int i = 0; i < points.size(); i++){
os<<points[i]<<" ";
}
os<<" text: "<<m.get_text()<<std::endl;
return os;
}