admin
2025-04-14 c9de25e292060cab6d7c817027b42d8b6b7d2ad0
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
#pragma once
 
#include "NvInfer.h"
#include <cuda_runtime.h>
#include<device_launch_parameters.h>
 
#include <fstream>
 
#include <opencv2/opencv.hpp>
#include"utils.hpp"
 
 
using namespace nvinfer1;
 
class clasification {
 
public:
    ~clasification();
    bool initConfig(const char* modelpath);
    int detect(cv::Mat& image);
 
 
private:
    IRuntime* runtime{ nullptr };
    ICudaEngine* engine{ nullptr };
    IExecutionContext* context{ nullptr };
 
    int input_batch = 1;
    int input_channel = 3;
    int input_height = 224;
    int input_width = 224;
    int input_numel;
 
    int num_classes = 2;
    int output_classs = 1;
    int output_numel;
 
    int image_area = 1;
 
    cudaStream_t stream = nullptr;
 
    float* input_data_host = nullptr;
    float* output_data_host = nullptr;
 
    float* input_data_device = nullptr;
    float* output_data_device = nullptr;
 
};