#ifndef DATA_HPP__ #define DATA_HPP__ #include #include #include #include #include #include "opencv2/opencv.hpp" #include "common/check.hpp" namespace data { struct Point { float x; float y; float score; Point() : x(0), y(0), score(0) {} Point(float x, float y, float score) : x(x), y(y), score(score) {} Point(const Point& p) : x(p.x), y(p.y), score(p.score) {} Point& operator=(const Point& p) { x = p.x; y = p.y; score = p.score; return *this; } }; struct InstanceSegmentMap { int width = 0, height = 0; // width % 8 == 0 unsigned char *data = nullptr; // is width * height memory InstanceSegmentMap(int width, int height) { this->width = width; this->height = height; checkRuntime(cudaMallocHost(&this->data, width * height)); } virtual ~InstanceSegmentMap() { if (this->data) { checkRuntime(cudaFreeHost(this->data)); this->data = nullptr; } this->width = 0; this->height = 0; } }; struct Box { float left, top, right, bottom, score; // 在目标追踪中,将class_id赋值表示追踪的目标id int class_id; std::string label; std::vector keypoints; cv::Mat seg_mask; Box() : left(0), top(0), right(0), bottom(0), score(0), class_id(0), label("") {} Box(float left, float top, float right, float bottom, float score, int class_id) : left(left), top(top), right(right), bottom(bottom), score(score), class_id(class_id), label("") {} Box(float left, float top, float right, float bottom, float score, int class_id, const std::string& label) : left(left), top(top), right(right), bottom(bottom), score(score), class_id(class_id), label(label) {} Box(const Box& b) : left(b.left), top(b.top), right(b.right), bottom(b.bottom), score(b.score), class_id(b.class_id), label(b.label), keypoints(b.keypoints), seg_mask(b.seg_mask.clone()) {} Box(Box&& b) noexcept : left(b.left), top(b.top), right(b.right), bottom(b.bottom), score(b.score), class_id(b.class_id), label(std::move(b.label)), keypoints(std::move(b.keypoints)), seg_mask(std::move(b.seg_mask)) {} Box& operator=(const Box& b) { left = b.left; top = b.top; right = b.right; bottom = b.bottom; score = b.score; class_id = b.class_id; label = b.label; keypoints = b.keypoints; seg_mask = b.seg_mask.clone(); return *this; } }; using BoxArray = std::vector; } // namespace data #endif // DATA_HPP__