用C++重新封装了一下NNIE的代码。把sample里面大部分的那坨垃圾代码全部弃用了,主要贡献如下,代码量是sample代码的几十分之一,结构清晰简单易懂
代码片段和文件信息
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2020-04-01 09:14 nnie-master
文件 1601 2020-04-01 09:14 nnie-masterMakefile
文件 946 2020-04-01 09:14 nnie-masterREADME.md
目录 0 2020-04-01 09:14 nnie-masterdata
目录 0 2020-04-01 09:14 nnie-masterdata
nie_image
目录 0 2020-04-01 09:14 nnie-masterdata
nie_image est
文件 519168 2020-04-01 09:14 nnie-masterdata
nie_image estdog_bike_car.bgr
目录 0 2020-04-01 09:14 nnie-masterdata
nie_model
目录 0 2020-04-01 09:14 nnie-masterdata
nie_modeldetection
文件 62936560 2020-04-01 09:14 nnie-masterdata
nie_modeldetectioninst_yolov3_cycle.wk
目录 0 2020-04-01 09:14 nnie-mastersample
文件 13049 2020-04-01 09:14 nnie-mastersamplesample_nnie_main.cpp
目录 0 2020-04-01 09:14 nnie-mastersrc
文件 208 2020-04-01 09:14 nnie-mastersrcTensor.h
文件 1389 2020-04-01 09:14 nnie-mastersrcins_nnie_interface.cpp
文件 1222 2020-04-01 09:14 nnie-mastersrcins_nnie_interface.h
文件 16469 2020-04-01 09:14 nnie-mastersrc
nie_core.c
文件 1594 2020-04-01 09:14 nnie-mastersrc
nie_core.h
文件 23141 2020-04-01 09:14 nnie-mastersrcsample_comm.h
文件 23497 2020-04-01 09:14 nnie-mastersrcsample_comm_nnie.c
文件 11216 2020-04-01 09:14 nnie-mastersrcsample_comm_nnie.h
文件 25121 2020-04-01 09:14 nnie-mastersrcsample_comm_svp.c
文件 7857 2020-04-01 09:14 nnie-mastersrcsample_comm_svp.h
文件 10961 2020-04-01 09:14 nnie-mastersrcutil.h
目录 0 2020-04-01 09:14 nnie-master hird_party
目录 0 2020-04-01 09:14 nnie-master hird_partyhisi
目录 0 2020-04-01 09:14 nnie-master hird_partyhisiinclude
文件 8341 2020-04-01 09:14 nnie-master hird_partyhisiincludeaacdec.h
文件 5967 2020-04-01 09:14 nnie-master hird_partyhisiincludeaacenc.h
文件 7694 2020-04-01 09:14 nnie-master hird_partyhisiincludeacodec.h
目录 0 2020-04-01 09:14 nnie-master hird_partyhisiincludeadapt
............此处省略600个文件信息
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include “ins_nnie_interface.h“
#include “Tensor.h“
#include “util.h“
#include “opencv2/highgui.hpp“
#include “opencv2/imgproc.hpp“
#include “opencv2/core.hpp“
#include “opencv2/dnn.hpp“
/******************************************************************************
* function : show usage
******************************************************************************/
void Usage(char *pchPrgName)
{
printf(“Usage : %s
“ pchPrgName);
printf(“index:
“);
printf(“ 1) Yolov3(Read File).
“);
printf(“ 2) Yolov2(Read File).
“);
}
void yolov2DetectDemo(const char *model_path const char *image_path)
{
NNIE yolov2;
yolov2.init(model_path);
printf(“yolov2 start
“);
struct timeval tv1;
struct timeval tv2;
long t1 t2 time;
unsigned char *data = (unsigned char *)malloc(sizeof(unsigned char) * 240 * 80 * 3);
cv::Mat img = cv::imread(image_path);
cv::resize(img img cv::Size(240 80));
int step = img.step;
int h = img.rows;
int w = img.cols;
int c = img.channels();
printf(“h=%d
“ h);
printf(“w=%d
“ w);
printf(“c=%d
“ c);
unsigned char *data1 = (unsigned char *)img.data;
int count = 0;
for (int k = 0; k < c; k++)
{
for (int i = 0; i < h; i++)
{
for (int j = 0; j < w; j++)
{
data[count++] = data1[i * step + j * c + k];
}
}
}
gettimeofday(&tv1 NULL);
yolov2.run(data);
gettimeofday(&tv2 NULL);
t1 = tv2.tv_sec - tv1.tv_sec;
t2 = tv2.tv_usec - tv1.tv_usec;
time = (long)(t1 * 1000 + t2 / 1000);
printf(“yolov2 NNIE inference time : %dms
“ time);
gettimeofday(&tv1 NULL);
Tensor output0 = yolov2.getOutputTensor(0);
printf(“%d
“ output0.width);
printf(“%d
“ output0.height);
printf(“%d
“ output0.channel);
/*yolov2的参数*/
int img_width = 240;
int img_height = 80;
int num_classes = 35;
int kBoxPerCell = 2;
int feature_index0 = 0;
int feature_index1 = 1;
int feature_index2 = 2;
float conf_threshold = 0.2;
float nms_threshold = 0.2;
int is_nms = 1;
std::vector ids;
std::vector boxes;
std::vector confidences;
const std::vector> anchors = {
{{3.638 5.409} {3.281 4.764}}};
parseYolov2Feature(img_width
img_height
num_classes
kBoxPerCell
feature_index0
conf_threshold
anchors[0]
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2020-04-01 09:14 nnie-master
文件 1601 2020-04-01 09:14 nnie-masterMakefile
文件 946 2020-04-01 09:14 nnie-masterREADME.md
目录 0 2020-04-01 09:14 nnie-masterdata
目录 0 2020-04-01 09:14 nnie-masterdata
nie_image
目录 0 2020-04-01 09:14 nnie-masterdata
nie_image est
文件 519168 2020-04-01 09:14 nnie-masterdata
nie_image estdog_bike_car.bgr
目录 0 2020-04-01 09:14 nnie-masterdata
nie_model
目录 0 2020-04-01 09:14 nnie-masterdata
nie_modeldetection
文件 62936560 2020-04-01 09:14 nnie-masterdata
nie_modeldetectioninst_yolov3_cycle.wk
目录 0 2020-04-01 09:14 nnie-mastersample
文件 13049 2020-04-01 09:14 nnie-mastersamplesample_nnie_main.cpp
目录 0 2020-04-01 09:14 nnie-mastersrc
文件 208 2020-04-01 09:14 nnie-mastersrcTensor.h
文件 1389 2020-04-01 09:14 nnie-mastersrcins_nnie_interface.cpp
文件 1222 2020-04-01 09:14 nnie-mastersrcins_nnie_interface.h
文件 16469 2020-04-01 09:14 nnie-mastersrc
nie_core.c
文件 1594 2020-04-01 09:14 nnie-mastersrc
nie_core.h
文件 23141 2020-04-01 09:14 nnie-mastersrcsample_comm.h
文件 23497 2020-04-01 09:14 nnie-mastersrcsample_comm_nnie.c
文件 11216 2020-04-01 09:14 nnie-mastersrcsample_comm_nnie.h
文件 25121 2020-04-01 09:14 nnie-mastersrcsample_comm_svp.c
文件 7857 2020-04-01 09:14 nnie-mastersrcsample_comm_svp.h
文件 10961 2020-04-01 09:14 nnie-mastersrcutil.h
目录 0 2020-04-01 09:14 nnie-master hird_party
目录 0 2020-04-01 09:14 nnie-master hird_partyhisi
目录 0 2020-04-01 09:14 nnie-master hird_partyhisiinclude
文件 8341 2020-04-01 09:14 nnie-master hird_partyhisiincludeaacdec.h
文件 5967 2020-04-01 09:14 nnie-master hird_partyhisiincludeaacenc.h
文件 7694 2020-04-01 09:14 nnie-master hird_partyhisiincludeacodec.h
目录 0 2020-04-01 09:14 nnie-master hird_partyhisiincludeadapt
............此处省略600个文件信息
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件举报,一经查实,本站将立刻删除。
评论列表(条)