//// Created by tunm on 2023年1月26日.//#include <iostream>#include "hyper_lpr_sdk.h"#include "opencv2/opencv.hpp"static const std::vector<std::string> TYPES = {"蓝牌", "黄牌单层", "白牌单层", "绿牌新能源", "黑牌港澳", "香港单层", "香港双层", "澳门单层", "澳门双层", "黄牌双层"};int main(int argc, char **argv) {char *model_path = argv[1];char *image_path = argv[2];cv::Mat image = cv::imread(image_path);// create ImageDataHLPR_ImageData data = {0};data.data = image.ptr<uint8_t>(0);data.width = image.cols;data.height = image.rows;data.format = STREAM_BGR;data.rotation = CAMERA_ROTATION_0;// create DataBufferP_HLPR_DataBuffer buffer = HLPR_CreateDataBuffer(&data);// create contextHLPR_ContextConfiguration configuration = {0};configuration.models_path = model_path;configuration.max_num = 5;configuration.det_level = DETECT_LEVEL_LOW;configuration.use_half = false;configuration.nms_threshold = 0.5f;configuration.rec_confidence_threshold = 0.5f;configuration.box_conf_threshold = 0.30f;configuration.threads = 1;P_HLPR_Context ctx = HLPR_CreateContext(&configuration);HREESULT ret = HLPR_ContextQueryStatus(ctx);if (ret != HResultCode::Ok) {printf("create error.\n");return -1;}// exec plate recognitionHLPR_PlateResultList results = {0};double time;time = (double)cv::getTickCount();HLPR_ContextUpdateStream(ctx, buffer, &results);time = ((double)cv::getTickCount() - time) / cv::getTickFrequency();printf("cost: %f\n", time);for (int i = 0; i < results.plate_size; ++i) {std::string type;if (results.plates[i].type == HLPR_PlateType::PLATE_TYPE_UNKNOWN) {type = "未知";} else {type = TYPES[results.plates[i].type];}cv::rectangle(image, cv::Point2f(results.plates[i].x1, results.plates[i].y1), cv::Point2f(results.plates[i].x2, results.plates[i].y2),cv::Scalar(100, 100, 200), 3);printf("<%d> %s, %s, %f\n", i + 1, type.c_str(),results.plates[i].code, results.plates[i].text_confidence);}// cv::imwrite("out.jpg", image);cv::imshow("out", image);cv::waitKey(0);// release bufferHLPR_ReleaseDataBuffer(buffer);// release contextHLPR_ReleaseContext(ctx);return 0;}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。