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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
| #include "PaImageDrawElement.h"
| #include <basic/util/opencv/CvUtil.h>
|
| PaImageDrawElement::PaImageDrawElement() {
|
| }
|
| void PaImageDrawElement::darwProperty(cv::Mat &image, string key, string value, int x, int y) {
| cv::putText(image, key + ": " + value, cv::Point(x, y), cv::HersheyFonts::FONT_HERSHEY_PLAIN, 1.5,
| cv::Scalar(255, 255, 0), 2);
| }
|
| void PaImageDrawElement::processImage(cv::Mat &image) {
|
| auto yoloObjectsData = yoloObjects.getData();
|
| // {\"x\":4,\"y\":6},{\"x\":4,\"y\":537},{\"x\":955,\"y\":536},{\"x\":951,\"y\":9},{\"x\":4,\"y\":6}]
| CvPoint spoint1[5] = {{4,6},{4,537},{955,536},{951,9},{4,6}};
|
| cv::Rect rect(100,6,1700,1200);
| cv::rectangle(image, rect, cv::Scalar(0, 0, 255), 2);
| for (auto yoloObj: yoloObjectsData) {
| auto rect = CvUtil::zoomRect(yoloObj.rect, 1, 1);
| // Scalar scalar;
| if(yoloObj.id>=0)
| {
| if(yoloObj.isMask)
| {
| //scalar=cv::Scalar(0, 0, 255);
| cv::rectangle(image, rect, cv::Scalar(0, 0, 255), 2);
| }
| else
| {
| //scalar=cv::Scalar(255, 0, 0);
| cv::rectangle(image, rect, cv::Scalar(255, 0, 0), 2);
| }
| }
| else
| {
| // scalar=cv::Scalar(0, 255, 255);
| cv::rectangle(image, rect, cv::Scalar(0, 255, 255), 2);
| }
| //cv::rectangle(image, rect, scalar, 2);
| int i = 0;
| for (auto &property:yoloObj.properties) {
| darwProperty(image, property.first, property.second, rect.x + rect.width, rect.y + 40 * i++);
| }
| }
| }
|
|
|
| void PaImageDrawElement::setYoloObjects(std::vector<ScoredRect> value) {
| yoloObjects = value;
| }
|
|