Skip to content

File dllengine.h

File List > dllengine.h

Go to the documentation of this file

#pragma once
#ifndef DLLENGINE_H
#define DLLENGINE_H

#include <string>
#include <vector>

using namespace std;

namespace autocare
{
    class TrtInferencer;

    struct ModelConfig {
        // GPU device index
        int gpuID = 0;
        // model input size
        int width = 0;
        int height = 0;
        // engine file path
        std::string enginePath = std::string("");
    };

    class Inferencer
    {
    private:
        autocare::TrtInferencer* trt_inferencer;
    public:
        static Inferencer* CreateInferencer(string onnxPath, int gpuID, string configPath=string(""));
        static Inferencer* CreateInferencer(string onnxPath, ModelConfig modelCofing);
        Inferencer(TrtInferencer *trt_inferencer);
        ~Inferencer();
        int do_inference(unsigned char* bgr_input_data, unsigned char* bgr_output_data,
            const int width, const int height);
        int get_gpuid();
    };
}

using namespace autocare;

#ifdef __cplusplus
extern "C" {
#endif

#ifdef DLLENGINE_EXPORTS
#define DLLENGINE_API __declspec(dllexport)
#else
#define DLLENGINE_API __declspec(dllimport)
#endif

    autocare::Inferencer DLLENGINE_API *get_inferencer(string onnxPath, int gpuID, string configPath=string(""));

    autocare::Inferencer DLLENGINE_API* get_inference_with_model_config(string onnxPath, autocare::ModelConfig modelConfig);

    int DLLENGINE_API do_inference(autocare::Inferencer* inferencer,
        unsigned char* bgr_input_data, unsigned char* bgr_output_data,
        const int width, const int height);

    void DLLENGINE_API remove_inferencer(autocare::Inferencer* inferencer);

     int DLLENGINE_API get_gpuid(autocare::Inferencer* inferencer);

     autocare::ModelConfig DLLENGINE_API get_model_config(int width, int height, int gpuID = 0, string enginePath = string(""));


#ifdef __cplusplus
}
#endif

#endif