Welcome back.
We finished the Object Detector helper class and now we need to create the camera screen.
So inside the screens create a new Kotlin file.
Name it as camera screen.
Start with a new composable function.
Name it as camera screen val context equals to local context dot current val life cycle owner equals
to lack local lifecycle owner dot current.
Here it's very simple.
We are accessing the Android context in compose function.
So we need for accessing resources, starting activities, access system services, showing toasts and
so on.
Here getting the current lifecycle owner for lifecycle aware operations like observing live data, lifecycle
aware coroutines, register lifecycle observers, and so on.
We talked a lot in the previous sections about those two concepts.
Now val camera controller equals to remember life cycle camera controller passing the context dot apply
set enabled use cases and set the camera controller image analysis.
Let me explain.
Remember creates a long lived object that survives the composition.
Camera controller is expensive to create and should persist across UI updates.
So let me write those notes down here and I want from you to write them, because they are very important
and helps you to memorize everything without using.
Remember with recreate the controller on every composition, causing camera flickering and reinitialization.
So we use the remember, because camera controller is expensive to create and should persist across
UI updates and recompositions, the lifecycle camera controller Manages the camera lifecycle.
Automatically handles camera lifecycle.
Open and close on start or stop.
Manages camera permissions and handles configuration changes like rotation.
Apply configure the control immediately after creation and alternative to creating a variable and calling
methods separately.
Set enabled use cases that set enabled use cases.
The camera controller, dot preview use case or image capture.
The preview use case here for camera preview and the camera controller.
Dot image capture for taking photos.
So here we need to take photos.
Taking photos can combine multiple image analysis or image capture.
So for example here we have image analysis, image capture, video capture and others.
But for now we need that image capture.
This is for camera control.