WEBVTT

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

00:01.200 --> 00:08.600
We finished the Object Detector helper class and now we need to create the camera screen.

00:08.600 --> 00:12.320
So inside the screens create a new Kotlin file.

00:12.440 --> 00:15.320
Name it as camera screen.

00:15.440 --> 00:19.000
Start with a new composable function.

00:19.000 --> 00:33.000
Name it as camera screen val context equals to local context dot current val life cycle owner equals

00:33.000 --> 00:38.320
to lack local lifecycle owner dot current.

00:38.360 --> 00:39.800
Here it's very simple.

00:39.800 --> 00:43.960
We are accessing the Android context in compose function.

00:43.960 --> 00:51.800
So we need for accessing resources, starting activities, access system services, showing toasts and

00:51.800 --> 00:52.440
so on.

00:52.480 --> 01:01.200
Here getting the current lifecycle owner for lifecycle aware operations like observing live data, lifecycle

01:01.200 --> 01:05.200
aware coroutines, register lifecycle observers, and so on.

01:05.360 --> 01:10.230
We talked a lot in the previous sections about those two concepts.

01:10.270 --> 01:21.950
Now val camera controller equals to remember life cycle camera controller passing the context dot apply

01:22.030 --> 01:29.630
set enabled use cases and set the camera controller image analysis.

01:29.670 --> 01:30.790
Let me explain.

01:30.790 --> 01:36.510
Remember creates a long lived object that survives the composition.

01:36.670 --> 01:42.430
Camera controller is expensive to create and should persist across UI updates.

01:42.430 --> 01:50.350
So let me write those notes down here and I want from you to write them, because they are very important

01:50.350 --> 01:54.390
and helps you to memorize everything without using.

01:54.390 --> 02:01.910
Remember with recreate the controller on every composition, causing camera flickering and reinitialization.

02:01.910 --> 02:07.950
So we use the remember, because camera controller is expensive to create and should persist across

02:07.990 --> 02:16.030
UI updates and recompositions, the lifecycle camera controller Manages the camera lifecycle.

02:16.270 --> 02:18.990
Automatically handles camera lifecycle.

02:18.990 --> 02:21.270
Open and close on start or stop.

02:21.470 --> 02:26.870
Manages camera permissions and handles configuration changes like rotation.

02:26.910 --> 02:35.030
Apply configure the control immediately after creation and alternative to creating a variable and calling

02:35.030 --> 02:36.350
methods separately.

02:36.710 --> 02:43.470
Set enabled use cases that set enabled use cases.

02:43.670 --> 02:48.310
The camera controller, dot preview use case or image capture.

02:49.310 --> 02:54.710
The preview use case here for camera preview and the camera controller.

02:54.710 --> 02:57.750
Dot image capture for taking photos.

02:57.750 --> 02:59.950
So here we need to take photos.

03:00.150 --> 03:06.590
Taking photos can combine multiple image analysis or image capture.

03:06.910 --> 03:12.870
So for example here we have image analysis, image capture, video capture and others.

03:12.870 --> 03:15.830
But for now we need that image capture.

03:15.950 --> 03:17.990
This is for camera control.
