Skip to content

Commit

Permalink
Merge pull request #50 from Yoonit-Labs/development
Browse files Browse the repository at this point in the history
Development
  • Loading branch information
TeruyaHaroldo authored Mar 18, 2021
2 parents 5e6536c + 7bc0a3b commit 5f117b1
Show file tree
Hide file tree
Showing 23 changed files with 224 additions and 194 deletions.
32 changes: 16 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@
![GitHub tag (latest by date)](https://img.shields.io/github/v/tag/Yoonit-Labs/android-yoonit-camera?color=lightgrey&label=version&style=for-the-badge) ![GitHub](https://img.shields.io/github/license/Yoonit-Labs/android-yoonit-camera?color=lightgrey&style=for-the-badge)

A Android plugin to provide:
- Modern Android Camera API [Camera X](https://developer.android.com/training/camerax)
- Camera preview (Front & Back)
- [Google MLKit](https://developers.google.com/ml-kit) integration
- [PyTorch](https://pytorch.org/mobile/home/) integration
- Computer vision pipeline
- Face detection, capture and image crop
- Understanding of the human face
- Frame capture
- Capture timed images
- QR Code scanning
* Modern Android Camera API [Camera X](https://developer.android.com/training/camerax)
* Camera preview (Front & Back)
* [Google MLKit](https://developers.google.com/ml-kit)
* [PyTorch](https://pytorch.org/mobile/home/) integration
* Computer vision pipeline
* Face detection, capture and image crop
* Understanding of the human face
* Frame capture
* Capture timed images
* QR Code scanning

## Table of Contents

Expand Down Expand Up @@ -56,7 +56,7 @@ dependencies {

## Usage

All the functionalities that the `android-yoonit-camera` provides is accessed through the `CameraView`, that includes the camera preview. Below we have the basic usage code, for more details, see the [**Methods**](#methods).
All the functionalities that the `android-yoonit-camera` provides is accessed through the `CameraView`, that includes the camera preview. Below we have the basic usage code, for more details, see the [**API**](#api) section.


### Camera Preview
Expand Down Expand Up @@ -150,7 +150,7 @@ fun buildCameraEventListener(): CameraEventListener = object : CameraEventListen
| Function | Parameters | Valid values | Return Type | Description
| - | - | - | - | -
| startPreview | - | - | void | Start camera preview if has permission.
| startCaptureType | `captureType: String` | <ul><li>`"none"`</li><li>`"face"`</li><li>`"qcode"`</li><li>`"frame"`</li></ul> | void | Set capture type none, face, QR Code or frame.
| startCaptureType | `captureType: String` | <ul><li>`"none"`</li><li>`"face"`</li><li>`"qrcode"`</li><li>`"frame"`</li></ul> | void | Set capture type none, face, QR Code or frame.
| stopCapture | - | - | void | Stop any type of capture.
| destroy | - | - | void | Remove camera preview.
| toggleCameraLens | - | - | void | Set camera lens facing front or back.
Expand All @@ -161,8 +161,8 @@ fun buildCameraEventListener(): CameraEventListener = object : CameraEventListen
| setOutputImageWidth | `width: Int` | Any positive `number` value that represents in pixels | void | Set face image width to be created in pixels.
| setOutputImageHeight | `height: Int` | Any positive `number` value that represents in pixels | void | Set face image height to be created in pixels.
| setSaveImageCaptured | `enable: Bool` | `true` or `false` | void | Set to enable/disable save image when capturing face and frame.
| setFaceDetectionBox | `enable: Bool` | `true` or `false` | void | Set to show a detection box when face detected.
| setFaceContours | `enable: Bool` | `true` or `false` | void | Set to show/hide face contours when face detected.
| setFaceDetectionBox | `enable: Bool` | `true` or `false` | void | Set to enable/disable detection box when face detected.
| setFaceContours | `enable: Bool` | `true` or `false` | void | Set to enable/disable face contours when face detected.
| setFaceContoursColor | `alpha: Int, red: Int, green: Int, blue: Int` | Positive value between 0 and 255 | void | Set face contours ARGB color.
| setFacePaddingPercent | `facePaddingPercent: Float` | Any positive `Float` value | void | Set face image and bounding box padding in percent.
| setFaceCaptureMinSize | `faceCaptureMinSize: Float` | Value between `0` and `1`. Represents the percentage. | void | Set the minimum face capture based on the screen width.
Expand All @@ -174,7 +174,7 @@ fun buildCameraEventListener(): CameraEventListener = object : CameraEventListen
| setFaceROILeftOffset | `leftOffset: Float` | Values between `0` and `1`. Represents the percentage. | void | Distance in percentage of the left face bounding box with the left of the camera preview.
| setFaceROIMinSize | `minimumSize: Float` | Values between `0` and `1`. Represents the percentage. | void | Set the minimum face size related with the region of interest.
| setFaceROIAreaOffset | `enable: Bool` | `true` or `false` | void | Set face region of interest offset color visibility.
| setFaceROIAreaOffsetColor | `alpha: Int, red: Int, green: Int, blue: Int` | Any positive integer between 0 and 255 | void | Set face region of interest area offset color. Default value is (100, 255, 255, 255).
| setFaceROIAreaOffsetColor | `alpha: Int, red: Int, green: Int, blue: Int` | Any positive integer between 0 and 255 | void | Set face region of interest area offset color. Default value is `(100, 255, 255, 255)`.
| setBlurFaceDetectionBox | `enable: Bool` | `true` or `false` | void | Enable/disable blur in face detection box.
| setColorEncodingCapture | `colorEncoding: String` | <ul><li>`"RGB"`</li><li>`"YUV"`</li> | void | Set the color encoding for the saved images.
| setComputerVision | `enable: Boolean` | `true` or `false` | void | Enable/disable computer vision usage.
Expand All @@ -185,7 +185,7 @@ fun buildCameraEventListener(): CameraEventListener = object : CameraEventListen

| Event | Parameters | Description
| - | - | -
| onImageCaptured | `type: String, count: Int, total: Int, imagePath: String, inferences: ArrayList<Pair<String, FloatArray>>` | Must have started capture type of face/frame (see `startCaptureType`). Emitted when the image file is created: <ul><li>type: 'face' | 'frame'</li><li>count: current index</li><li>total: total to create</li><li>imagePath: the image path</li><li>inferences: each array element is the image inference result.</li><ul>
| onImageCaptured | `type: String, count: Int, total: Int, imagePath: String, inferences: ArrayList<Pair<String, FloatArray>>` | Must have started capture type of face/frame (see `startCaptureType`). Emitted when the image file is created: <ul><li>type: '"face"' or '"frame"'</li><li>count: current index</li><li>total: total to create</li><li>imagePath: the image path</li><li>inferences: each array element is the image inference result.</li><ul>
| onFaceDetected | `x: Int, y: Int, width: Int, height: Int, leftEyeOpenProbability: Float?, rightEyeOpenProbability: Float?, smilingProbability: Float?, headEulerAngleX: Float, headEulerAngleY: Float, headEulerAngleZ: Float` | Must have started capture type of face. Emit the [face analysis](#face-analysis).
| onFaceUndetected | - | Must have started capture type of face. Emitted after `onFaceDetected`, when there is no more face detecting.
| onEndCapture | - | Must have started capture type of face/frame. Emitted when the number of image files created is equal of the number of images set (see the method `setNumberOfImages`).
Expand Down
2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ android {
minSdkVersion 22
targetSdkVersion 29
versionCode 1
versionName "2.2.1"
versionName "2.7.1"

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* | Yoonit Camera lib for Android applications |
* | Haroldo Teruya & Victor Goulart @ Cyberlabs AI 2020 |
* | Haroldo Teruya & Victor Goulart @ Cyberlabs AI 2020-2021 |
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
*/

Expand Down
5 changes: 2 additions & 3 deletions yoonit-camera/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ android {
minSdkVersion 22
targetSdkVersion 30
versionCode 1
versionName "2.5.2"
versionName "2.7.1"

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
consumerProguardFiles "consumer-rules.pro"
Expand Down Expand Up @@ -60,11 +60,10 @@ dependencies {
implementation "androidx.camera:camera-view:1.0.0-alpha15"

// Facefy
implementation 'com.github.Yoonit-Labs:android-yoonit-facefy:1.0.2'
implementation 'com.github.Yoonit-Labs:android-yoonit-facefy:1.0.3'

// MLKit
implementation "com.google.mlkit:barcode-scanning:16.0.3"
implementation "com.google.mlkit:face-detection:16.0.2"

// KTLint
ktlint "com.pinterest:ktlint:0.39.0"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* | Yoonit Camera lib for Android applications |
* | Haroldo Teruya & Victor Goulart @ Cyberlabs AI 2020 |
* | Haroldo Teruya & Victor Goulart @ Cyberlabs AI 2020-2021 |
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
*/

Expand Down Expand Up @@ -84,17 +84,15 @@ class CameraGraphicView constructor(
*
* @param faceDetectionBox The face coordinates within the graphic view.
* @param faceBitmap The face bitmap to be blurred.
* @param faceContours The face coordinates within the graphic view.
* @param faceContours List of points that represents the shape of the face detected .
*/
fun handleDraw(
faceDetectionBox: RectF?,
faceBitmap: Bitmap?,
faceContours: MutableList<PointF>?
) {
this.faceDetectionBox = faceDetectionBox
faceBitmap?.let {
this.faceBlurBitmap = BlurBuilder.blur(this.context, it)
}
this.faceBlurBitmap = faceBitmap
this.faceContours = faceContours

this.postInvalidate()
Expand All @@ -120,7 +118,7 @@ class CameraGraphicView constructor(
private fun drawFaceBlur(canvas: Canvas) {
this.faceBlurBitmap?.let { faceBlurBitmap ->
canvas.drawBitmap(
faceBlurBitmap,
BlurBuilder.blur(this.context, faceBlurBitmap),
null,
this.faceDetectionBox!!,
null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* | Yoonit Camera lib for Android applications |
* | Haroldo Teruya & Victor Goulart @ Cyberlabs AI 2020 |
* | Haroldo Teruya & Victor Goulart @ Cyberlabs AI 2020-2021 |
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
*/

Expand Down Expand Up @@ -219,7 +219,7 @@ open class CameraView @JvmOverloads constructor(
}

/**
* Set to show/hide face detection box when face detected.
* Set to enable/disable face detection box when face detected.
*
* @param enable The indicator to show or hide the face detection box.
* Default value is true.
Expand All @@ -229,9 +229,9 @@ open class CameraView @JvmOverloads constructor(
}

/**
* Set to show/hide face contours when face detected.
* Set to enable/disable face contours when face detected.
*
* @param enable The indicator to show or hide the face landmarks.
* @param enable The indicator to show or hide the face contours.
* Default value is true.
*/
fun setFaceContours(enable: Boolean) {
Expand All @@ -241,10 +241,11 @@ open class CameraView @JvmOverloads constructor(
/**
* Set face contours ARGB color.
*
* @param red Integer that represent red color.
* @param green Integer that represent green color.
* @param blue Integer that represent blue color.
* Default value is 255, 255, 255 (white color).
* @param alpha The alpha value.
* @param red The red value.
* @param green The green value.
* @param blue The blue value.
* Default value is `(100, 255, 255, 255)`.
*/
fun setFaceContoursColor(alpha: Int, red: Int, green: Int, blue: Int) {
if (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* | Yoonit Camera lib for Android applications |
* | Haroldo Teruya & Victor Goulart @ Cyberlabs AI 2020 |
* | Haroldo Teruya & Victor Goulart @ Cyberlabs AI 2020-2021 |
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
*/

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* | Yoonit Camera lib for Android applications |
* | Haroldo Teruya & Victor Goulart @ Cyberlabs AI 2020 |
* | Haroldo Teruya & Victor Goulart @ Cyberlabs AI 2020-2021 |
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
*/

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* | Yoonit Camera lib for Android applications |
* | Haroldo Teruya & Victor Goulart @ Cyberlabs AI 2020 |
* | Haroldo Teruya & Victor Goulart @ Cyberlabs AI 2020-2021 |
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
*/

Expand Down
Loading

0 comments on commit 5f117b1

Please sign in to comment.