| | |
| | | |
| | | #define FRAMES 3 |
| | | |
| | | int max_objects() { return C_SHARP_MAX_OBJECTS; } |
| | | |
| | | static Detector* detector; |
| | | //static std::unique_ptr<Detector> detector; |
| | | |
| | | int init(const char *configurationFilename, const char *weightsFilename, int gpu) { |
| | | std::string configurationFilenameString; |
| | | configurationFilenameString = configurationFilename; |
| | | std::string weightsFilenameString; |
| | | weightsFilenameString = weightsFilename; |
| | | |
| | | detector = new Detector(configurationFilenameString, weightsFilenameString, gpu); |
| | | return 1; |
| | | } |
| | | |
| | | int detect_image(const char *filename, bbox_t_container &container) { |
| | | std::string filenameString; |
| | | filenameString = filename; |
| | | |
| | | std::vector<bbox_t> detection = detector->detect(filenameString); |
| | | for (size_t i = 0; i < detection.size() && i < C_SHARP_MAX_OBJECTS; ++i) |
| | | container.candidates[i] = detection[i]; |
| | | return detection.size(); |
| | | } |
| | | |
| | | int detect_image2(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() { |
| | | detector->~Detector(); |
| | | //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) |
| | |
| | | int letterbox = 0; |
| | | float hier_thresh = 0.5; |
| | | detection *dets = get_network_boxes(&net, im.w, im.h, thresh, hier_thresh, 0, 1, &nboxes, letterbox); |
| | | if (nms) do_nms_sort_v3(dets, nboxes, l.classes, nms); |
| | | if (nms) do_nms_sort(dets, nboxes, l.classes, nms); |
| | | |
| | | std::vector<bbox_t> bbox_vec; |
| | | |