| | |
| | | |
| | | #define FRAMES 3 |
| | | |
| | | //static Detector* detector = NULL; |
| | | static std::unique_ptr<Detector> detector; |
| | | |
| | | int init(const char *configurationFilename, const char *weightsFilename, int gpu) |
| | | { |
| | | detector.reset(new Detector(configurationFilename, weightsFilename, gpu)); |
| | | return 1; |
| | | } |
| | | |
| | | int detect_image(const char *filename, bbox_t_container &container) |
| | | { |
| | | std::vector<bbox_t> detection = detector->detect(filename); |
| | | for (size_t i = 0; i < detection.size() && i < C_SHARP_MAX_OBJECTS; ++i) |
| | | container.candidates[i] = detection[i]; |
| | | return detection.size(); |
| | | } |
| | | |
| | | int detect_mat(const uint8_t* data, const size_t data_length, bbox_t_container &container) { |
| | | #ifdef OPENCV |
| | | std::vector<char> vdata(data, data + data_length); |
| | | cv::Mat image = imdecode(cv::Mat(vdata), 1); |
| | | |
| | | std::vector<bbox_t> detection = detector->detect(image); |
| | | for (size_t i = 0; i < detection.size() && i < C_SHARP_MAX_OBJECTS; ++i) |
| | | container.candidates[i] = detection[i]; |
| | | return detection.size(); |
| | | #else |
| | | return -1; |
| | | #endif // OPENCV |
| | | } |
| | | |
| | | int dispose() { |
| | | //if (detector != NULL) delete detector; |
| | | //detector = NULL; |
| | | detector.reset(); |
| | | return 1; |
| | | } |
| | | |
| | | #ifdef GPU |
| | | void check_cuda(cudaError_t status) { |
| | | if (status != cudaSuccess) { |
| | |
| | | detector_gpu_t &detector_gpu = *static_cast<detector_gpu_t *>(detector_gpu_ptr.get()); |
| | | return detector_gpu.net.h; |
| | | } |
| | | YOLODLL_API int Detector::get_net_color_depth() const { |
| | | detector_gpu_t &detector_gpu = *static_cast<detector_gpu_t *>(detector_gpu_ptr.get()); |
| | | return detector_gpu.net.c; |
| | | } |
| | | |
| | | |
| | | YOLODLL_API std::vector<bbox_t> Detector::detect(std::string image_filename, float thresh, bool use_mean) |