I use AVFoundation
framework to display video from camera.
The code how i use it is usual:
session = [[AVCaptureSession alloc] init] ;
...
captureVideoPreviewLayer = [[AVCaptureVideoPreviewLayer alloc] initWithSession:session];
...
[cameraView.layer addSublayer:captureVideoPreviewLayer];
...
So i want to add zoom function to camera.
I have found 2 solutions how to implement zoom.
First : is to use CGAffineTransform
:
cameraView.transform = CGAffineTransformMakeScale(x,y);
Second : is to put cameraView in the scroll view ,set up max and min scrolling and set this view as zooming view.
- (UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView
{
return cameraView;
}
What is the best way to make zooming better performance and quality? Are there any else solutions to make zoom? Maybe i missed some AVFoundation
methods for zooming.
Thank you.
The remainder of this blog post, though, will detail exactly how to build your own camera control using AVFoundation. AVFoundation is a namespace that contains classes for high-level recording and playback capabilities for audio and video on iOS.
We encourage you to try it. Camera Manager has an example app that you can run on your device. You'll need a real device to run it, due to the use of AVFoundation camera API's which are unavailable on the iOS simulator. Ready for a UX Audit?
Let’s move on to switching cameras. Switching cameras in AV Foundation is a pretty easy task. We just need to remove the capture input for the existing camera and add a new capture input for the camera we want to switch to. Let’s add another function to our CameraController class for switching cameras:
Building a Custom Camera with AVFoundation AVFoundation is a namespace that contains classes for high-level recording and playback capabilities for audio and video on iOS. Many tasks, such as capturing and playing photos or videos, can be done without AVFoundation using techniques described earlier in this post.
Well there is actually a GCFloat
called setVideoScaleandCropFactor
.
You can find the documentation here.
I'm not sure if this is just for still image output but I've been working on it and it does well if you set it to a gesture or a slider and let that control the float.
You can find a demo of it here.
Good stuff. Im trying to loop it so I can create a barcode scanner with a zoom. What im doing is rough though haha.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With