#include "VehiclePlate.h" #include //static string type[69] = { "京", "沪", "津", "渝", "冀", "晋", "蒙", "辽", "吉", "黑", "苏", "浙", "皖", "闽", "赣", "鲁", "豫", "鄂", "湘", "粤", "桂", "琼", "川", "贵", "云", "藏", "陕", "甘", "青", "宁", "新", "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F", "G", "H", "J", "K", "L", "M", "N", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", "警", "学", "使", "澳" }; int VehiclePlateDetectRecog_Init(void *&handle, int gpuid) { vpd_param param; param.gpuid = gpuid; param.mode = DEVICE_GPU; param.thresld = 0.3; param.process_w = 320; param.process_h = 320; param.engine = ENGINE_TENSORRT; param.max_batch = 20; param.serialize_file = "./serialize_file/VPD"; vpr_param rparam; rparam.gpuid =gpuid; rparam.mode = DEVICE_GPU; param.engine = ENGINE_TENSORRT; param.max_batch = 20; param.serialize_file = "./serialize_file/VPR"; int ret = vpdr_init(&handle, param, rparam); if (ret != 0) { cout << "Init platedr Failed!" << endl; return FAILED; } return SUCCESS; } #include int VehiclePlateDetectRecog_Process(void * handle, sy_img * batch_img, int batchsize, vplate_result *&result) { /*初始化结果结构体*/ vplates_result * all_result = new vplates_result[batchsize] {}; for (int i = 0; i gpu_data; for (int i = 0; i < batchsize; i++) { if (batch_img[i].data_ == NULL) { cout << i << " data null" << endl; } unsigned char * data_ = (unsigned char *)malloc(batch_img[i].w_ *batch_img[i].h_ * batch_img[i].c_ * sizeof(unsigned char)); cudaMemcpy(data_, batch_img[i].data_, batch_img[i].w_ *batch_img[i].h_ * batch_img[i].c_ * sizeof(unsigned char), cudaMemcpyDeviceToHost); gpu_data.push_back(batch_img[i].data_); batch_img[i].data_ = data_; } //cout << "begin vpdr_batch" << endl; int index_count = vpdr_batch(handle, batch_img, batchsize, all_result); //cout << "end vpdr_batch" << endl; for (int b = 0; b < batchsize; b++) { double max_score = 0.0; int best_index = 0; for (int j = 0; j < MAXPLATECOUNT; j++) { if (all_result[b].vehicle_plate_infos[j].rect.left_ == -1) { continue; } if (all_result[b].vehicle_plate_infos[j].detect_score > max_score) { max_score = all_result[b].vehicle_plate_infos[j].detect_score; best_index = j; } } /*{ result[b].detect_score = all_result[b][best_index].detect_score; result[b].num_score = all_result[b][best_index].num_score; result[b].rect.left_ = all_result[b][best_index].rect.left_; result[b].rect.height_ = all_result[b][best_index].rect.height_; result[b].rect.top_ = all_result[b][best_index].rect.top_; result[b].rect.width_ = all_result[b][best_index].rect.width_; result[b].type = all_result[b][best_index].type; } */ memcpy(&result[b], &all_result[b].vehicle_plate_infos[best_index], sizeof(vplate_result)); } //for (int i = 0; i