1 Star 0 Fork 0

sklink/rv1126_rknn_blazeface

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
BlazeFace.h 2.43 KB
一键复制 编辑 原始数据 按行查看 历史
jason 提交于 2021-11-11 15:13 +08:00 . first commit
#ifndef _BLAZEFACE_H_
#define _BLAZEFACE_H_
#include <cstdio>
#include <cstdint>
#include <cstdlib>
#include <fstream>
#include <iostream>
#include <ctime>
#include "opencv2/opencv.hpp"
#include <opencv2/core.hpp>
#include <opencv2/videoio.hpp>
#include "rknn/rknn_api.h"
#define OBJ_NUMB_MAX_SIZE 64
typedef struct _BOX_RECT
{
int left;
int right;
int top;
int bottom;
} BOX_RECT;
typedef struct __detect_result_t
{
int keypoints[6][2];
BOX_RECT box;
} detect_result_t;
typedef struct _detect_result_group_t
{
int count;
detect_result_t results[OBJ_NUMB_MAX_SIZE];
} detect_result_group_t;
class BlazeFace {
typedef cv::Mat Mat;
private:
unsigned char *m_model;
int m_model_size;
rknn_context m_context;
rknn_input_output_num m_io_num;
rknn_output* m_outputs;
rknn_tensor_attr* output_attrs;
float scoreThreshold = 0.7;
float sigmoidScoreThreshold = logf(scoreThreshold/(1-scoreThreshold));
float iouThreshold = 0.3;
int inputHeight = 128;
int inputWidth = 128;
int channels = 3;
std::vector<double> anchor;
struct str
{
float value;
int index;
};
public:
explicit BlazeFace(const char *filename);
static void print_tensor(rknn_tensor_attr *attr) {
printf("index=%d name=%s n_dims=%d dims=[%d %d %d %d] n_elems=%d size=%d fmt=%d type=%d qnt_type=%d fl=%d zp=%d scale=%f\n",
attr->index, attr->name, attr->n_dims, attr->dims[3], attr->dims[2], attr->dims[1], attr->dims[0],
attr->n_elems, attr->size, 0, attr->type, attr->qnt_type, attr->fl, attr->zp, attr->scale);
}
bool model_init();
void compute_iou(std::vector<std::vector<float>> boxes, std::vector<unsigned int> scores_indexes, std::vector<float> areas, int index, std::vector<float> &ious);
std::vector<unsigned int> non_max_suppression(std::vector<std::vector<float>> boxes, std::vector<float> scores_vector, float threshold, int size);
bool forward(Mat img, detect_result_group_t* detect_result_group);
template<typename T>
std::vector<unsigned int> argsort(const std::vector<T> array);
void postprocess(detect_result_group_t *group, int w, int h);
~BlazeFace() {
delete m_model;
// Release
if (m_context >= 0) {
rknn_destroy(m_context);
}
// Release rknn_outputs
rknn_outputs_release(m_context, m_io_num.n_output, m_outputs);
};
};
#endif
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C++
1
https://gitee.com/sklink/rv1126_rknn_blazeface.git
git@gitee.com:sklink/rv1126_rknn_blazeface.git
sklink
rv1126_rknn_blazeface
rv1126_rknn_blazeface
master

搜索帮助