AVFoundation zoom

I use the AVFoundation framework to display video from the camera.

The code, as I use it, is usually:

 session = [[AVCaptureSession alloc] init] ; ... captureVideoPreviewLayer = [[AVCaptureVideoPreviewLayer alloc] initWithSession:session]; ... [cameraView.layer addSublayer:captureVideoPreviewLayer]; ... 

So, I want to add a zoom function to the camera.

I found 2 solutions on how to implement scaling.

First : use CGAffineTransform :

cameraView.transform = CGAffineTransformMakeScale(x,y);

Second : you need to place the CameraView in the scroll view, configure the scrolling of max and min, and set this view to scale.

 - (UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView { return cameraView; } 

What is the best way to increase productivity and quality? Are there any other solutions to increase? I might have skipped some AVFoundation methods for scaling.

Thanks.

+7
source share
1 answer

Well, there really is a GCFloat called setVideoScaleandCropFactor .

Here you can find the documentation here .

I'm not sure if this is only for outputting still images, but I worked on it, and it’s good if you install it on a gesture or slider and let it control the float.

You can find a demo here .

Good stuff. Im trying to loop it so that I can create a scaleable barcode scanner. What am I doing rudely though haha.

+6
source

All Articles