Welcome back.
We finished this composable function box with detection overlay.
Now let's create another package.
Name it as helper.
And this package contains a new Kotlin file.
Name it as object detector helper.
It's of type class taking into its constructor private file, context object and private val listener.
It's of type detection listener.
The interface that we created before Alt+ enter to import the context.
And let's start defining the variables interpreter from TensorFlow library.
Define it as null empty list private var.
The input width and input height are zero.
The interpreter is the TensorFlow.
Lite object that loads and runs the Tflite model to make predictions.
So we're going to use it to load this model that we've added before to our application.
And here we are telling that this interpreter, it can hold either an actual interpreter object or a
null.
When you net, you are not initializing it or after being closed.
Okay, so interpreter can be null or holding an object of type interpreter labels equals to string a
list which holds all labels.
Okay.
In each block let me call the set up interpreter.
This is the function that we're going to create here.
So private function set up interpreter.
And here we're going to load the model.
As we learned before we need to use try and catch to load the models and handle any possible possibility
of errors.
And try here start with loading the model var model equals to Do file util dot load mapped file.
This function has two parameters the context and the file path.
The context is context, and the file path is the name of the model.
What's the name of the model?
It's called HDD underscore AirPods underscore model.
So make sure that you type it well HDD AirPods model make sure that it matches correctly.
The name of the file hdd_airpods_model.tf Lite okay.
And it's highlighted by green.
And it's um like referenced here and detected.
So everything is working fine.
Then we need to use the interpreter to pass the model to it's buffer byte buffer okay.
So the first step is loading the memory the model from the assets into memory.