未验证 提交 a6c6dd46 编写于 作者: J Jewel 提交者: GitHub

update openvino demo (#4486)

* update openvino demo
上级 b20e9023
......@@ -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
......
// 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 <opencv2/highgui/highgui.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <iostream>
#define image_size 416
struct object_rect {
int x;
......@@ -216,9 +217,8 @@ void draw_bboxes(const cv::Mat& bgr, const std::vector<BoxInfo>& 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++)
{
......
......@@ -21,6 +21,7 @@
#include <opencv2/core.hpp>
#include <inference_engine.hpp>
#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<BoxInfo>& 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;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册