安卓脸部识别开源库 | FaceDetector

名称 FaceDetector
语言 Android
平台 GitHub
作者 Fotoapparat
链接 点此进入
备注 更多精彩开源库推荐请访问明灯小站

该开源库能让你在Android上实现通过手机相机实时识别人的面部,其特点有:
简单易用;
多重相机开源库都可以使用该框架做面部识别;
使用C++编写核心库,效率高;
效果

screenshot.gif

使用方法

  1. 添加依赖
repositories {
    maven {
        url  "http://dl.bintray.com/fotoapparat/fotoapparat"
    }
}

compile 'io.fotoapparat:facedetector:1.0.0'

// If you are using Fotoapparat add this one as well
compile 'io.fotoapparat.fotoapparat:library:1.2.0' // or later version
  1. 编写布局
<io.fotoapparat.facedetector.view.CameraOverlayLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent">

    <!-- 配置可以根据你的需求调整,但是CameraView必须在 CameraOverlayLayout 布局中 -->
    <io.fotoapparat.view.CameraView
        android:id="@+id/cameraView"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />

    <!-- 这个View将显示面部识别的框框 -->
    <io.fotoapparat.facedetector.view.RectanglesView
        android:id="@+id/rectanglesView"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:rectanglesColor="@color/colorAccent"
        app:rectanglesStrokeWidth="2dp"/>

</io.fotoapparat.facedetector.view.CameraOverlayLayout>
  1. Java代码中创建FaceDetectorProcessor
FaceDetectorProcessor processor = FaceDetectorProcessor.with(this)
    .listener(faces -> {
        rectanglesView.setRectangles(faces);  // (Optional) Show detected faces on the view.

        // ... or do whatever you want with the result
    })
    .build()
  1. 添加处理器到Fotoapparat
Fotoapparat.with(this)
    .into(cameraView)
    // the rest of configuration
    .frameProcessor(processor)
    .build()

更多使用方法可以参考其GitHub。

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • 发现 关注 消息 iOS 第三方库、插件、知名博客总结 作者大灰狼的小绵羊哥哥关注 2017.06.26 09:4...
    肇东周阅读 14,222评论 4 61
  • Android 自定义View的各种姿势1 Activity的显示之ViewRootImpl详解 Activity...
    passiontim阅读 175,625评论 25 709
  • 一 已是黄昏时分,女人正独自坐在咖啡厅中,穿着最心仪的衣服,配着最精美的饰物,好一个幸福女人的样子!可是她的眼神却...
    Lealie阅读 2,540评论 2 1
  • app和游戏都能赚钱。看每个人自己的选择。要对自己有信心,这个是最重要的。坚持go
    工匠良辰阅读 3,157评论 0 0
  • 一直不能接受独自带娃,原因有两个:第一,实在是太辛苦,每天娃就像念经一样妈妈妈妈妈妈妈妈……她对这个世...
    D083关璐洁上海阅读 1,001评论 0 0