WEBVTT

00:00.200 --> 00:00.960
Welcome back.

00:01.000 --> 00:07.880
We created those variables the object detector, the object detector listener and detection results

00:07.880 --> 00:09.480
and the camera controller.

00:09.520 --> 00:12.400
Now I want from you to focus with me.

00:12.400 --> 00:15.800
This is a very important step we need to do here.

00:16.000 --> 00:24.600
We need to create the image analyzer that processes camera frames for object detection.

00:24.600 --> 00:37.160
Let's start with var analyzer equals to remember and set by using the image analyzer, passing image

00:37.440 --> 00:39.720
analyzer and pass.

00:39.720 --> 00:43.720
Here the parameter of the lambda expression.

00:43.880 --> 00:54.080
The image proxy remember is used to create a stable analyzer instance that survives recomposition,

00:54.120 --> 01:00.080
preventing recreating the analyzer on every frame, which could be inefficient.

01:00.120 --> 01:06.640
The image analysis and analyzer that receives camera frames.

01:06.800 --> 01:16.530
The image proxy contains the camera frame data and metadata called for every new camera frame frequency

01:16.530 --> 01:18.410
depends on camera configuration.

01:18.410 --> 01:22.090
So let me, um, add some notes here.

01:22.130 --> 01:23.410
Please write them down.

01:23.410 --> 01:28.410
Let's start by using the try and catch block.

01:28.570 --> 01:35.210
Try val bit map equals to image proxy dot to bitmap.

01:35.370 --> 01:43.370
Then we need the object detector instance that we create and get the detect function.

01:43.490 --> 01:46.890
Did you remember the detect function that we created before?

01:47.170 --> 01:53.570
Here we have two parameters to be passed the bitmap and the rotation.

01:53.570 --> 01:57.210
So passing the first parameter is the bitmap.

01:57.210 --> 02:04.210
And the second parameter is the rotation which is image proxy, image info and rotation degrees.

02:04.210 --> 02:12.250
Set the catch for e as exception log dot e e failed to analyze image.

02:12.290 --> 02:17.050
Then you can use finally block to set the image proxy dot.

02:17.050 --> 02:19.250
Close the val bitmap.

02:19.250 --> 02:30.420
Converting here the camera frame to a bitmap, convert image to bitmap, or you can set the camera frame.

02:30.540 --> 02:32.100
Camera frame.

02:32.300 --> 02:35.140
The image proxy image to bitmap.

02:35.260 --> 02:36.860
Here we are converting it.

02:37.020 --> 02:44.340
So you see guys, the image proxy is the camera frame that we get on every camera frame.

02:44.620 --> 02:50.980
And we are converting this image proxy into bitmap using the two bitmap function.

02:51.100 --> 02:51.540
Why?

02:51.580 --> 03:00.260
Because the object detector detect function takes the bitmap object and not an image, proxy or image

03:00.260 --> 03:01.380
or camera frame.

03:01.700 --> 03:05.740
It takes bitmap as the first parameter.

03:05.780 --> 03:09.500
This conversion has a performance cost.

03:09.780 --> 03:13.020
Consider alternatives for high efficiency analysis.

03:13.020 --> 03:21.220
But since our application is small and contains only two labels and, um, this is, uh, good, this

03:21.220 --> 03:25.540
is good, but there are better implementations and conversion.

03:25.580 --> 03:26.060
Okay.

03:26.220 --> 03:34.870
The rotation here and the object detector detect the bitmap through, uh, through an object detection

03:34.870 --> 03:35.470
model.

03:35.510 --> 03:38.350
A passes the image rotation.

03:38.350 --> 03:41.350
This is the rotation passes the image rotation.

03:41.350 --> 03:44.510
So detection can account for device orientation.

03:44.510 --> 03:51.630
Typically returns detection results, bounding boxes, labels, confidence scores and so on.

03:51.790 --> 03:54.270
Uh, try block attempts.

03:54.270 --> 04:01.990
The risky image processing operation catch handles failures gracefully without crashing the app.

04:02.190 --> 04:08.950
And finally crucial ensures image proxy close is always called.

04:08.950 --> 04:17.310
So here ensuring image proxy dot close is always called why we need it.

04:17.310 --> 04:22.470
Because releasing the camera frame buffer back to the camera system.

04:22.470 --> 04:26.830
Without this, the camera would stop producing new frames.

04:26.950 --> 04:32.910
And finally block ensures this run even if processing failed.

04:32.950 --> 04:37.430
Okay, this is all about the image analyzer.
