zoukankan      html  css  js  c++  java
  • AVfoundation中焦距的设置(slider实现拉近拉远镜头) -自定义UISlider

    首先设置一个slider

    UISlider focusSlider = [[UISlideralloc]initWithFrame:CGRectMake(60,_bottomView.frame.origin.y-60,200,20)];

        [focusSlideraddTarget:selfaction:@selector(AdjustFocusAction:)forControlEvents:UIControlEventValueChanged];

        [focusSlidersetThumbImage:[UIImageimageNamed:@"camera_view_slider_take_gray.png"]forState:UIControlStateNormal];

        [focusSlidersetMinimumTrackImage:[UIImageimageNamed:@"camera_view_sliderbar_gray.png"]forState:UIControlStateNormal];

        [focusSlidersetMaximumTrackImage:[UIImageimageNamed:@"camera_view_sliderbar_gray.png"]forState:UIControlStateNormal];

        [focusSlidersetBackgroundColor:[UIColorclearColor]];

        [focusSlidersetMaximumValue:1];

        [focusSlidersetMinimumValue:0];

        [focusSlider setValue:0.0];

        [self.viewaddSubview:focusSlider];

    以下做一下有关相机的设置(只写出来了其中一部分,并非全部)

    preview = [AVCaptureVideoPreviewLayerlayerWithSession:self.session];

        self.preview.frame =CGRectMake(0,0, self.cameraView.frame.size.width,self.cameraView.frame.size.height);

        [self.previewsetPosition:CGPointMake(CGRectGetMidX(self.cameraView.bounds),CGRectGetMidY(self.cameraView.bounds))];

       

        self.preview.videoGravity =AVLayerVideoGravityResize;

        [self.cameraView.layeraddSublayer:self.preview];


    captureOutput(AVCaptureStillImageOutput*)[self.session.outputsobjectAtIndex:0];

     

    focusConnection =[captureOutput connectionWithMediaType:AVMediaTypeVideo];    

                                                              

    调节焦距

     

    -(void)AdjustFocusAction:(id)sender

    {

        [UIViewanimateWithDuration:0.025animations:^{

            [self.previewsetAffineTransform:CGAffineTransformMakeScale([(UISlider *)sendervalue]+1, [(UISlider *)sendervalue]+1)];

            focusConnection.videoScaleAndCropFactor = [(UISlider *)sendervalue]+1;

        }];


    }

  • 相关阅读:
    Sqlserver @@IDENTITY 和 SCOPE_IDENTITY() 的使用
    Sqlserver 其它操作
    将 .net core 通过容器docker 部署到 linux 记录
    Unity中使用ProtocolBuffer
    Android笔记基于https://www.bilibili.com/video/BV1Bf4y1D7Gq?p=1
    简单登陆界面的应用
    springboot 梳理7--整合redis(待完善)
    4.工厂方式建立
    5,db的解决方法,日志集成
    10.3右上角后台逻辑处理,前台处理
  • 原文地址:https://www.cnblogs.com/allanliu/p/4277438.html
Copyright © 2011-2022 走看看