From a6c6dd4665868b148176b9505908297b0c5f725b Mon Sep 17 00:00:00 2001 From: Jewel Date: Fri, 5 Nov 2021 22:28:13 +0800 Subject: [PATCH] update openvino demo (#4486) * update openvino demo --- deploy/third_engine/demo_openvino/README.md | 15 ++++++++++++++- deploy/third_engine/demo_openvino/main.cpp | 14 +++++++------- .../third_engine/demo_openvino/picodet_openvino.h | 3 ++- 3 files changed, 23 insertions(+), 9 deletions(-) diff --git a/deploy/third_engine/demo_openvino/README.md b/deploy/third_engine/demo_openvino/README.md index d9409b268..426edf60c 100644 --- a/deploy/third_engine/demo_openvino/README.md +++ b/deploy/third_engine/demo_openvino/README.md @@ -2,7 +2,7 @@ This fold provides PicoDet inference code using [Intel's OpenVINO Toolkit](https://software.intel.com/content/www/us/en/develop/tools/openvino-toolkit.html). Most of the implements in this fold are same as *demo_ncnn*. -**Recommand** to use the xxx.tar.gz file to install instead of github method. +**Recommand** to use the xxx.tar.gz file to install instead of github method, [link](https://registrationcenter-download.intel.com/akdlm/irc_nas/18096/l_openvino_toolkit_p_2021.4.689.tgz). ## Install OpenVINO Toolkit @@ -105,6 +105,19 @@ Download PicoDet openvino model [PicoDet openvino model download link](https://p move picodet openvino model files to the demo's weight folder. Then run these commands: +### Edit file +``` +step1: +main.cpp +#define image_size 416 +... +auto detector = PicoDet("../weight/picodet_m_416.xml"); +... +step2: +picodet_openvino.h +#define image_size 416 +``` + ### Webcam ```shell diff --git a/deploy/third_engine/demo_openvino/main.cpp b/deploy/third_engine/demo_openvino/main.cpp index 044f91c35..6833a305b 100644 --- a/deploy/third_engine/demo_openvino/main.cpp +++ b/deploy/third_engine/demo_openvino/main.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2020 PaddlePaddle Authors. All Rights Reserved. +// Copyright (c) 2021 PaddlePaddle Authors. All Rights Reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -18,6 +18,7 @@ #include #include #include +#define image_size 416 struct object_rect { int x; @@ -216,9 +217,8 @@ void draw_bboxes(const cv::Mat& bgr, const std::vector& bboxes, object_ cv::putText(image, text, cv::Point(x, y + label_size.height), cv::FONT_HERSHEY_SIMPLEX, 0.4, cv::Scalar(255, 255, 255)); + cv::imwrite("../predict.jpg",image); } - - cv::imshow("image", image); } @@ -236,7 +236,7 @@ int image_demo(PicoDet& detector, const char* imagepath) } object_rect effect_roi; cv::Mat resized_img; - resize_uniform(image, resized_img, cv::Size(320, 320), effect_roi); + resize_uniform(image, resized_img, cv::Size(image_size, image_size), effect_roi); auto results = detector.detect(resized_img, 0.4, 0.5); draw_bboxes(image, results, effect_roi); } @@ -253,7 +253,7 @@ int webcam_demo(PicoDet& detector, int cam_id) cap >> image; object_rect effect_roi; cv::Mat resized_img; - resize_uniform(image, resized_img, cv::Size(320, 320), effect_roi); + resize_uniform(image, resized_img, cv::Size(image_size, image_size), effect_roi); auto results = detector.detect(resized_img, 0.4, 0.5); draw_bboxes(image, results, effect_roi); cv::waitKey(1); @@ -271,7 +271,7 @@ int video_demo(PicoDet& detector, const char* path) cap >> image; object_rect effect_roi; cv::Mat resized_img; - resize_uniform(image, resized_img, cv::Size(320, 320), effect_roi); + resize_uniform(image, resized_img, cv::Size(image_size, image_size), effect_roi); auto results = detector.detect(resized_img, 0.4, 0.5); draw_bboxes(image, results, effect_roi); cv::waitKey(1); @@ -287,7 +287,7 @@ int benchmark(PicoDet& detector) double time_min = DBL_MAX; double time_max = -DBL_MAX; double time_avg = 0; - cv::Mat image(320, 320, CV_8UC3, cv::Scalar(1, 1, 1)); + cv::Mat image(image_size, image_size, CV_8UC3, cv::Scalar(1, 1, 1)); for (int i = 0; i < warm_up + loop_num; i++) { diff --git a/deploy/third_engine/demo_openvino/picodet_openvino.h b/deploy/third_engine/demo_openvino/picodet_openvino.h index 003eed4c6..27c997ba1 100644 --- a/deploy/third_engine/demo_openvino/picodet_openvino.h +++ b/deploy/third_engine/demo_openvino/picodet_openvino.h @@ -21,6 +21,7 @@ #include #include +#define image_size 416 typedef struct HeadInfo { @@ -66,7 +67,7 @@ private: BoxInfo disPred2Bbox(const float*& dfl_det, int label, float score, int x, int y, int stride); static void nms(std::vector& result, float nms_threshold); std::string input_name_; - int input_size_ = 320; + int input_size_ = image_size; int num_class_ = 80; int reg_max_ = 7; -- GitLab