-
Notifications
You must be signed in to change notification settings - Fork 7
/
KeypointDetector.h
41 lines (34 loc) · 1.01 KB
/
KeypointDetector.h
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
#pragma once
#include <algorithm>
#include <numeric>
#include <opencv2/opencv.hpp>
#include "NvInfer.h"
#include "NvOnnxParser.h"
#include "Utils.h"
static const int KEYPOINTS_CHANNEL = 3;
static const int NUM_KEYPOINTS = 7;
static const int KEYPOINT_SCALE = 1;
// #define KPT_PROFILE
class KeypointDetector
{
public:
KeypointDetector(std::string onnxFile, std::string trtFile, int input_w, int input_h, int max_batch);
~KeypointDetector();
std::vector<std::vector<cv::Point2f>> doInference(std::vector<cv::Mat>& imgs);
private:
std::vector<cv::Point2f> interpretOutputTensor(float *tensor, int width, int height);
Logger logger_;
#ifdef KPT_PROFILE
nvinfer1::Profiler profiler_;
#endif
nvinfer1::IExecutionContext* context_;
nvinfer1::ICudaEngine* engine_;
nvinfer1::IRuntime* runtime_;
std::unique_ptr<float[]> inputData_;
std::unique_ptr<float[]> outputData_;
cudaStream_t stream_;
std::unique_ptr<void*[]> buffers_;
int inputW_;
int inputH_;
int maxBatch_;
};