简体   繁体   English

延时捕获帧-iPhone相机

[英]Capture frames with time delay - iPhone camera

I'm trying to write some objective-c code that allows capture of frames through the iPhone camera, after a specific time delay. 我正在尝试编写一些Objective-C代码,允许在特定的时间延迟后通过iPhone相机捕获帧。 Any examples I have found online have captured the 'present' frame input by the camera (ie a realtime frame capture). 我在网上找到的所有示例均已捕获了摄像机输入的“当前”帧(即实时帧捕获)。 I am looking for a less real time frame capture - a way to capture frames with a specific time delay. 我正在寻找不太实时的帧捕获-一种捕获具有特定时间延迟的帧的方法。 Any ideas? 有任何想法吗?

I would use NSTimer . 我会使用NSTimer It would allow you to use the code that captures the current frame, and it would get called after a delay. 它将允许您使用捕获当前帧的代码,并且将在延迟后调用它。

You can create a non-repeating timer like this: timer = [NSTimer scheduledTimerWithTimerInterval:delay target:self selector:@selector(capture) userInfo:nil repeats:NO]; 您可以创建一个非重复计时器,如下所示: timer = [NSTimer scheduledTimerWithTimerInterval:delay target:self selector:@selector(capture) userInfo:nil repeats:NO]; where delay is the specific time delay and capture is a method that contains the code from an example that captures the present frame. 其中delay是特定的时间延迟,而capture是一种方法,其中包含捕获当前帧的示例中的代码。

Use following code..... 使用以下代码.....

//call method according to your delay that you need..... //根据需要的延迟调用方法.....

    float yourdelay;
    yourdelay = 0.7;
    [self performSelector:@selector(captureView) withObject:nil afterDelay:yourdelay];

// or set time for calling method.... //或设置调用方法的时间...

[NSTimer scheduledTimerWithTimeInterval:0.02 target: self selector:@selector(captureView) userInfo:nil repeats:NO];

///or you can call method directly when you need.. ///或者您可以在需要时直接调用方法。

[self captureView];

////Here the code for capture real time image. ////这里是捕获实时图像的代码。

- (void)captureView {

UIGraphicsBeginImageContext(mapView.frame.size);
[self.view.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *viewImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
flickerImaveView.image=viewImage;    
}

Hope this will help you.... 希望这个能对您有所帮助....

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM