基于OpencvForUnity 人脸检测 移动端实现

it2025-12-05  3

基于OpencvForUnity 人脸检测 移动端实现

参考文章:https://blog.csdn.net/GottaYiWanLiu/article/details/90442274 https://blog.csdn.net/weixin_42872122/article/details/103232865

基本实现可参考以上两篇博客. 本文主要是记录一下在手机上运行获取人脸识别训练数据的代码

在FaceDetect.cs脚本里面.

void Start() { webcamTexToMat = transform.GetComponent<WebCamTextureToMatExample>(); //获取WebCamTextureToMatExample faceXml_path = Utils.getFilePath("haarcascade_frontalface_alt2.xml", true); Debug.Log(faceXml_path); //faceXml_path = Application.streamingAssetsPath + "/haarcascade_frontalface_alt2.xml"; //读取人脸识别训练数据xml gray = new Mat(); //初始化Mat faceRect = new MatOfRect(); //初始化识别到的人脸的区域 classifier = new CascadeClassifier(faceXml_path); //初始化人脸识别分类器 }

使用 Utils.getFilePath方法即可获取xml文件的Path.

然后打包即可. 但是我的手机运行起来掉帧很厉害,不知道是不是手机的问题.

最新回复(0)