1、sdk_init 问题
in main
auth result is -1
运行控制台就停在 auth result is -1
解决办法:
使用release 运行而不是使用debug
2、项目路径问题
因为我的项目放在了一个带有中文的路径下,在使用人脸注册的时候,出现了问题。
一直报错 Can't open database: unable to open database file
上网查,关于百度SDK问题,无果,
查关于C# sqllite的问题,无果,
有答案的分2种:
1、权限问题
运行 calcs 加文件路径 + 权限 ,尝试后未解决
2、文件句柄问题
项目多次运行出现了未释放句柄(因为是百度底层实现的sql操作,应该不会出现这样弱智的错误)尝试后无果。
最后只能猜是文件路径问题,转移文件到根目录,运行,ok。
3、C#如何实现form窗体预览
控件:
using AForge;
using AForge.Controls;
using AForge.Video;
using AForge.Video.DirectShow;
using Size = System.Drawing.Size;
页面上添加:videoSourcePlayer1
代码:
videoDevices = new FilterInfoCollection(AForge.Video.DirectShow.FilterCategory.VideoInputDevice);
index_usb = 1;
videoSource = new VideoCaptureDevice(videoDevices[index_usb].MonikerString);//连接摄像头。
videoSource.VideoResolution = videoSource.VideoCapabilities[index_usb];
videoSourcePlayer1.VideoSource = videoSource;
// set NewFrame event handler
videoSourcePlayer1.Start();
timer1.Enabled = true;
Face.test_face_setting();//人脸识别设置
Face.test_face_manager();//照片库管理
FaceCompare.load_db_face();//将照片库加载到内存
定时器:
//定时获取照片 通过照片和加载到内存的照片库进行比对
private void timer1_Tick_1(object sender, EventArgs e)
{
RotatedRect box;
Bitmap bitmap = videoSourcePlayer1.GetCurrentVideoFrame();
string fileName = i+".jpg";
i++;
string filePase = @"D:\file\" + fileName;
bitmap.Save(filePase, ImageFormat.Jpeg);
FaceCompare comp = new FaceCompare();
comp.test_identify_with_all(filePase); //比对照片
bitmap.Dispose();
}
4、获取照片分辨率问题
_cameraDevice.VideoResolution = _cameraDevice.VideoCapabilities[15];//分辨率,每个摄像头获取到的分辨率数组不同,这里按需要选择分辨率。
加上这个,否则照片分辨率太低,也是无法进行读取特征值的。会导致识别失败