WEBVTT

00:00.080 --> 00:06.840
We finished the screens, package drop boxes, camera preview and camera permission wrapper.

00:07.040 --> 00:09.880
Now let's create another package.

00:10.000 --> 00:11.760
Name it as detector.

00:11.760 --> 00:15.600
Inside this package, create a new Kotlin class.

00:15.840 --> 00:18.600
Name it as Object detector.

00:18.840 --> 00:25.040
This class takes into the constructor for variables in the interpreter.

00:25.160 --> 00:27.040
Private val labels.

00:27.040 --> 00:35.040
It's of type list of strings, input size or the result view size, which is of type size, and the

00:35.040 --> 00:40.880
private val listener which is a lambda expression.

00:40.920 --> 00:43.600
Taking detections as a parameter.

00:44.240 --> 00:50.040
List of detection object returning unit Alt+.

00:50.040 --> 00:54.880
Enter to import the size from Android util class.

00:54.880 --> 00:55.960
And here we go.

00:56.080 --> 00:57.320
This class.

00:57.480 --> 01:04.000
The object detector extends from image analysis dot analyzer.

01:04.160 --> 01:15.660
The image analyzer or the image analysis dot analyzer is an interface from Camerax library that processes

01:15.660 --> 01:20.820
camera frames from computer vision tasks like object detection.

01:20.860 --> 01:29.900
This interface has one mandatory function Alt+ enter to implement the member called analyze.

01:30.180 --> 01:31.820
So let's implement it.

01:32.060 --> 01:33.220
And here we go.

01:33.260 --> 01:42.340
Before we continue with this analyze function, let's create a companion object containing some very

01:42.340 --> 01:44.260
important variables.

01:44.300 --> 01:53.340
Private constant val image size equals to 300 which is the SSD.

01:53.620 --> 02:00.540
SSD mobile net expects 300 by 300 input.

02:00.580 --> 02:09.740
Okay this is very important back guys to here we set that the model the SSD MobileNet version one takes

02:09.780 --> 02:15.980
an object an image size with 300 height and 300 width.

02:16.020 --> 02:16.420
Okay.

02:16.460 --> 02:20.220
So this is the input of the SSD MobileNet model.

02:20.280 --> 02:22.800
Private constant val.

02:22.840 --> 02:27.800
Maximum detection number equals to ten.

02:27.840 --> 02:32.440
Set the maximum detections to ten and the private constant val.

02:32.640 --> 02:33.560
Default.

02:33.560 --> 02:35.560
Maximum result.

02:35.560 --> 02:38.200
Default equals to four.

02:38.240 --> 02:40.400
Please pay attention to this.

02:40.440 --> 02:49.120
This is very important because if you, um if you modify this number without taking into consideration

02:49.120 --> 02:54.840
the input, the real input of the model, it will give you an error.

02:54.880 --> 02:55.360
Okay.

02:55.600 --> 02:58.840
Later on in the next videos, we're gonna talk about it.

02:58.840 --> 03:04.200
When we import the model that we we get it that Tflite model.

03:04.200 --> 03:09.240
And we're going to study the input and output shape of this model.

03:09.280 --> 03:13.760
Private image rotation degrees.

03:13.880 --> 03:16.920
It's of type integer equals to zero.

03:16.960 --> 03:23.120
Private val background scoop equals to coroutine.

03:23.120 --> 03:33.100
Scoop dispatchers dot default private var params equals to detection parameters.

03:33.260 --> 03:35.380
We need those variables.

03:35.620 --> 03:37.620
The image rotation degrees.

03:37.980 --> 03:39.060
Set it to zero.

03:39.300 --> 03:41.060
We're going to use it later on.

03:41.100 --> 03:42.220
The background scoop.

03:42.220 --> 03:47.340
We're going to work with a coroutine scoop and the default dispatcher.

03:47.620 --> 03:57.100
We need to do uh some background stuff for detection and params is a an instance of the detection parameter.

03:57.140 --> 04:00.340
Parameters that we created before.

04:00.380 --> 04:04.340
And we set the score threshold to 0.6.

04:04.540 --> 04:15.940
That means every other object that it is detected and has a score above 60% and inference 60%, and

04:16.500 --> 04:18.180
score 60%.

04:18.220 --> 04:19.500
Go and display it.

04:19.540 --> 04:24.500
Okay, so for that we created this params object.

04:24.540 --> 04:33.500
Okay then let's continue with the other variables and we're going in the next video to study the SSD

04:33.780 --> 04:37.940
mobile net output structure.
