【鸿蒙南向实战开发】OpenHarmony人脸识别实现

202 篇文章 0 订阅
201 篇文章 0 订阅

一、简介

人脸识别,是基于人的脸部特征信息进行身份识别的一种生物识别技术。用摄像机或摄像头采集含有人脸的图像或视频流,并自动在图像中检测和跟踪人脸,进而对检测到的人脸进行脸部识别的一系列相关技术,通常也叫做人像识别、面部识别。

二、案例中使用的接口

接口描述
GetRecognizePoints获取人脸矩形框
FaceSearchInit人脸模型注册以及识别模块初始化
FaceSearchRegister人脸搜索识别注册
FaceSearchGetRecognize获取人脸搜索识别结果

三、人脸检测

1、在工程本地放入几张带人脸的图片,并利用GetRecognizePoints接口去检测图片中是否存在人脸


let path = getContext(this).bundleCodeDir + '/entry/resources/rawfile/'

let FdPath = path + "fd_2_00.dat";

let FlPath = path + "pd_2_00_pts81.dat";

            seetfaceApi.GetRecognizePoints(`${getContext(this).bundleCodeDir}/entry/resources/rawfile/${item.path}`, FdPath, FlPath)

.then(result => {

    console.log(`GetRecognizePoints success, result: ${JSON.stringify(result)}`)

    item.setCheckResult(result)

    this.refresh()

})

.catch(ex => {

    console.log(`GetRecognizePoints exception: ${JSON.stringify(ex)}`)

    item.setCheckResult(undefined)

    this.refresh()

})

四、人脸识别

1、调用FaceSearchInit接口,主要包含模型的注册以及识别模块的初始化


let path = getContext(this).bundleCodeDir + '/entry/resources/rawfile/'

let FdPath = path + "fd_2_00.dat";

let PdPath = path + "pd_2_00_pts5.dat";

let FrPath = path + "fr_2_10.dat";

seetfaceApi.FaceSearchInit(FdPath, PdPath, FrPath)

2、调用FaceSearchRegister接口,获取图片并注册人脸模型


let register = seetfaceApi.FaceSearchRegister({

name: item.name,

image[`${getContext(this).bundleCodeDir}/entry/resources/rawfile/${item.image}`],

sum: 1

})

3、调用FaceSearchGetRecognize接口,获取人脸识别结果


seetfaceApi.FaceSearchGetRecognize(`${getContext(this).bundleCodeDir}/entry/resources/rawfile/${item.path}`)

.then(result => {

    console.log(`GetRecognizePoints success, result: ${JSON.stringify(result)}`)

    item.setCheckResult(result)

    this.refresh()

})

.catch(ex => {

    console.log(`GetRecognizePoints exception: ${JSON.stringify(ex)}`)

    item.setCheckResult(undefined)

    this.refresh()

})

总结

通过这些接口,可以实现人脸识别以及检测的功能,希望能帮到大家

写在最后

●如果你觉得这篇内容对你还蛮有帮助,我想邀请你帮我三个小忙:
●点赞,转发,有你们的 『点赞和评论』,才是我创造的动力。
●关注小编,同时可以期待后续文章ing🚀,不定期分享原创知识。
●更多鸿蒙最新技术知识点,请移步前往小编:https://gitee.com/

在这里插入图片描述

  • 4
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值