DaoAI World C++ SDK
Loading...
Searching...
No Matches
common.h
1#pragma once
2#include "API_EXPORT.h"
3#include <iostream>
4#include <vector>
5
6namespace DaoAI
7{
8 namespace DeepLearning
9 {
10 enum class Device_Type
11 {
12 CPU, GPU
13 };
14
15 class Point
16 {
17 public:
18 DAOAI_API Point(const float& x, const float& y);
19 DAOAI_API Point();
20 DAOAI_API ~Point();
21
22 // overload operator<< to print out polygon object
23 friend DAOAI_API std::ostream& operator<<(std::ostream& ss, const Point& point);
24
25 DAOAI_API Point operator+(const Point& point) const;
26 DAOAI_API Point operator-(const Point& point) const;
27
28 float x = 0, y = 0;
29 };
30
31 class Polygon
32 {
33 public:
34 DAOAI_API Polygon(const std::vector<Point>& points);
35 DAOAI_API Polygon();
36 DAOAI_API ~Polygon();
37
38 // overload operator<< to print out polygon object
39 friend DAOAI_API std::ostream& operator<<(std::ostream& ss, const Polygon& polygon);
40
41 // overload operator<< to print out polygon object
42 friend DAOAI_API std::stringstream& operator<<(std::stringstream& ss, const Polygon& polygon);
43
44 std::vector<Point> points;
45 };
46
47 class Box
48 {
49 public:
50
51 enum class Type
52 {
53 XYXY, XYWH
54 };
55
61 DAOAI_API Box(const Point& p1, const Point& p2, const float& angle = 0);
62
70 DAOAI_API Box(const float& a1, const float& a2, const float& a3, const float& a4, const float& angle = 0, const Type& type = Type::XYXY);
71
72 DAOAI_API ~Box();
73
77 DAOAI_API Polygon toPolygon() const;
78
79 DAOAI_API std::string toString() const;
80
81 // overload operator<< to print out polygon object
82 friend DAOAI_API std::ostream& operator<<(std::ostream& ss, const Box& box);
83
84 // overload operator<< to print out polygon object
85 friend DAOAI_API std::stringstream& operator<<(std::stringstream& ss, const Box& box);
86
90 DAOAI_API const float& h() const;
91
95 DAOAI_API const float& w() const;
96
100 DAOAI_API const float& x1() const;
101
105 DAOAI_API const float& y1() const;
106
110 DAOAI_API const float& x2() const;
111
115 DAOAI_API const float& y2() const;
116
120 DAOAI_API const float& angle() const;
121
126 DAOAI_API Box toType(const Type& type) const;
127
128 std::vector<float> data;
129 Type type;
130 };
131
132 class Image
133 {
134 public:
135 enum class Type
136 {
137 RGB, BGR, GRAYSCALE
138 };
139
140 // create an image object from headers with a new deep copy of data buffer
141 DAOAI_API Image(const int& image_height, const int& image_width, const Image::Type& type, void* data);
142
143 DAOAI_API ~Image();
144
145 // create a deep copy of the Image object
146 DAOAI_API Image clone() const;
147
148 std::shared_ptr<uint8_t[]> data;
149 int width, height;
150 Type type;
151 };
152
153 namespace Utils
154 {
160 DAOAI_API std::vector<Polygon> convertMaskToPolygons(const Image& mask);
161
167 DAOAI_API Image convertPolygonsToMask(const std::vector<Polygon>& polygons, const int& image_height, const int& image_width);
168 }
169 }
170}
Definition common.h:48
DAOAI_API Polygon toPolygon() const
DAOAI_API Box(const float &a1, const float &a2, const float &a3, const float &a4, const float &angle=0, const Type &type=Type::XYXY)
DAOAI_API const float & x2() const
DAOAI_API const float & y2() const
DAOAI_API Box(const Point &p1, const Point &p2, const float &angle=0)
DAOAI_API const float & angle() const
DAOAI_API const float & w() const
DAOAI_API Box toType(const Type &type) const
DAOAI_API const float & x1() const
DAOAI_API const float & h() const
DAOAI_API const float & y1() const
Definition common.h:133
Definition common.h:16
Definition common.h:32