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
interface DirectionProvider { | |
fun start() | |
fun stop() | |
fun destroy() | |
} | |
internal class HuaweiVoiceProvider( | |
private val context: Context, | |
private val voiceDirectionExtractor: VoiceDirectionExtractor, | |
private val onDirectionListener: (direction: Direction) -> Unit, |
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
@Composable | |
fun SimpleCameraPreview() { | |
val lifecycleOwner = LocalLifecycleOwner.current | |
val context = LocalContext.current | |
val cameraProviderFuture = remember { ProcessCameraProvider.getInstance(context) } | |
AndroidView( | |
factory = { ctx -> | |
val previewView = PreviewView(ctx) | |
val executor = ContextCompat.getMainExecutor(ctx) |
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 imageAnalysis = ImageAnalysis.Builder() | |
.setBackpressureStrategy(ImageAnalysis.STRATEGY_KEEP_ONLY_LATEST) | |
.build() | |
.apply { | |
setAnalyzer(executor,analyzer) | |
} | |
cameraProvider.bindToLifecycle( | |
lifecycleOwner, | |
cameraSelector, |
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 GestureAnalyzer(private val onGestureDetected: (Int) -> Unit) : ImageAnalysis.Analyzer { | |
private val analyzer = MLGestureAnalyzerFactory | |
.getInstance().gestureAnalyzer | |
private var inprogress = false | |
@SuppressLint("UnsafeExperimentalUsageError") | |
override fun analyze(imageProxy: ImageProxy) { | |
if (inprogress) { |
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 capture() { | |
// Create output file to hold the image | |
val photoFile = createFile(outputFolder, FILENAME, PHOTO_EXTENSION) | |
// Create output options object which contains file + metadata | |
val outputOptions = ImageCapture.OutputFileOptions.Builder(photoFile) | |
.build() | |
imageCapture.takePicture(outputOptions, Executors.newSingleThreadExecutor(), | |
object : ImageCapture.OnImageSavedCallback { |
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 TextAnalyzer(private val onTextDetected: (MLText) -> Unit) : ImageAnalysis.Analyzer { | |
private val setting = MLLocalTextSetting.Factory() | |
.setOCRMode(MLLocalTextSetting.OCR_TRACKING_MODE) | |
.setLanguage("en") | |
.create() | |
private val analyzer = MLAnalyzerFactory.getInstance().getLocalTextAnalyzer(setting) | |
@SuppressLint("UnsafeOptInUsageError") | |
override fun analyze(imageProxy: ImageProxy) { |
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"?> | |
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" | |
xmlns:app="http://schemas.android.com/apk/res-auto" | |
android:id="@+id/container" | |
android:layout_width="match_parent" | |
android:layout_height="match_parent" | |
android:paddingTop="?attr/actionBarSize"> | |
<com.google.android.material.bottomnavigation.BottomNavigationView | |
android:id="@+id/nav_view" |