123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101 |
- #ifndef DATA_HPP__
- #define DATA_HPP__
- #include <string>
- #include <vector>
- #include <map>
- #include <iostream>
- #include <memory>
- #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<Point> 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<Box>;
- } // namespace data
- #endif // DATA_HPP__
|