I work on a Flutter
app in which I use camera
plugin. I want to zoom in to an arbitrary point (offset) of the camera
preview, for example to the top-left corner of the screen and then take a photo of it. Using CameraContoroller.setZoomLevel()
method zooms into the center of the camera
! Is it possbile to achieve the behavior that I want? Thank you in advance!
Here is what I want to achieve!
4
Answers
Unfortunately your wanted behavior is probably not possible with the camera packages. That is because the camera itself can not zoom into a specific area of its view, because of the way how zooming works with the hardware.
But there are ways to achieve your expected behavior. Try to wrap your CameraPreview with a OverflowBox and/or a ClipRect and position the Preview in a way, that only the part you want to zoom in is visible.
But be aware, that you "zoom" only virtually this way, because the actual camera view wont change (the resulting cutout may be of worse quality).
Basically you are creating the illusion of a zoom, by cropping the image to the expected area.
You can view specific code examples, on how you can implement this functionality in this answer.
Keep in mind that if you want to take a picture of the "zoomed" area, you have to crop the resulting image again (because the actual camera view doesn’t change), as explained in the question above.
Camera zoom at a particular point of view is not possible even on a native camera or any other camera.
I’ve checked iphone, android and even Dslr. Since your camera hardware starts with a single point of view spread around. It is impossible to zoom at a particular point without moving or calibrating the camera.
The problem can only be solved after capturing the snapshot and cropping the particular area thus giving an illusion of that particular zoom.
However this could be solved if we use multiple cameras and make a mechanism out of it, only reason it has been ignored is because the problem is not much critical to see into.
You can do it but it’s a bit not practical , by showing the Camera Image in a Dragable/zoomable widget like
InteractiveViewer()
, then wrap it with aGestureDetector()
and then make a function that zooms when you double press the image and drag to the point you want.I’m Trying To Solve Your Problem:
Code:
you just need to wrap
widget on
it’s working fine