测试FaceRecognitionDotNet报错“Error deserializing object of type int”

  FaceRecognitionDotNet宣称是最简单的.net人脸识别模块,其内部使用Dlib、DlibDotNet、OpenCVSharp等模块实现人脸识别,网上有不少介绍文章。实际测试过程中,在调用FaceRecognition.Create函数创建FaceRecognition实例对象时,会报如下错误:

bash 复制代码
DlibDotNet.SerializationException:"An error occurred while trying to read the first object from the file E:\MyPrograms\C#\TestViewFaceCore\TestFaceRecognitionDotNet\Models\shape_predictor_68_face_landmarks.dat.
ERROR: Error deserializing object of type int


  开始认为是个人电脑中的模型文件有误,于是在参考文献4中重新下载了所有模型,然后运行程序还是报相同错误。
  百度错误信息,在stackoverflow中找到个类似问题(参考文献2),文章中提到有可能是shape_predictor_68_face_landmarks.dat文件不对,于是从参考文献1中下载FaceRecognitionDotNet源码,并将FaceRecognition中加载部分模型文件的代码注释,如下所示。

csharp 复制代码
private FaceRecognition(string directory)
{
    ...
    ...

    //this._PosePredictor68Point?.Dispose();
    //this._PosePredictor68Point = ShapePredictor.Deserialize(predictor68PointModel);

    ....
    ....
}

  重新编译FaceRecognitionDotNet项目后再调用,上述报错问题解决。但又出现以下异常,从报错信息来看,缺少DlibDotNetNativeDnn.dll文件,但是将DlibDotNetNativeDnn.dll及DlibDotNetNative.dll文件复制到exe同级文件夹或者同级文件夹下的runtimes\win-x86\native文件夹内都不行。最后找到参考文献3,其内提到在exe同级文件夹下创建dll\x86子文件夹并复制dll文件,照此方式能解决报错问题,至此即可正常测试FaceRecognitionDotNet的用法了。

参考文献:

1https://github.com/takuya-takeuchi/FaceRecognitionDotNet/tree/master

2https://stackoverflow.com/questions/50349818/dlib-error-deserializing-object-of-type-unsigned-long-while-deserializing-object

3https://blog.csdn.net/qq_29881799/article/details/134267102

4https://github.com/ageitgey/face_recognition_models/tree/master/face_recognition_models/models

相关推荐
波力海苔夹心脆6753 小时前
VisionMaster 两级位置修正实战:塑料外壳与金属件装配角度检测
经验分享·计算机视觉·c#·visionmaster·海康机器人·位置修正
小羊没烦恼!4 小时前
C#综合揭秘——Entity Framework 并发处理详解
java·开发语言·前端·javascript·数据库·mysql·c#
淡海水6 小时前
05-02-源码-Boehm GC标记阶段
算法·unity·c#·游戏引擎·gc
信可维6 小时前
AI 读 Word 表格总读错?先查合并单元格和表头这 3 处
开发语言·人工智能·c#·word·软件工程
半摆烂日常8 小时前
手机表单的左滑操作:触摸事件的处理细节
大数据·开发语言·人工智能·智能手机·https·c#
绛橘色的日落(。・∀・)ノ8 小时前
C#学习笔记
笔记·学习·c#
asdzx678 小时前
C# 将 HTML 转换为 PDF:基于 Chrome 的转换方案
pdf·c#·html
1-1=010 小时前
.NET 实现后台任务
c#·.net·.netcore·quartz·hangfire
步步为营DotNet10 小时前
从分代预算到 DATAS:.NET GC 调优到底在调什么
c#·.net·内存管理·gc·datas
淡海水10 小时前
05-03-源码-Boehm GC分配与碎片管理
开发语言·算法·unity·c#·游戏引擎·gc