a scrappy gimbal that insults you in shakespearean english
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

skeleton for moving left & right

+52 -2
+3
mobile/composeApp/src/androidMain/kotlin/com/paytondeveloper/myrus_mobile/MLFace.android.kt
··· 27 import com.google.mlkit.vision.face.FaceDetector 28 import com.google.mlkit.vision.face.FaceDetectorOptions 29 import com.google.mlkit.vision.face.FaceDetectorOptions.LandmarkMode 30 import com.kashif.cameraK.builder.CameraControllerBuilder 31 import com.kashif.cameraK.controller.CameraController 32 import com.kashif.cameraK.enums.Directory ··· 52 // val img = InputImage.fromByteArray(img, options.outWidth, options.outHeight, rotationDegrees, InputImage.IMAGE_FORMAT_NV21) 53 val bitmap = BitmapFactory.decodeByteArray(img, 0, img.size) 54 val img = InputImage.fromBitmap(bitmap, 0) 55 val detector = FaceDetection.getClient() 56 if (AppInfo.canDetectFace) { 57 AppInfo.canDetectFace = false
··· 27 import com.google.mlkit.vision.face.FaceDetector 28 import com.google.mlkit.vision.face.FaceDetectorOptions 29 import com.google.mlkit.vision.face.FaceDetectorOptions.LandmarkMode 30 + import com.google.mlkit.vision.face.FaceDetectorOptions.PERFORMANCE_MODE_ACCURATE 31 import com.kashif.cameraK.builder.CameraControllerBuilder 32 import com.kashif.cameraK.controller.CameraController 33 import com.kashif.cameraK.enums.Directory ··· 53 // val img = InputImage.fromByteArray(img, options.outWidth, options.outHeight, rotationDegrees, InputImage.IMAGE_FORMAT_NV21) 54 val bitmap = BitmapFactory.decodeByteArray(img, 0, img.size) 55 val img = InputImage.fromBitmap(bitmap, 0) 56 + val options = FaceDetectorOptions.Builder() 57 + options.setPerformanceMode(PERFORMANCE_MODE_ACCURATE) 58 val detector = FaceDetection.getClient() 59 if (AppInfo.canDetectFace) { 60 AppInfo.canDetectFace = false
+49 -2
mobile/composeApp/src/commonMain/kotlin/com/paytondeveloper/myrus_mobile/App.kt
··· 16 import androidx.compose.ui.Alignment 17 import androidx.compose.ui.Modifier 18 import androidx.compose.ui.draw.drawWithCache 19 import androidx.compose.ui.geometry.Offset 20 import androidx.compose.ui.graphics.Color 21 import androidx.compose.ui.graphics.RectangleShape 22 import androidx.compose.ui.layout.onSizeChanged 23 import androidx.compose.ui.platform.LocalDensity 24 import androidx.compose.ui.platform.LocalViewConfiguration 25 import androidx.compose.ui.unit.dp 26 import androidx.graphics.shapes.RoundedPolygon 27 import com.kashif.cameraK.builder.CameraControllerBuilder ··· 54 data class Rect(val top: Float, val left: Float, val bottom: Float, val right: Float) 55 data class FaceData(val boundingBox: Rect) 56 57 expect suspend fun sayText(text: String) 58 59 val genAI = GenerativeModel( ··· 63 64 expect fun epochMillis(): Long 65 66 67 @Composable 68 @Preview ··· 86 var currentThingy by remember { mutableStateOf<Rect?>(Rect(0f,0f,0f,0f)) } 87 var delayMillis by remember { mutableStateOf(1000) } 88 var analyzing by remember { mutableStateOf(true) } 89 val tts = rememberTextToSpeechOrNull(TextToSpeechEngine.Google) 90 LaunchedEffect(Unit) { 91 //not proud of this. 92 suspend fun roast(image: ByteArray) { ··· 123 124 currentThingy = bounds.copy(top = newY, left = newX) 125 analyzing = false 126 - CoroutineScope(Dispatchers.IO).launch { 127 - roast(it.byteArray) 128 } 129 }) 130 131 } ··· 145 val leftPx = with(LocalDensity.current) { 146 currentThingy!!.left.toDp() 147 } 148 println("offset (dp) ${topPx} ${leftPx}") 149 150 CameraPreview(modifier = Modifier.fillMaxSize().onSizeChanged { ··· 164 } 165 }) 166 Text("Face", modifier = Modifier.offset(x = leftPx, y = topPx)) 167 } 168 Slider(modifier = Modifier.padding(top = 64.dp), value = delayMillis.toFloat(), onValueChange = { 169 delayMillis = it.toInt()
··· 16 import androidx.compose.ui.Alignment 17 import androidx.compose.ui.Modifier 18 import androidx.compose.ui.draw.drawWithCache 19 + import androidx.compose.ui.draw.scale 20 import androidx.compose.ui.geometry.Offset 21 import androidx.compose.ui.graphics.Color 22 import androidx.compose.ui.graphics.RectangleShape 23 import androidx.compose.ui.layout.onSizeChanged 24 import androidx.compose.ui.platform.LocalDensity 25 import androidx.compose.ui.platform.LocalViewConfiguration 26 + import androidx.compose.ui.text.font.FontWeight 27 import androidx.compose.ui.unit.dp 28 import androidx.graphics.shapes.RoundedPolygon 29 import com.kashif.cameraK.builder.CameraControllerBuilder ··· 56 data class Rect(val top: Float, val left: Float, val bottom: Float, val right: Float) 57 data class FaceData(val boundingBox: Rect) 58 59 + fun Rect.origin(): Size { 60 + val midpointX = (this.left + this.right) / 2 61 + val midpointY = (this.top + this.bottom) / 2 62 + return Size(width = midpointX, height = midpointY) 63 + } 64 + 65 expect suspend fun sayText(text: String) 66 67 val genAI = GenerativeModel( ··· 71 72 expect fun epochMillis(): Long 73 74 + enum class MovingDirection { 75 + RIGHT, LEFT 76 + } 77 78 @Composable 79 @Preview ··· 97 var currentThingy by remember { mutableStateOf<Rect?>(Rect(0f,0f,0f,0f)) } 98 var delayMillis by remember { mutableStateOf(1000) } 99 var analyzing by remember { mutableStateOf(true) } 100 + var moving by remember { mutableStateOf(false) } 101 val tts = rememberTextToSpeechOrNull(TextToSpeechEngine.Google) 102 + val movingDirection = remember { mutableStateOf<MovingDirection?>(null) } 103 LaunchedEffect(Unit) { 104 //not proud of this. 105 suspend fun roast(image: ByteArray) { ··· 136 137 currentThingy = bounds.copy(top = newY, left = newX) 138 analyzing = false 139 + val leftCenter = bounds.right - bounds.left 140 + println("BOUNDS: ${bounds.origin().width} SIZE: ${size.width}") 141 + val midpointX = bounds.origin().width 142 + if (midpointX < ((size.width / 2) - (size.width / 12))) { 143 + //move left 144 + println("move left") 145 + movingDirection.value = MovingDirection.LEFT 146 + analyzing = true 147 + } else if (midpointX > ((size.width / 2) + (size.width / 12))) { 148 + //move right 149 + println("move right") 150 + analyzing = true 151 + movingDirection.value = MovingDirection.RIGHT 152 + } else { 153 + movingDirection.value = null 154 + //centered 155 + CoroutineScope(Dispatchers.IO).launch { 156 + roast(it.byteArray) 157 + } 158 } 159 + 160 }) 161 162 } ··· 176 val leftPx = with(LocalDensity.current) { 177 currentThingy!!.left.toDp() 178 } 179 + val camSizePx = with(LocalDensity.current) { 180 + camSize?.width?.toDp() ?: 0.dp 181 + } 182 println("offset (dp) ${topPx} ${leftPx}") 183 184 CameraPreview(modifier = Modifier.fillMaxSize().onSizeChanged { ··· 198 } 199 }) 200 Text("Face", modifier = Modifier.offset(x = leftPx, y = topPx)) 201 + // when (movingDirection) { 202 + // null -> {} 203 + // MovingDirection.RIGHT { 204 + // Text(">", fontWeight = FontWeight.Black, color = Color.White) 205 + // } 206 + // } 207 + if (movingDirection.value != null) { 208 + if (movingDirection.value == MovingDirection.RIGHT) { 209 + Text(">", fontWeight = FontWeight.Black, color = Color.White, modifier = Modifier.padding(top = 128.dp, start = camSizePx - 64.dp).scale(20f)) 210 + } else { 211 + Text("<", fontWeight = FontWeight.Black, color = Color.White, modifier = Modifier.padding(top = 128.dp, start = 32.dp).scale(20f)) 212 + } 213 + } 214 } 215 Slider(modifier = Modifier.padding(top = 64.dp), value = delayMillis.toFloat(), onValueChange = { 216 delayMillis = it.toInt()