We created image capture, preview, executor and camera provider.
Now let's set up the real Android camera.
So as we learned before in the previous section, we need to use the Android view to set up camera X
and camera X is not.
There is no composable or ready made composable for handling the camera preview.
For this, we use the Android view that let us run the the the the camera X widget or view inside our
composables.
Okay, the first parameter is the modifier modifier dot fill maximum size.
The factory equals to context.
And let me start by this.
This is what we've done before and we created in the previous application.
Don't worry we're going to clarify everything.
Preview view pass the context and camera provider future dot add listener inside this camera.
Future dot add listener.
We need to set up the image analyzer and image capture and camera provider.
So we're going to set up the previously created variables and states.
I want from you to focus with me and pay attention.
The first step is the image analyzer val image analyzer equals to image analyzer dot builder dot set
target rotation to surface dot rotation zero.
Set back pressure strategy to image analysis.
Keep only latest dot build dot.
Also, don't worry, we're gonna clarify everything image analysis and pass it before lecture.
There is a mistake here.
Set target rotation, not name.
Don't worry the error here create exception.
And if we hover the mouse there is a returning type.
Um is a view but actually is unit.
So don't worry, we're going to solve it in the next couple of minutes.
But please pay attention.
Image analysis dot builder creates a builder for image analysis.
Set target to rotation.
Sets the image rotation to zero degrees for portrait.
So this is the portrait set back pressure strategy.
Drops all the frames.
Only keeps the most recent one when busy and build function builds.
The image analysis instance also immediately calls on image analysis callback with the build instance.
So this is how we set up the image analysis.
Again guys the purpose here is to configure.
Configure real time image analysis from the camera strategy keeps only latest optimal for ML machine
learning or computer vision tasks when you only need the latest frame.
Since we are not capturing the videos or photos, we just need to keep updating and keep only the latest
frame.
Target rotation ensures images are oriented correctly for analysis and here setting it rotation to zero,
which is the portrait.
The on image analysis function and callback typically sets up an analyzer to process each camera frame.
This creates a performant image analysis pipeline for real time process.
So this is the real time process pipeline for real time processing.