2014-11-25 7 views
0

저는 Apple의 AVCam source code을 사용하여 맞춤 카메라를 만들었습니다. 매력있는 것처럼 보이지만 일단 비디오 또는 이미지를 캡처 한 다음 사진을 체크인하면 문제가 발생합니다. 라이브러리의 방향이 가로로 변경됩니다 (세로 방향으로 캡처 한 경우조차도). 나는 이것을 많이 찾았지만 이것을위한 길을 찾지 못했습니다. 어떤 도움이 필요합니까?AVCam을 사용하여 비디오 또는 이미지의 방향을 세로로 변경하십시오.

참고로 내 앱은 세로 만 지원하고 캡쳐는 세로로해야합니다.

업데이트 :

AVCaptureConnection *captureConnection = ... 
if ([captureConnection isVideoOrientationSupported]) 
{ 
    AVCaptureVideoOrientation orientation = AVCaptureVideoOrientationPortrait; 
    [captureConnection setVideoOrientation:orientation]; 
} 

이 작동하지 않습니다.

답변

0

이미지를 캡처하려면 방향도 설정해야합니다. 디스크에 이미지를 저장할 때는

writeImageToSavedPhotosAlbum:orientation:completionBlock: 

기능을 사용해야하며 올바른 "방향"매개 변수도 설정해야합니다.

용도 : https://developer.apple.com/library/ios/documentation/AssetsLibrary/Reference/ALAssetsLibrary_Class/index.html#//apple_ref/occ/instm/ALAssetsLibrary/writeImageToSavedPhotosAlbum:orientation:completionBlock :

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

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

     if (imageDataSampleBuffer) { 
      self.imageData = [AVCaptureStillImageOutput jpegStillImageNSDataRepresentation:imageDataSampleBuffer]; 

      [[[ALAssetsLibrary alloc] init] writeImageToSavedPhotosAlbum:image.CGImage 
                  orientation:(ALAssetOrientation)[image imageOrientation] 
                 completionBlock:^(NSURL *assetURL, NSError *error) { 
                  if(error == nil) { 
                   NSLog(@"PHOTO SAVED - assetURL: %@", assetURL); 
                  } else { 
                   NSLog(@"ERROR : %@",error); 
                  } 
                 }]; 
: 목표 C에