We finished the screens, package drop boxes, camera preview and camera permission wrapper.
Now let's create another package.
Name it as detector.
Inside this package, create a new Kotlin class.
Name it as Object detector.
This class takes into the constructor for variables in the interpreter.
Private val labels.
It's of type list of strings, input size or the result view size, which is of type size, and the
private val listener which is a lambda expression.
Taking detections as a parameter.
List of detection object returning unit Alt+.
Enter to import the size from Android util class.
And here we go.
This class.
The object detector extends from image analysis dot analyzer.
The image analyzer or the image analysis dot analyzer is an interface from Camerax library that processes
camera frames from computer vision tasks like object detection.
This interface has one mandatory function Alt+ enter to implement the member called analyze.
So let's implement it.
And here we go.
Before we continue with this analyze function, let's create a companion object containing some very
important variables.
Private constant val image size equals to 300 which is the SSD.
SSD mobile net expects 300 by 300 input.
Okay this is very important back guys to here we set that the model the SSD MobileNet version one takes
an object an image size with 300 height and 300 width.
Okay.
So this is the input of the SSD MobileNet model.
Private constant val.
Maximum detection number equals to ten.
Set the maximum detections to ten and the private constant val.
Default.
Maximum result.
Default equals to four.
Please pay attention to this.
This is very important because if you, um if you modify this number without taking into consideration
the input, the real input of the model, it will give you an error.
Okay.
Later on in the next videos, we're gonna talk about it.
When we import the model that we we get it that Tflite model.
And we're going to study the input and output shape of this model.
Private image rotation degrees.
It's of type integer equals to zero.
Private val background scoop equals to coroutine.
Scoop dispatchers dot default private var params equals to detection parameters.
We need those variables.
The image rotation degrees.
Set it to zero.
We're going to use it later on.
The background scoop.
We're going to work with a coroutine scoop and the default dispatcher.
We need to do uh some background stuff for detection and params is a an instance of the detection parameter.
Parameters that we created before.
And we set the score threshold to 0.6.
That means every other object that it is detected and has a score above 60% and inference 60%, and
score 60%.
Go and display it.
Okay, so for that we created this params object.
Okay then let's continue with the other variables and we're going in the next video to study the SSD
mobile net output structure.