想实现一个图片数据的输入,然后输出一个特征结结果,一下写法对吗?
int DealWithModel(cv::Mat img, vector& V1)
{
const int img_width = 96; /*图像尺寸*/
const int img_height = 112;
const int img_channels = 3; /*图像量化通道*/
const int input_index = 0; // node name "Preprocessor/sub"
if (img.cols != img_width || img.rows != img_height) /*如果图像的大小和定义的不一样,则进行重新设置大小*/
{
cv::resize(img, img, cv::Size(img_width, img_height), (0, 0), (0, 0), cv::INTER_LINEAR);
}
FILE* fp = fopen(model_path, "rb"); /*加载模型*/
if (fp == NULL)
{
printf("fopen %s fail!\n", model_path);
return -1;
}
fseek(fp, 0, SEEK_END); /*标记fp从文件头开始到文件末尾*/
int model_len = ftell(fp); /*获取fp从头到尾的文件长度*/
void* model = malloc(model_len); /*动态申请内存*/
fseek(fp, 0, SEEK_SET); /*把文件指针指向文件的开始*/
if (model_len != fread(model