Skip to content

Commit

Permalink
#11 SleepAnalyzer 생성, DetectionView에 설정 but 클래스 오류남
Browse files Browse the repository at this point in the history
  • Loading branch information
comye1 committed Feb 27, 2022
1 parent b26d795 commit b6daff4
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 3 deletions.
9 changes: 9 additions & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ android {
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
aaptOptions {
noCompress = "tflite"
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
Expand All @@ -38,6 +41,7 @@ android {
}
buildFeatures {
compose true
mlModelBinding true
}
composeOptions {
kotlinCompilerExtensionVersion compose_version
Expand All @@ -52,6 +56,8 @@ android {

dependencies {

implementation 'org.tensorflow:tensorflow-lite-support:0.1.0'
implementation 'org.tensorflow:tensorflow-lite-metadata:0.1.0'
def nav_version = "2.4.1"

implementation 'androidx.core:core-ktx:1.7.0'
Expand Down Expand Up @@ -117,4 +123,7 @@ dependencies {

// Easy Permissions
implementation 'pub.devrel:easypermissions:3.0.0'

// tensorflow lite
implementation 'org.tensorflow:tensorflow-lite:+'
}
20 changes: 17 additions & 3 deletions app/src/main/java/com/comye1/dontsleepdriver/main/CameraView.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package com.comye1.dontsleepdriver.main

import android.annotation.SuppressLint
import android.content.Context
import android.util.Log
import androidx.camera.core.CameraSelector
import androidx.camera.core.ImageAnalysis
import androidx.camera.core.Preview
Expand All @@ -18,6 +20,7 @@ import androidx.compose.ui.unit.dp
import androidx.compose.ui.viewinterop.AndroidView
import androidx.core.content.ContextCompat
import androidx.lifecycle.LifecycleOwner
import com.comye1.dontsleepdriver.analyzer.SleepAnalyzer
import java.util.concurrent.Executors

@Composable
Expand All @@ -44,6 +47,7 @@ fun CameraView() {
}
}

@SuppressLint("UnsafeOptInUsageError")
@Composable
fun DetectionView(
context: Context,
Expand All @@ -65,11 +69,21 @@ fun DetectionView(
factory = { ctx ->
val previewView = PreviewView(ctx)
cameraProviderFuture.addListener({

val cameraProvider: ProcessCameraProvider = cameraProviderFuture.get()

// preview = ImageAnalysis.Builder()
// .setTargetResolution(Size(224, 224))

val analyzer = SleepAnalyzer(context)

Log.d("SleepAnalyzer", analyzer.toString())

val imageAnalysis = ImageAnalysis.Builder()
// .setBackpressureStrategy(ImageAnalysis.STRATEGY_KEEP_ONLY_LATEST)
.setBackpressureStrategy(ImageAnalysis.STRATEGY_KEEP_ONLY_LATEST)
.build()
.apply {
// setAnalyzer(cameraExecutor, ObjectDetectorImageAnalyzer(textRecognizer, extractedText))
.also { imageAnalysis ->
imageAnalysis.setAnalyzer(executor, analyzer)
}
val cameraSelector = CameraSelector.Builder()
.requireLensFacing(CameraSelector.LENS_FACING_BACK)
Expand Down
Binary file added app/src/main/ml/SLeepModel1.tflite
Binary file not shown.
Binary file added app/src/main/ml/SleepModel.tflite
Binary file not shown.

0 comments on commit b6daff4

Please sign in to comment.