I’m fairly new to Kotlin, coming from Java. But to give some background information, I’m building an object detection application (in Kotlin , for Android). The application uses CameraX to build a camera preview and Google ML to provide machine learning expertise. Just for reference; I used this CameraX documentation and this this Google ML Kit documentation.
My issue today revolves around Step 4 of the Google ML documentation, which provides steps for both Kotlin and Java users. I’m currently attempting to print Log.d("TAG", "onSuccess" + it.size)
to my Android Studio console in order to determine if .addonSuccessListener
is actually running. If it does, it should print something along the lines of onSuccess1
. However, I’m not even entirely sure the following code is even running. Would anybody happen to know why?
objectDetector
.process(image)
.addOnSuccessListener {
Log.d("TAG", "onSuccess" + it.size) //I want this to print
for (detectedObject in it)
{
val boundingBox = detectedObject.boundingBox
val trackingId = detectedObject.trackingId
for (label in detectedObject.labels) {
val text = label.text
val index = label.index
val confidence = label.confidence
}
}
}
If more code from this class is required to resolve this problem, I’ve formatted it all into this Pastebin link. Any further information required to resolve this problem will be provided upon request.