Skip to content

Commit 35179f4

Browse files
author
izaak
committed
Move back to CPU to make mediapipe work
1 parent d7c3630 commit 35179f4

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

app/src/main/java/co/stonephone/stonecamera/plugins/PhotoMode.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ open class PhotoModePlugin : IPlugin {
2727
override val id: String = "photoMode"
2828
override val name: String = "Photo Mode"
2929

30-
private lateinit var viewModel: StoneCameraViewModel
30+
protected lateinit var viewModel: StoneCameraViewModel
3131

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

app/src/main/java/co/stonephone/stonecamera/plugins/PortraitMode.kt

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,13 @@ class PortraitModePlugin : PhotoModePlugin() {
3434
get() = "portrait"
3535

3636
private var imageSegmenter: ImageSegmenter? = null
37-
private lateinit var viewModel: StoneCameraViewModel
3837

3938
init {
4039
setupImageSegmenter()
4140
}
4241

4342
override fun initialize(viewModel: StoneCameraViewModel) {
43+
super.initialize(viewModel)
4444
setupImageSegmenter()
4545
}
4646

@@ -50,7 +50,7 @@ class PortraitModePlugin : PhotoModePlugin() {
5050
) {
5151

5252
//TODO: This kind of check should probably be built into the plugin interface, something reusable
53-
if (viewModel.selectedMode == modeLabel) {
53+
if (viewModel.selectedMode != modeLabel) {
5454
return
5555
}
5656

@@ -269,7 +269,9 @@ class PortraitModePlugin : PhotoModePlugin() {
269269

270270
private fun setupImageSegmenter() {
271271
val baseOptionsBuilder = BaseOptions.builder()
272-
baseOptionsBuilder.setDelegate(Delegate.GPU)
272+
//TODO fix error when using gpu mode
273+
// Error occurs when getting MediaPipe task result. com.google.mediapipe.framework.MediaPipeException: invalid argument: Expected buffer size 31961088 got: 7990272, width 3264, height 2448, channels 1
274+
baseOptionsBuilder.setDelegate(Delegate.CPU)
273275
baseOptionsBuilder.setModelAssetPath("selfie_segmenter.tflite")
274276

275277
try {
@@ -278,7 +280,7 @@ class PortraitModePlugin : PhotoModePlugin() {
278280
.setRunningMode(RunningMode.IMAGE)
279281
.setBaseOptions(baseOptions)
280282
.setOutputCategoryMask(true)
281-
.setOutputConfidenceMasks(true)
283+
.setOutputConfidenceMasks(false)
282284

283285
val options = optionsBuilder.build()
284286
imageSegmenter = ImageSegmenter.createFromOptions(MyApplication.getAppContext(), options)

0 commit comments

Comments
 (0)