#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 <json/json.h>
|
#include "../utils.hpp"
|
|
using namespace nvinfer1;
|
|
class HAT {
|
|
public:
|
~HAT();
|
bool isLoad = false;//是否加载
|
bool initConfig(const char* enginefile, double confThreshold = 0.7, double nmsThreshold = 0.45);
|
char* detect(unsigned char* bgrImageData, int width, int height);
|
void 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;
|
|
double confThreshold_ = 0.5, nmsThreshold_ = 0.45;
|
|
float* input_data_host = nullptr;
|
float* output_data_host = nullptr;
|
|
float* input_data_device = nullptr;
|
float* output_data_device = nullptr;
|
|
};
|