标签: avcam

将照片保存到相机胶卷时,AVCaptureMovieFileOutput导致方向错误

我对captureStillImageAsynchronouslyFromConnection有一个奇怪的问题.如果在镜像视频时使用jpegStillImageNSDataRepresentation保存图像,则相机胶卷中的图像顺时针旋转90度.但是,如果它没有镜像,则方向很好.我会发布代码,其他人有这个问题/知道修复?

更新:刚刚运行了一些测试,高度和宽度(640x480)很好,反映了设备的方向.当我以肖像拍照时,它会报告UIImageOrientationLeft并在镜像时报告UIImageOrientationLeftMirrored.

更新2:当我在相机胶卷中查看已保存的照片时,图像预览的方向正确,在照片之间滑动时图像也是如此,但是当照片完全加载时,它会旋转90度.这可能是相机胶卷问题吗?(我在4.3.3)

- (void) captureImageAndSaveToCameraRoll
{
    AVCaptureConnection *stillImageConnection = [AVCamUtilities connectionWithMediaType:AVMediaTypeVideo fromConnections:[[self stillImageOutput] connections]];
    if ([stillImageConnection isVideoOrientationSupported])
        [stillImageConnection setVideoOrientation:[self orientation]];

    [[self stillImageOutput] captureStillImageAsynchronouslyFromConnection:stillImageConnection
                                                         completionHandler:^(CMSampleBufferRef imageDataSampleBuffer, NSError *error) {

                                                             ALAssetsLibraryWriteImageCompletionBlock completionBlock = ^(NSURL *assetURL, NSError *error) {
                                                                 if (error) {
                                                                     if ([[self delegate] respondsToSelector:@selector(captureManager:didFailWithError:)]) {
                                                                         [[self delegate] captureManager:self didFailWithError:error];
                                                                     }
                                                                 }
                                                             };

                                                             if (imageDataSampleBuffer != NULL) {
                                                                 NSData *imageData = [AVCaptureStillImageOutput jpegStillImageNSDataRepresentation:imageDataSampleBuffer];
                                                                 ALAssetsLibrary *library = [[ALAssetsLibrary alloc] init];

                                                                 UIImage *image = [[UIImage alloc] initWithData:imageData];
                                                                 [library writeImageToSavedPhotosAlbum:[image CGImage]
                                                                                           orientation:(ALAssetOrientation)[image imageOrientation]
                                                                                       completionBlock:completionBlock]; …
Run Code Online (Sandbox Code Playgroud)

iphone avfoundation ios avcapturesession avcam

5
推荐指数
1
解决办法
4249
查看次数

AVCamDemo - 不会调用captureStillImageAsynchronouslyFromConnection的完成处理程序

我已经修改了AVCamDemoWWDC 2010使用AVCaptureSessionPresetPhoto代替AVCaptureSessionPresetHigh.这适用于iPhone 3GS(iOS 4.3.5),但在使用iPhone 3G(iOS 4.2.1)时,captureStillImageAsynchronouslyFromConnection 永远不会调用完成处理程序,并且预览图层会在最后一帧冻结.

有没有其他人看过这种行为或知道如何解释它?

iphone camera 3g ios avcam

5
推荐指数
0
解决办法
790
查看次数

重新打开AVCaptureSession

我有一个应用程序,需要一些照片.我的整个应用程序都是基于WWDC 2010 的AVCam示例代码.我已经搞砸了很多但直到现在我还无法弄清楚如何正确释放相机视图以释放相机会话......

我要做的就是以下几点:

  • 打开相机视图控制器
  • 拍一些照片
  • 关闭相机视图控制器
  • 再打开它

第二次推送viewController会话丢失,预览不可用,捕获也不可用.我在github上发布了完整的示例代码.

我对这个问题的解决方法是根本不释放相机,因此Camera View Controller充当Singleton,我认为这不是正确的方法.此外,有了这种行为,我无法找到一种方法来支持相机应用程序进入后台(例如电话).

请指教.如何破坏相机会话?这样做很重要吗?

iphone cocoa-touch avfoundation ios avcam

5
推荐指数
1
解决办法
3238
查看次数

iOS录制视频并同时播放MP3

我需要从iPhone摄像头录制视频,同时播放MP3文件.

我开始使用AVCam示例代码,我相信你们都有.它非常适合录制视频.

但是,我添加了以下代码来播放MP3.这个MP3播放代码在我的不同应用程序中工作,但是当我将其插入到此示例代码中时,MP3不仅不会播放,AVCamCaptureManager的recordingDidFinishToOutputFileURL永远不会被调用,因此视频永远不会被保存.

这就像音频播放代码与视频捕获代码冲突.有任何想法吗?

这是我放入AVCam的音频播放代码:

 AVAudioPlayer *audioPlayer = nil;
    NSURL *url = [NSURL fileURLWithPath:[NSString stringWithFormat:@"%@/soundeffect.mp3", [[NSBundle mainBundle] resourcePath]]];
    audioPlayer = [[AVAudioPlayer alloc] initWithContentsOfURL:url error:&error];
    [audioPlayer setVolume:1.0]; 
    [audioPlayer prepareToPlay];
    [m_audioPlayer play];
Run Code Online (Sandbox Code Playgroud)

这里的代码非常简单.不知道为什么这个音频播放代码会导致recordingDidFinishToOutputFileURL永远不会被调用...

谢谢你的任何想法.

iphone record avaudioplayer ios avcam

4
推荐指数
1
解决办法
1507
查看次数

将BGRA转换为ARGB

我正在阅读本教程,从iPhone相机获取像素数据.

虽然我没有运行和使用此代码的问题,但我需要获取相机数据的输出(在BGRA中)并将其转换为ARGB,以便我可以将其与外部库一起使用.我该怎么做呢?

core-graphics ios avcapturesession avcam

4
推荐指数
1
解决办法
4649
查看次数

AVCam vs UIImagepicker

我是iPhone的新手,我想知道AVFoundation的AVCam和UIImagePicker相机有什么区别.什么时候我们应该去AVCam什么时候去UIImagePicker

提前致谢

iphone avfoundation uiimagepickercontroller ios avcam

4
推荐指数
1
解决办法
1903
查看次数

iPhone应用程序 - 在横向模式下显示AVFoundation视频

我正在使用Apple的AVCam示例App.

此示例使用AVFoundation以在视图上显示视频.

我试图从AVCam制作一个没有运气的风景应用程序.

当屏幕方向改变时,视频在视图上旋转显示.有办法解决这个问题吗?

iphone video rotation avfoundation avcam

3
推荐指数
1
解决办法
4248
查看次数

iPhone相机聚焦

我使用下面的代码来聚焦iphone相机.但它没有用.我从Apple的AVCam示例代码中获取此代码.我做错了吗?是否有任何方法可以检测到iPhone是否真正关注?

-(void) focusAtPoint:(CGPoint)point   
{
    AVCaptureDevice *device =  [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeVideo];;

    if (device != nil) {            
        if ([device isFocusPointOfInterestSupported] && [device isFocusModeSupported:AVCaptureFocusModeAutoFocus]) {

            NSError *error;

            if ([device lockForConfiguration:&error]) {             
                [device setFocusPointOfInterest:point];             
                [device setFocusMode:AVCaptureFocusModeAutoFocus];              
                [device unlockForConfiguration];                
            } else {                
                NSLog(@"Error in Focus Mode");
            }        

        }
    }
}
Run Code Online (Sandbox Code Playgroud)

iphone objective-c avcapturesession avcapturedevice avcam

3
推荐指数
1
解决办法
3816
查看次数

AVCam保存全屏捕获的图像

我使用苹果公司制作的AVCam作为我的自定义相机视图.老实说,AVCamViewController如果你第一次看到它,那么理解课堂上发生的事情并不简单.

现在我感兴趣他们如何设置捕获图像的帧.我试图找到一些名人或类似的东西,但我没有找到任何.

我在谷歌搜索,发现AVCam的答案不在全屏

但是当我实现该解决方案时,我才意识到它只是制作了与我的视图相同大小的实时相机预览图层,但是当应用程序将图像保存- (IBAction)snapStillImage:(id)sender在图库中的方法中时,图像仍然是左右两个条纹.

我的问题是如何删除此条纹或源代码中的哪一行苹果设置这个东西?

另外作为额外的子问题我如何设置类型创建只是照片,因为该应用程序请求我"麦克风设置",我不需要它只需要拍一张照片,就是这样.

来自apple源的此代码将图像保存到照片库.

- (IBAction)snapStillImage:(id)sender
{
    dispatch_async([self sessionQueue], ^{
        // Update the orientation on the still image output video connection before capturing.
        [[[self stillImageOutput] connectionWithMediaType:AVMediaTypeVideo] setVideoOrientation:[[(AVCaptureVideoPreviewLayer *)[[self previewView] layer] connection] videoOrientation]];

        // Flash set to Auto for Still Capture
        [AVCamViewController setFlashMode:AVCaptureFlashModeAuto forDevice:[[self videoDeviceInput] device]];

        // Capture a still image.
        [[self stillImageOutput] captureStillImageAsynchronouslyFromConnection:[[self stillImageOutput] connectionWithMediaType:AVMediaTypeVideo] completionHandler:^(CMSampleBufferRef imageDataSampleBuffer, NSError *error) {

            if (imageDataSampleBuffer)
            {
                NSData *imageData = [AVCaptureStillImageOutput …
Run Code Online (Sandbox Code Playgroud)

objective-c ios avcapturesession avcam

2
推荐指数
1
解决办法
1564
查看次数