You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi all, I'm looking into using the new OverlayEffect class in my app to draw bounding boxes and labels of objects recognized by ML Kit's implementation of ImageAnalysis.Analyzer (i.e. MlKitAnalyzer).
I'm currently trying to keep things as simple as possible - I'm using CameraController - but I don't understand how I should hook up an OverlayEffect to it. An example would be really helpful, but I currently cannot find any in the camera-samples repository.
For instance, how would you render bounding boxes in an app using ML Kit's default Object Recognition model? Here's a small sample app where you could (hopefully) add an OverlayEffect.
classMainActivity : AppCompatActivity() {
overridefunonCreate(savedInstanceState:Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
val previewView = findViewById<PreviewView>(R.id.previewView)
val cameraController =LifecycleCameraController(baseContext)
cameraController.bindToLifecycle(this)
cameraController.cameraSelector =CameraSelector.DEFAULT_BACK_CAMERA
previewView.controller = cameraController
val objectDetector =ObjectDetection.getClient(
ObjectDetectorOptions.Builder()
.setDetectorMode(ObjectDetectorOptions.STREAM_MODE)
.enableClassification()
.build()
)
cameraController.setImageAnalysisAnalyzer(
ContextCompat.getMainExecutor(this),
MlKitAnalyzer(
listOf(objectDetector),
CameraController.COORDINATE_SYSTEM_VIEW_REFERENCED,
ContextCompat.getMainExecutor(this)
)
{ result:MlKitAnalyzer.Result?->if (result !=null) {
val values = result.getValue(objectDetector)
if (values !=null) {
for (value in values) {
TODO("Render bounding box with OverlayEffect")
println(value.boundingBox.flattenToString())
}
}
}
}
)
}
}
Thanks!
The text was updated successfully, but these errors were encountered:
Hi, I saw the introduction of the new COORDINATE_SYSTEM_SENSOR option which, according to the commit which introduced it (by @xizhang), should be useful to make use of the new OverlayEffect API. Still, no sample code is present in the repository. Where can we find some helpful example showing how to make use of this efficient API together with an ImageAnalyzer like ML Kit or MediaPipe?
Hi all, I'm looking into using the new
OverlayEffect
class in my app to draw bounding boxes and labels of objects recognized by ML Kit's implementation ofImageAnalysis.Analyzer
(i.e.MlKitAnalyzer
).I'm currently trying to keep things as simple as possible - I'm using
CameraController
- but I don't understand how I should hook up anOverlayEffect
to it. An example would be really helpful, but I currently cannot find any in the camera-samples repository.For instance, how would you render bounding boxes in an app using ML Kit's default Object Recognition model? Here's a small sample app where you could (hopefully) add an
OverlayEffect
.Thanks!
The text was updated successfully, but these errors were encountered: