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
<meta-data | |
android:name="com.google.firebase.ml.vision.DEPENDENCIES" | |
android:value="face" /> | |
<!-- To use multiple models: android:value="face,model2,model3" --> |
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
<uses-permission android:name="android.permission.CAMERA"/> |
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.camerakit:camerakit:1.0.0-beta3.11' | |
implementation 'com.camerakit:jpegkit:0.1.0' | |
implementation 'org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.3.31' | |
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.0.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
<com.camerakit.CameraKitView | |
android:layout_above="@id/btn_detect" | |
android:layout_width="match_parent" | |
android:id="@+id/camera_view" | |
android:layout_height="match_parent" | |
android:adjustViewBounds="true" | |
android:keepScreenOn="true" | |
app:camera_flash="auto" | |
app:camera_facing="back" | |
app:camera_focus="continuous" |
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
<Button android:layout_width="match_parent" | |
android:layout_height="wrap_content" | |
android:layout_alignParentBottom="true" | |
android:layout_centerHorizontal="true" | |
android:id="@+id/btn_detect" | |
android:text="Detect"/> |
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
override fun onResume() { | |
super.onResume() | |
camera_view.onResume() | |
} | |
override fun onPause() { | |
super.onPause() | |
camera_view.onPause() | |
} | |
override fun onStart() { | |
super.onStart() |
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
override fun onRequestPermissionsResult(requestCode: Int, permissions: Array<String>, grantResults: IntArray) { | |
super.onRequestPermissionsResult(requestCode, permissions, grantResults) | |
camera_view.onRequestPermissionsResult(requestCode, permissions, grantResults) | |
} |
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
btn_detect.setOnClickListener { | |
camera_view.captureImage { cameraKitView, byteArray -> } | |
} |
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
btn_detect.setOnClickListener { | |
camera_view.captureImage { cameraKitView, byteArray -> | |
camera_view.onStop() | |
alertDialog.show() | |
var bitmap = BitmapFactory.decodeByteArray(byteArray, 0, byteArray?.size ?: 0) | |
bitmap = Bitmap.createScaledBitmap(bitmap, camera_view?.width ?: 0, camera_view?.height ?: 0, false) | |
runDetector(bitmap) | |
} | |
graphic_overlay.clear() | |
} |
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 image = FirebaseVisionImage.fromBitmap(bitmap) |
OlderNewer