#ifdef VP_WITH_TRT #include "vp_trt_vehicle_scanner.h" namespace vp_nodes { vp_trt_vehicle_scanner::vp_trt_vehicle_scanner(std::string node_name, std::string vehicle_scan_model_path): vp_primary_infer_node(node_name, "") { vehicle_scanner = std::make_shared(vehicle_scan_model_path); this->initialized(); } vp_trt_vehicle_scanner::~vp_trt_vehicle_scanner() { deinitialized(); } // please refer to vp_infer_node::run_infer_combinations void vp_trt_vehicle_scanner::run_infer_combinations(const std::vector>& frame_meta_with_batch) { assert(frame_meta_with_batch.size() == 1); std::vector mats_to_infer; // start auto start_time = std::chrono::system_clock::now(); // prepare data, as same as base class vp_primary_infer_node::prepare(frame_meta_with_batch, mats_to_infer); auto prepare_time = std::chrono::duration_cast(std::chrono::system_clock::now() - start_time); start_time = std::chrono::system_clock::now(); std::vector> vehicles; vehicle_scanner->detect(mats_to_infer, vehicles); assert(vehicles.size() == 1); auto& vehicle_list = vehicles[0]; auto& frame_meta = frame_meta_with_batch[0]; for (int i = 0; i < vehicle_list.size(); i++) { auto& objbox = vehicle_list[i]; // check value range objbox.x = std::max(objbox.x, 0); objbox.y = std::max(objbox.y, 0); objbox.width = std::min(objbox.width, frame_meta->frame.cols - objbox.x); objbox.height = std::min(objbox.height, frame_meta->frame.rows - objbox.y); if (objbox.width <= 0 || objbox.height <= 0) { continue; } auto target = std::make_shared(objbox.x, objbox.y, objbox.width, objbox.height, objbox.class_, objbox.score, frame_meta->frame_index, frame_meta->channel_index, objbox.label); // create target and update back into frame meta frame_meta->targets.push_back(target); } auto infer_time = std::chrono::duration_cast(std::chrono::system_clock::now() - start_time); // can not calculate preprocess time and postprocess time, set 0 by default. vp_infer_node::infer_combinations_time_cost(mats_to_infer.size(), prepare_time.count(), 0, infer_time.count(), 0); } void vp_trt_vehicle_scanner::postprocess(const std::vector& raw_outputs, const std::vector>& frame_meta_with_batch) { } } #endif