Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
fcb312a
Initial mediapipe segmentation
Jan 12, 2025
772a10f
Add something that currently just blurs the whole image
Jan 12, 2025
5b582fa
Working portrait mode
Jan 12, 2025
d18a13f
Use a faster blurring algorithm & refactor to apply mask at blur time
Jan 13, 2025
cdc4085
Add coroutines lib
Jan 20, 2025
7cf8cc4
Run blurring in a coroutine
Jan 20, 2025
059cfab
Fix applying the mask when blurring
Jan 20, 2025
011f2d2
Add comment for mask blurring
Jan 20, 2025
50f0324
Add portrait mode setting
Jan 26, 2025
6c58f8e
Disable portrait mode when setting off
Jan 26, 2025
d26e1e2
Clean up the SegmenterHelper to remove stream specific code
Jan 26, 2025
780c7c9
Remove image segmenter listener
Jan 26, 2025
9e92755
Ensure rotation is correct on save
Jan 26, 2025
a1d598f
unused file
Jan 26, 2025
289799b
Fix linting errors
Jan 26, 2025
54c6cd3
Merge branch 'main' into portrait-mediapipe
Jan 26, 2025
2d4ac18
Fix build errors
Jan 26, 2025
a75f673
Use proper library management
Jan 27, 2025
98ac693
Add some proguard rules
Jan 27, 2025
196dc66
Remove more dead code
Jan 27, 2025
8391197
Use compatable coroutines version
Jan 27, 2025
a2e551f
Use actual latest mediapipe task version
Jan 27, 2025
59b8191
Another proguard rule
Jan 27, 2025
ca845fa
Use actual latest mediapipe task version
Feb 2, 2025
494e349
Remove ImageSegmenterHelper.kt
Feb 3, 2025
f7e4d8f
Remove specific portrait setting with aim of using photo modes instead
Feb 12, 2025
3b580aa
Add portrait photo mode and use in photo mode plugin
Feb 12, 2025
72d86c0
Remove imports
Feb 12, 2025
d7c3630
Move to a mode for toggling portrait
Feb 12, 2025
35179f4
Move back to CPU to make mediapipe work
Feb 12, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,10 @@ dependencies {

// ML Kit for Barcode/QR scanning
implementation(libs.barcode.scanning)

//Mediapipe for segmentation (portrait)
implementation(libs.tasks.vision)
implementation(libs.coroutines)
}


Expand Down
10 changes: 9 additions & 1 deletion app/proguard-rules.pro
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,12 @@

# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
#-renamesourcefileattribute SourceFile

-dontwarn javax.lang.model.element.Element*
-dontwarn javax.lang.model.element.ElementKind*
-dontwarn javax.lang.model.element.Modifier*
-dontwarn javax.lang.model.type.TypeMirror*
-dontwarn javax.lang.model.type.TypeVisitor*
-dontwarn javax.lang.model.util.SimpleTypeVisitor8*
-dontwarn javax.lang.model.SourceVersion*
Binary file added app/src/main/assets/selfie_segmenter.tflite
Binary file not shown.
34 changes: 24 additions & 10 deletions app/src/main/java/co/stonephone/stonecamera/StoneCameraApp.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,35 @@ package co.stonephone.stonecamera

import android.annotation.SuppressLint
import android.graphics.Rect
import android.util.Log
import androidx.annotation.OptIn
import androidx.camera.camera2.interop.ExperimentalCamera2Interop
import androidx.camera.lifecycle.ProcessCameraProvider
import androidx.compose.foundation.background
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.*
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.FlipCameraAndroid
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.WindowInsets
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.offset
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.systemBars
import androidx.compose.foundation.layout.width
import androidx.compose.foundation.layout.windowInsetsPadding
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.runtime.*
import androidx.compose.ui.*
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.text.font.FontWeight
Expand All @@ -33,13 +45,14 @@ import co.stonephone.stonecamera.plugins.FlashPlugin
import co.stonephone.stonecamera.plugins.FocusBasePlugin
import co.stonephone.stonecamera.plugins.PhotoModePlugin
import co.stonephone.stonecamera.plugins.PinchToZoomPlugin
import co.stonephone.stonecamera.plugins.PortraitModePlugin
import co.stonephone.stonecamera.plugins.QRScannerPlugin
import co.stonephone.stonecamera.plugins.SettingLocation
import co.stonephone.stonecamera.plugins.SettingsTrayPlugin
import co.stonephone.stonecamera.plugins.ShutterFlashPlugin
import co.stonephone.stonecamera.plugins.TapToFocusPlugin
import co.stonephone.stonecamera.plugins.VolumeControlsPlugin
import co.stonephone.stonecamera.plugins.VideoModePlugin
import co.stonephone.stonecamera.plugins.VolumeControlsPlugin
import co.stonephone.stonecamera.plugins.ZoomBarPlugin
import co.stonephone.stonecamera.plugins.ZoomBasePlugin
import co.stonephone.stonecamera.ui.RenderPluginSetting
Expand All @@ -62,6 +75,7 @@ val PLUGINS = listOf(
ShutterFlashPlugin(),
VolumeControlsPlugin(),
PhotoModePlugin(),
PortraitModePlugin(),
VideoModePlugin(),
SettingsTrayPlugin()
// DebugPlugin()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,23 @@ import android.net.Uri
import android.util.Log
import android.view.MotionEvent
import androidx.annotation.OptIn
import androidx.camera.core.*
import androidx.camera.core.Camera
import androidx.camera.core.CameraSelector
import androidx.camera.core.ExperimentalGetImage
import androidx.camera.core.ImageAnalysis
import androidx.camera.core.ImageCapture
import androidx.camera.core.Preview
import androidx.camera.lifecycle.ProcessCameraProvider
import androidx.camera.video.Quality
import androidx.camera.video.QualitySelector
import androidx.camera.video.Recorder
import androidx.camera.video.Recording
import androidx.camera.video.VideoCapture
import androidx.camera.view.PreviewView
import androidx.compose.runtime.*
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateMapOf
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.setValue
import androidx.compose.runtime.snapshots.SnapshotStateMap
import androidx.lifecycle.LifecycleOwner
import androidx.lifecycle.ViewModel
Expand Down Expand Up @@ -139,7 +147,6 @@ class StoneCameraViewModel(
recreateUseCases()
}


//--------------------------------------------------------------------------------
// Public methods to manipulate the above states
//--------------------------------------------------------------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ import androidx.compose.ui.unit.dp
import co.stonephone.stonecamera.StoneCameraViewModel
import co.stonephone.stonecamera.ui.ResponsiveOrientation

class PhotoModePlugin : IPlugin {
open class PhotoModePlugin : IPlugin {
override val id: String = "photoMode"
override val name: String = "Photo Mode"

private lateinit var viewModel: StoneCameraViewModel
protected lateinit var viewModel: StoneCameraViewModel

// Should Analysis be added by QRScanner instead? Probably doesn't matter for now
override val modeUseCases: List<PluginUseCase>
Expand Down
Loading
Loading