派生自 Algorithm/baseDetector

sunty
2022-03-21 d0a24896f95b4e060011852f80048ebfb0bf5f55
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
56
57
58
59
60
61
62
63
64
65
66
67
68
#ifndef CLASS_DETECTOR_H_
#define CLASS_DETECTOR_H_
 
#include "API.h"
#include <iostream>
#include <opencv2/opencv.hpp>
 
struct Result
{
    int         id        = -1;
    float     prob    = 0.f;
    cv::Rect rect;
};
 
using BatchResult = std::vector<Result>;
 
enum ModelType
{
    YOLOV3,
    YOLOV4,
    YOLOV5
};
 
enum Precision
{
    INT8 = 0,
    FP16,
    FP32
};
 
struct Config
{
    std::string file_model_cfg                    = "configs/yolov4.cfg";
 
    std::string file_model_weights                = "configs/yolov4.weights";
 
    float detect_thresh                            = 0.5;
 
    ModelType    net_type                        = YOLOV4;
 
    Precision    inference_precison                = FP32;
    
    int    gpu_id                                    = 0;
 
    std::string calibration_image_list_file_txt = "configs/calibration_images.txt";
 
};
 
class API Detector
{
public:
    explicit Detector();
 
    ~Detector();
 
    void init(const Config &config);
 
    void detect(const std::vector<cv::Mat> &mat_image, std::vector<BatchResult> &vec_batch_result);
 
private:
    
    Detector(const Detector &);
    const Detector &operator =(const Detector &);
    class Impl;
    Impl *_impl;
};
 
#endif // !CLASS_QH_DETECTOR_H_