admin
2025-04-14 fa5b069f9021a73210dcc45ebcc89883306372e6
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
#pragma once
#include "NvInfer.h"
 
#include <cuda_runtime.h>
#include <device_launch_parameters.h>
#include <assert.h>
#include <fstream>
#include <string>
#include <opencv2/opencv.hpp>
#include "../utils.hpp"
 
using namespace nvinfer1;
 
class BELT {
 
public:
 
    ~BELT();
    bool isLoad = false;//是否加载
    //leftarea�й�������,rightarea�й�������,beltareaƤ������˳ʱ�봫��4�����xy���꣬x1,y1,x2,y2,x3,y3,x4,y4,��8��ֵ
    bool initConfig(const char* enginefile, int* leftarea, int* rightarea, int* beltarea,
    float bigcoal_threshold = 0.4, float beltdeviation_threshold = 0.3, float confThreshold = 0.5);
    int detect(cv::Mat& image, std::vector<Box>& boxes);
 
 
private:
    IRuntime* runtime{ nullptr };
    ICudaEngine* engine{ nullptr };
    IExecutionContext* context{ nullptr };
 
    int input_batch = 1;
    int input_channel = 3;
    int input_height = 640;
    int input_width = 640;
    int input_numel;
 
    int num_classes = 1;
    int output_numbox;
    int output_numprob;
    int output_numel;
 
    cudaStream_t stream = nullptr;
 
    float threshold = 0.2;//��ú��ֱ����ֵ����ֵΪú��ռƤ��������ȵı���
    float threshold_ = 0.05;//Ƥ����ƫ��ֵ,��ֵΪƤ��ƫ����ռƤ��������ȵı���
    float confThreshold_ = 0.5;//������ֵ
    float nmsThreshold_ = 0.45;
 
    float* input_data_host = nullptr;
    float* output_data_host = nullptr;
 
    float* input_data_device = nullptr;
    float* output_data_device = nullptr;
 
    std::vector<point> leftarea_;//�й�������㼯(˳ʱ��)
    std::vector<point> rightarea_;//�й�������㼯(˳ʱ��)
    std::vector<point> beltarea_;//Ƥ������㼯(˳ʱ��)
    float belt_top_cy, belt_bottom_cy;//Ƥ���������±��е��y
    float belt_top_length, belt_bottom_length;//Ƥ���������±ߵ����س���
    float k;//����/���ض���y���صı任��б��
    //float belt_length=1;//Ƥ���������(����)
    //k = (belt_length / belt_top_length - belt_length / belt_bottom_length)/(belt_top_cy- belt_bottom_cy);
    //lpx =k * (y- belt_top_cy) + belt_length / belt_top_length;//����ÿ��yλ�ö�Ӧ���صĺ���
};