#include "rknn_api.h"
#include <thread>
#include <string>
#include <iostream>
#include <fstream>
#include "opencv2/core/core.hpp"
#include "opencv2/imgproc/imgproc.hpp"
#include "opencv2/highgui/highgui.hpp"
using namespace std;
void YOLO(string model_path)
{
FILE *fp_ = fopen(model_path.c_str(), "rb");
if (fp_ == NULL)
{
printf("fopen %s fail!\n", model_path.c_str());
return;
}
fseek(fp_, 0, SEEK_END);
int model_len = ftell(fp_);
void *model_ = malloc(model_len);
fseek(fp_, 0, SEEK_SET);
if (model_len != fread(model_, 1, model_len, fp_))
{
printf("fread %s fail!\n", model_path.c_str());
free(model_);
return;
}
rknn_context ctx = 0;
int ret = rknn_init(&ctx, model_, model_len, RKNN_FLAG_PRIOR_MEDIUM);
if (ret < 0)
{
printf("rknn_init fail! ret=%d\n", ret);
if (ctx)
rknn_destroy(ctx);
if (model_)
free(model_);
if (fp_)
fclose(fp_);
return;
}
RK3399 Pro C++加载两个不同模型
最新推荐文章于 2024-08-30 17:02:13 发布