人脸库保存到文件,再读取就不能用了
vc绿茶2 发布于2018-10 浏览:820 回复:1
0
收藏
最后编辑于2018-10

typedef struct {
CImage image;
CRect rcFace;
CString * name;
AFR_FSDK_FACEMODEL faceModel;
} FACE;

std::vector   mFaceModels;
int   mFaceModelsNum;

 

// 保存人脸库
bool CDemoDlg::SaveFaceModels()
{
//以下保存
CFile file1(ZQDszFilePath + "FaceModels.dll", CFile::modeCreate | CFile::modeReadWrite);
CArchive ar1(&file1, CArchive::store);


long i1 = 0, j1 = 0, k1 = 0, len1 = 0;
CString str1 = _T("");


k1 = mFaceModelsNum;
ar1 << k1;


for (i1 = 0; i1 < k1; i1++)
{
ar1 << *(mFaceModels[i1]->name);                  //名字
ar1 << mFaceModels[i1]->faceModel.lFeatureSize;   //RECT

len1 = sizeof(mFaceModels[i1]->faceModel.pbFeature);
ar1 << len1;     //
for(j1=0; j1ar1 << mFaceModels[i1]->faceModel.pbFeature[j1];     //

}
ar1.Close();
file1.Close();
return false;
}

// 读取人脸库
int CDemoDlg::ReadFaceModels()
{
CFile file1(ZQDszFilePath + "FaceModels.dll", CFile::modeReadWrite);
if (0 == file1.GetLength())
{
file1.Close();
return 0;
}
CArchive ar1(&file1, CArchive::load);

long i1 = 0, j1 = 0, k1 = 0, len1 = 0;
CString str1 = _T("");

ar1 >> k1;
for (i1 = 0; i1 < k1; i1++)
{
FACE *face = new FACE;
face->name = new CString;
ar1 >> *(face->name);    //名字

ar1 >> face->faceModel.lFeatureSize;   //RECT

ar1 >> len1;     //
face->faceModel.pbFeature = new MByte[len1];
for (j1 = 0; j1 < len1; j1++)
ar1 >> face->faceModel.pbFeature[j1];     //

mFaceModels.push_back(face);  //保存到人脸库
mFaceModelsNum++;  //人脸库 人脸数加1
}

ar1.Close();
file1.Close();

return 0;
}

各位大神,问个问题,

人脸库保存到文件,再读取就不能用了,表现为比对不出结果,或者比对出错。求保存读取人脸库源码,或者帮我改改错,谢谢!

收藏
点赞
0
个赞
共1条回复 最后由彦丶子凡回复于2018-10
#2彦丶子凡回复于2018-10

你的代码写的有问题

0
TOP
切换版块