This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
val options = FirebaseVisionFaceDetectorOptions.Builder().build() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
val detector = FirebaseVision.getInstance().getVisionFaceDetector(options) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private fun runDetector(bitmap: Bitmap) { | |
val image = FirebaseVisionImage.fromBitmap(bitmap) | |
val options = FirebaseVisionFaceDetectorOptions.Builder() | |
.build() | |
val detector = FirebaseVision.getInstance() | |
.getVisionFaceDetector(options) | |
detector.detectInImage(image) | |
.addOnSuccessListener { faces -> | |
processFaceResult(faces) | |
}.addOnFailureListener { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class GraphicOverlay(context: Context, attrs: AttributeSet) : View(context, attrs) { | |
private val mLock = Any() | |
private var mPreviewWidth: Int = 0 | |
private var mWidthScaleFactor = 1.0f | |
private var mPreviewHeight: Int = 0 | |
private var mHeightScaleFactor = 1.0f | |
private var mFacing = CameraSource.CAMERA_FACING_BACK | |
private val mGraphics = HashSet<Graphic>() | |
/** |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class RectOverlay(private val graphicOverlay: GraphicOverlay, | |
private val rect: Rect) : GraphicOverlay.Graphic(graphicOverlay) { | |
private val RECT_COLOR = Color.RED | |
private val strokeWidth = 4.0f | |
private val rectPaint: Paint = Paint() | |
init { | |
rectPaint.color = RECT_COLOR | |
rectPaint.style = Paint.Style.STROKE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<com.aligkts.facedetection.GraphicOverlay | |
android:id="@+id/graphic_overlay" | |
android:layout_width="match_parent" | |
android:layout_height="match_parent"/> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<RelativeLayout | |
xmlns:android="http://schemas.android.com/apk/res/android" | |
xmlns:tools="http://schemas.android.com/tools" | |
xmlns:app="http://schemas.android.com/apk/res-auto" | |
android:layout_width="match_parent" | |
android:layout_height="match_parent" | |
tools:context=".MainActivity"> | |
<Button android:layout_width="match_parent" android:layout_height="wrap_content" | |
android:layout_alignParentBottom="true" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private fun processFaceResult(faces: MutableList<FirebaseVisionFace>) { | |
faces.forEach { | |
val bounds = it.boundingBox | |
val rectOverLay = RectOverlay(graphic_overlay, bounds) | |
graphic_overlay.add(rectOverLay) | |
} | |
alertDialog.dismiss() | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
implementation 'com.squareup.retrofit2:retrofit:2.5.0' | |
implementation 'com.squareup.retrofit2:converter-gson:2.3.0' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
data class UserResponse( | |
@field:SerializedName("documents") | |
val documents: List<DocumentsItem?>? = null | |
) |