Fitur Kamera deteksi wajah
This commit is contained in:
parent
f928fa47d9
commit
080b265607
@ -55,6 +55,10 @@ dependencies {
|
||||
implementation("com.google.android.gms:play-services-location:21.0.1")
|
||||
implementation("androidx.compose.material:material-icons-extended:1.6.0")
|
||||
implementation(libs.androidx.compose.animation.core.lint)
|
||||
implementation(libs.androidx.compose.foundation)
|
||||
implementation(libs.androidx.ui)
|
||||
implementation(libs.androidx.ui.graphics)
|
||||
implementation(libs.androidx.compose.ui.text)
|
||||
|
||||
testImplementation(libs.junit)
|
||||
androidTestImplementation(libs.androidx.junit)
|
||||
@ -64,4 +68,13 @@ dependencies {
|
||||
debugImplementation(libs.androidx.compose.ui.tooling)
|
||||
debugImplementation(libs.androidx.compose.ui.test.manifest)
|
||||
|
||||
// CameraX (Pastikan Anda sudah punya ini)
|
||||
implementation("androidx.camera:camera-core:1.3.0")
|
||||
implementation("androidx.camera:camera-camera2:1.3.0")
|
||||
implementation("androidx.camera:camera-lifecycle:1.3.0")
|
||||
implementation("androidx.camera:camera-view:1.3.0")
|
||||
|
||||
// Google ML Kit Face Detection
|
||||
implementation("com.google.android.gms:play-services-mlkit-face-detection:17.1.0")
|
||||
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,36 @@
|
||||
package id.ac.ubharajaya.sistemakademik
|
||||
import androidx.camera.core.ExperimentalGetImage
|
||||
import androidx.camera.core.ImageAnalysis
|
||||
import androidx.camera.core.ImageProxy
|
||||
import com.google.mlkit.vision.common.InputImage
|
||||
import com.google.mlkit.vision.face.FaceDetection
|
||||
import com.google.mlkit.vision.face.FaceDetectorOptions
|
||||
|
||||
class WajahAnalyzer(private val onFaceDetected: (Boolean) -> Unit) : ImageAnalysis.Analyzer {
|
||||
|
||||
// Settingan deteksi cepat (Performance Mode)
|
||||
private val options = FaceDetectorOptions.Builder()
|
||||
.setPerformanceMode(FaceDetectorOptions.PERFORMANCE_MODE_FAST)
|
||||
.setContourMode(FaceDetectorOptions.CONTOUR_MODE_NONE)
|
||||
.build()
|
||||
|
||||
private val detector = FaceDetection.getClient(options)
|
||||
|
||||
@ExperimentalGetImage
|
||||
override fun analyze(imageProxy: ImageProxy) {
|
||||
val mediaImage = imageProxy.image
|
||||
if (mediaImage != null) {
|
||||
val image = InputImage.fromMediaImage(mediaImage, imageProxy.imageInfo.rotationDegrees)
|
||||
|
||||
detector.process(image)
|
||||
.addOnSuccessListener { faces ->
|
||||
// Callback: True jika ada wajah, False jika kosong
|
||||
onFaceDetected(faces.isNotEmpty())
|
||||
}
|
||||
.addOnFailureListener { onFaceDetected(false) }
|
||||
.addOnCompleteListener { imageProxy.close() } // Wajib tutup image
|
||||
} else {
|
||||
imageProxy.close()
|
||||
}
|
||||
}
|
||||
}
|
||||
981
backend/app.py
981
backend/app.py
File diff suppressed because it is too large
Load Diff
@ -6,3 +6,4 @@ PyJWT==2.8.0
|
||||
bcrypt==4.1.2
|
||||
python-dotenv==1.0.0
|
||||
requests==2.31.0
|
||||
Flask-APScheduler==1.13.1
|
||||
@ -9,6 +9,10 @@ lifecycleRuntimeKtx = "2.9.4"
|
||||
activityCompose = "1.11.0"
|
||||
composeBom = "2024.09.00"
|
||||
animationCoreLint = "1.10.0"
|
||||
foundation = "1.10.0"
|
||||
ui = "1.10.0"
|
||||
uiGraphics = "1.10.0"
|
||||
uiText = "1.10.0"
|
||||
|
||||
[libraries]
|
||||
androidx-core-ktx = { group = "androidx.core", name = "core-ktx", version.ref = "coreKtx" }
|
||||
@ -26,6 +30,10 @@ androidx-compose-ui-test-manifest = { group = "androidx.compose.ui", name = "ui-
|
||||
androidx-compose-ui-test-junit4 = { group = "androidx.compose.ui", name = "ui-test-junit4" }
|
||||
androidx-compose-material3 = { group = "androidx.compose.material3", name = "material3" }
|
||||
androidx-compose-animation-core-lint = { group = "androidx.compose.animation", name = "animation-core-lint", version.ref = "animationCoreLint" }
|
||||
androidx-compose-foundation = { group = "androidx.compose.foundation", name = "foundation", version.ref = "foundation" }
|
||||
androidx-ui = { group = "androidx.compose.ui", name = "ui", version.ref = "ui" }
|
||||
androidx-ui-graphics = { group = "androidx.compose.ui", name = "ui-graphics", version.ref = "uiGraphics" }
|
||||
androidx-compose-ui-text = { group = "androidx.compose.ui", name = "ui-text", version.ref = "uiText" }
|
||||
|
||||
[plugins]
|
||||
android-application = { id = "com.android.application", version.ref = "agp" }
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user