安卓脸部识别开源库 | FaceDetector

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

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

使用方法
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">

    
    <io.fotoapparat.view.CameraView
        android:id="@+id/cameraView"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />

    
    <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。

有问题的可以访问原帖地址:https://www.mingtern.com/subject/1659708/ 进行交流。

你可能感兴趣的:(安卓)