派生自 Algorithm/baseDetector

孙天宇
2022-07-12 ce9d187fd294cca192a27f52719094e9df7b1b62
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
#ifndef __IMAGE_H__
#define __IMAGE_H__
 
#include "trt_utils.h"
 
struct BBoxInfo;
 
class DsImage
{
public:
    DsImage();
    DsImage(const std::string& path, const std::string &s_net_type_, const int& inputH, const int& inputW);
    DsImage(const cv::Mat& mat_image_, const std::string &s_net_type_, const int& inputH, const int& inputW);
    int getImageHeight() const { return m_Height; }
    int getImageWidth() const { return m_Width; }
    cv::Mat getLetterBoxedImage() const { return m_LetterboxImage; }
    cv::Mat getOriginalImage() const { return m_OrigImage; }
    std::string getImageName() const { return m_ImageName; }
    void addBBox(BBoxInfo box, const std::string& labelName);
    void showImage() const;
    void saveImageJPEG(const std::string& dirPath) const;
    std::string exportJson() const;
    void letterbox(const int& inputH, const int& inputW);
private:
    int m_Height;
    int m_Width;
    int m_XOffset;
    int m_YOffset;
    float m_ScalingFactor;
    std::string m_ImagePath;
    cv::RNG m_RNG;
    std::string m_ImageName;
    std::vector<BBoxInfo> m_Bboxes;
 
    // unaltered original Image
    cv::Mat m_OrigImage;
    // letterboxed Image given to the network as input
    cv::Mat m_LetterboxImage;
    // final image marked with the bounding boxes
    cv::Mat m_MarkedImage;
};
 
#endif