WEBVTT

00:00.520 --> 00:01.520
Welcome back.

00:01.800 --> 00:03.360
We have two functions.

00:03.520 --> 00:06.840
Parse image for model and parse detection results.

00:06.840 --> 00:08.200
We need to create them.

00:08.320 --> 00:12.520
So here create a new function private function.

00:12.520 --> 00:17.520
Prepare image for model parsing image proxy as a parameter.

00:17.520 --> 00:23.920
And the returning type is tensor image alt plus enter to import this class.

00:24.200 --> 00:29.720
And here we're going to write the logic of this function.

00:29.840 --> 00:36.280
Val bit map equals to image proxy dot to bitmap.

00:36.400 --> 00:48.480
And if it is not success go and through illegal state exception pass the the message failed to convert

00:48.520 --> 00:50.360
image proxy to bitmap.

00:50.400 --> 00:53.720
Okay here we have this step.

00:53.760 --> 00:58.320
We are going to convert the image proxy to bitmap.

00:58.440 --> 01:02.720
So the first one is converting image proxy to bitmap.

01:02.920 --> 01:14.160
The second step is using unit or or unsigned integer eight data type, not Float32.

01:14.200 --> 01:26.680
Here critical we're going to use use unit or unsigned integer eight data type and not float 32 val tensor

01:26.720 --> 01:27.280
image.

01:27.320 --> 01:33.280
Tensor image that's of data type unit or unsigned integer eight.

01:33.320 --> 01:36.360
There are a lot of data types.

01:37.120 --> 01:38.160
Integer 16.

01:38.200 --> 01:40.240
Integer 3264.

01:40.600 --> 01:42.360
Unsigned integer eight.

01:42.400 --> 01:43.360
Integer eight.

01:43.360 --> 01:44.000
String.

01:44.240 --> 01:51.640
But as I told you in the previous video, and when we talked about the input, we said that our model

01:51.640 --> 01:59.240
expects a unsigned integer eight, so the input is unsigned integer eight.

01:59.520 --> 02:02.520
This is a very important and critical.

02:02.560 --> 02:09.560
I said to you that it is critical because if you set it to, for example, 16, nothing.

02:09.680 --> 02:17.960
Uh, will, uh, will work and the app will crash, or maybe it will not display any detection.

02:17.960 --> 02:26.160
So this is a very important you should pay attention to the input and output of the shape.

02:26.320 --> 02:27.200
Okay guys.

02:27.360 --> 02:31.080
Tensor image dot load the bitmap.

02:31.240 --> 02:35.000
So we convert the image proxy to bitmap bitmap.

02:35.200 --> 02:39.360
Then we set it to unsigned integer eight.

02:39.640 --> 02:43.280
Then we loaded the image to a bitmap.

02:43.280 --> 02:54.520
Now the third step is process the image only resize and rotate as I told you, no normalization.

02:54.520 --> 02:56.120
So here there are.

02:56.240 --> 02:59.200
There is no normalization.

02:59.200 --> 03:02.040
It's very important and make it as critical.

03:02.200 --> 03:14.360
No normalization for an for unsigned integer data types or input val image process processor dot build.

03:14.400 --> 03:18.440
This is the builder and we talked about it in the previous videos.

03:18.600 --> 03:25.800
Dot add resize op which is operation the image size which is the target height.

03:25.840 --> 03:27.400
Image size.

03:27.560 --> 03:29.400
This is the target height.

03:29.440 --> 03:38.400
Then we need to pass another parameter which is the image size again which is the image width.

03:38.520 --> 03:46.720
The third parameter is resize op dot resize method dot by linear.

03:46.840 --> 03:47.360
Okay.

03:47.480 --> 03:57.560
Here we have this bilinear and use add rotate rotate 90 degrees up the image.

03:57.560 --> 04:02.640
Degrees over 90 and dot built.

04:05.840 --> 04:09.200
We missed here to close the parentheses.

04:09.200 --> 04:10.760
And here we go.

04:10.800 --> 04:12.160
This is not the image size.

04:12.160 --> 04:19.720
We need to use the fixed one, which is the image size from the object that we created before.

04:20.040 --> 04:25.760
Go up and here the companion object the image size which is 300.

04:25.800 --> 04:28.600
Or you can type 300 by.

04:28.720 --> 04:30.200
But I don't prefer it.

04:30.360 --> 04:33.800
If you change the model you should change everything.

04:34.080 --> 04:41.120
No, if you change the model, you should change this companion object the image size, the maximum

04:41.120 --> 04:45.000
detection number and the default maximum results.

04:45.040 --> 04:49.520
Okay, so this is the image processor.

04:49.560 --> 04:50.080
Okay.

04:50.280 --> 04:51.720
Let me return it.

04:51.720 --> 04:55.640
And let's explain what we've done here.

04:55.680 --> 05:01.600
Return image processor, dot process that tensor image.

05:01.640 --> 05:02.160
Okay.

05:02.280 --> 05:06.440
Close this and replace it with this parentheses.

05:06.520 --> 05:08.000
Curly braces okay.

05:08.160 --> 05:11.960
Now let me explain what we've done here.

05:12.160 --> 05:20.480
This prepare image for model function Pre-processes camera frames for the object detection model.

05:20.520 --> 05:22.520
Converting to bitmap.

05:22.520 --> 05:25.080
This is the first step.

05:25.240 --> 05:30.200
Transforms image proxy the camera format to map.

05:30.400 --> 05:33.520
So the image proxy is the camera format.

05:33.520 --> 05:42.200
So this camera format is the image proxy and create unsigned integer.

05:42.240 --> 05:53.440
A tensor called tensor image uses data type dot unit eight or u integer eight to match modal requirements

05:53.440 --> 05:57.880
from 0 to 255 pixel values apply.

05:58.200 --> 06:09.160
Processes and processing only resizes the model to input size and rotates for orientation and without

06:09.200 --> 06:10.760
normalization.

06:10.800 --> 06:11.760
Again guys.

06:11.960 --> 06:17.240
No normalization for unsigned integer eight input.

06:17.320 --> 06:24.200
This prepares the exact input format that your model expects.

06:24.400 --> 06:37.360
So here we are preparing the preparing the exact input input tensor of the model, which is unsigned

06:37.400 --> 06:44.840
integer eight and the array one 300 303.
