Skip to content

Commit 5928551

Browse files
updated the latest version and changed the code for Interactive seg
2 parents 1aa9984 + 060cd3d commit 5928551

File tree

2 files changed

+8
-3
lines changed
  • examples/interactive_segmentation/android/app

2 files changed

+8
-3
lines changed

examples/interactive_segmentation/android/app/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ dependencies {
6464
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
6565

6666
// MediaPipe Library
67-
implementation 'com.google.mediapipe:tasks-vision:0.10.29'
67+
implementation 'com.google.mediapipe:tasks-vision:0.10.33'
6868

6969
testImplementation 'junit:junit:4.13.2'
7070
androidTestImplementation 'androidx.test.ext:junit:1.1.5'

examples/interactive_segmentation/android/app/src/main/java/com/mediapipe/example/interactivesegmentation/OverlayView.kt

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ class OverlayView(context: Context?, attrs: AttributeSet?) :
2929
View(context, attrs) {
3030
private var maskBitmap: Bitmap? = null
3131
private var selectedPoint: Pair<Float, Float>? = null
32-
private var overlayColor: String = "#8012B5CB"
32+
private var overlayColor: String = "#8012B5CB" // Semi-transparent cyan
3333
private var selectionMarkerColor: String = "#FBBC04"
3434
private var selectionMarkerBorderColor: String = "#000000"
3535
private val selectPaint = Paint().apply {
@@ -56,9 +56,13 @@ class OverlayView(context: Context?, attrs: AttributeSet?) :
5656
*/
5757
fun setMaskResult(byteBuffer: ByteBuffer, maskWidth: Int, maskHeight: Int) {
5858
val pixels = IntArray(byteBuffer.capacity())
59+
val parsedOverlayColor = Color.parseColor(overlayColor) // Parse color once
60+
5961
for (i in pixels.indices) {
6062
val index = byteBuffer.get(i).toInt()
61-
val color = if (index == 0) Color.TRANSPARENT else Color.parseColor(overlayColor)
63+
// If index is 0, color it. Otherwise, make it transparent.
64+
// Index 0 typically represents the primary or first detected item in the results.
65+
val color = if (index == 0) parsedOverlayColor else Color.TRANSPARENT
6266
pixels[i] = color
6367
}
6468

@@ -91,3 +95,4 @@ class OverlayView(context: Context?, attrs: AttributeSet?) :
9195
invalidate()
9296
}
9397
}
98+

0 commit comments

Comments
 (0)