WEBVTT

00:00.080 --> 00:09.640
When the response is success, we loaded the file, the model correctly and we returned a list of detected

00:09.640 --> 00:10.480
objects.

00:10.480 --> 00:12.400
We need to display them.

00:12.680 --> 00:21.480
So here I want from you to understand that we are going to draw boxes and use the composables that we

00:21.520 --> 00:22.760
created before.

00:22.880 --> 00:26.640
For this purpose, start with box with constraints.

00:26.640 --> 00:39.480
This is the composable in in Kotlin modifier dot fill or modifier equals to modifier dot fill maximum

00:39.480 --> 00:53.320
size inside it create val box constraint equals to this val density equals to local density dot current

00:53.320 --> 00:59.000
val Lys width equals to with density.

00:59.270 --> 01:08.070
Set the box constraint dot maximum width dot two pixel size height equals to.

01:08.110 --> 01:08.750
With.

01:08.990 --> 01:10.950
Similar to what we've done before.

01:11.270 --> 01:15.230
Box constraint dot maximum height to pixels.

01:15.230 --> 01:18.870
Here we are creating the dimensions for the box.

01:19.030 --> 01:29.630
Now let me call the camera preview composable function that we created before, and pass the image analysis

01:29.750 --> 01:35.870
as a parameter and set the image analysis dot set analyzer.

01:36.110 --> 01:38.470
We need to pass two parameters.

01:38.470 --> 01:46.950
If you remember from the camera preview go up we have the modifier and the image analysis.

01:46.950 --> 01:48.990
Those are for the camera preview.

01:48.990 --> 01:54.070
And if we scroll down we need the image analyzer.

01:54.190 --> 02:00.500
So um go up see the image analysis and its returning type unit.

02:00.500 --> 02:03.660
This lambda expression would be called here.

02:03.660 --> 02:07.780
So set image analysis dot set analyzer.

02:07.900 --> 02:13.020
Set the context compat dot get main executor.

02:13.420 --> 02:20.500
Pass the context and the second parameter is ViewModel dot build analyzer.

02:20.700 --> 02:25.860
Size, width and size height variables that we created before.

02:25.980 --> 02:27.700
Let me explain.

02:27.700 --> 02:33.100
Here we have the camera preview and we have two parameters.

02:33.380 --> 02:36.860
That modifier can be passed and can't be passed.

02:36.860 --> 02:40.060
So it's optional because we initialize it by this.

02:40.260 --> 02:43.660
And the second parameter is on image analysis.

02:44.060 --> 02:52.020
On image analysis is a lambda expression that takes an image analysis as a parameter and returns unit.

02:52.020 --> 02:53.980
This is what I created.

02:54.020 --> 02:59.580
It's the parameter image analysis and returns null and returns unit.

02:59.620 --> 03:07.940
Here I just I just creating and setting the image analysis and setting the analyzer to those the context

03:07.980 --> 03:16.380
the compat the context compat get main executor I am passing the executor and the analyzer.

03:16.580 --> 03:21.380
If we go back to the view model we have the analyzer.

03:21.380 --> 03:27.020
So go up or scroll down to the build analyzer function.

03:27.020 --> 03:34.980
So here we are calling the ViewModel dot build analyzer function that we created previously.

03:35.100 --> 03:41.380
Okay so again guys this build analyzer returns an object detector.

03:41.380 --> 03:49.980
And as I told you we have this, um, this, uh, creation for the object detector class that we created

03:49.980 --> 03:50.460
before.

03:50.580 --> 03:57.850
And we pass the size width and size height as parameters for this build analyzer function.

03:57.890 --> 04:02.410
The last screen we need to make use of it is drill boxes.

04:02.410 --> 04:03.770
You see it's in gray.

04:03.810 --> 04:06.130
We didn't use it before.

04:06.330 --> 04:13.010
So under this camera preview go and create a drill boxes.

04:13.290 --> 04:17.690
Set the paint to paint objects that we created before.

04:17.970 --> 04:22.530
Path colors the path colors list that we created before.

04:22.770 --> 04:23.250
Up.

04:23.290 --> 04:26.410
You see guys here the colors.

04:26.810 --> 04:30.250
Remember green, cyan, red and others.

04:30.250 --> 04:32.770
If we go to drill boxes, we don't.

04:32.810 --> 04:34.810
We can specify the modifier.

04:34.850 --> 04:35.810
It's optional.

04:35.810 --> 04:41.010
We need to specify the paint path color and detection list object.

04:41.010 --> 04:44.370
So here remove those parameters.

04:44.530 --> 04:53.440
Detection list object view model dot detection list dot value Okay.

04:53.600 --> 05:03.800
You see, guys, how we get the latest detected objects, the latest updated list of the detected objects

05:03.800 --> 05:07.160
from the ViewModel detection list.

05:07.200 --> 05:10.160
Okay, so back to the detection ViewModel.

05:10.280 --> 05:17.120
You see guys here, the object detector and the detection list.

05:17.160 --> 05:32.160
We are using the ViewModel, the LiveData to update the screen and try to get the latest updated models

05:32.400 --> 05:34.640
and the objects detected.

05:34.680 --> 05:45.280
Okay, so this is the detection screen that uses and that link the UI with the view model.
