6

私はカメラからできるだけ良い画像を取得しようとしていますが、その例を見つけることしかできず、captureStillImageAsynchronouslyFromConnectionすぐに次の場所に移動します。

NSData *imageData = [AVCaptureStillImageOutput jpegStillImageNSDataRepresentation:imageSampleBuffer];    
UIImage *image = [[UIImage alloc] initWithData:imageData];

JPEGは不可逆であり、データをPNGとして、またはRGBA(BGRA、what-have-you?)として取得する方法はありますか?AVCaptureStillImageOutputには他のNSData*メソッドがないようです...。

実際にCMSampleBufferRefを見ると、すでにJPEGとしてロックされているようです〜

formatDescription = <CMVideoFormatDescription 0xfe5e1f0 [0x3e5ac650]> {
mediaType:'vide' 
mediaSubType:'jpeg' 
mediaSpecific: {
    codecType: 'jpeg'       dimensions: 2592 x 1936 
} 
extensions: {(null)}
}

フル解像度の写真を撮り、生データを取得する他の方法はありますか?

4

2 に答える 2

10

outputSettingsを別のピクセル形式で設定する必要があります。たとえば、32ビットBGRAが必要な場合は、次のように設定できます。

NSDictionary *outputSettings = [NSDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithUnsignedInt:kCVPixelFormatType_32BGRA], (id)kCVPixelBufferPixelFormatTypeKey, nil];

https://developer.apple.com/library/mac/#documentation/AVFoundation/Reference/AVCaptureStillImageOutput_Class/Reference/Reference.htmlから、「推奨される」ピクセル形式は次のとおりです。

  • kCMVideoCodecType_JPEG
  • kCVPixelFormatType_420YpCbCr8BiPlanarFullRange
  • kCVPixelFormatType_32BGRA

もちろん、JPEG出力を使用していない場合は使用できませんがjpegStillImageNSDataRepresentation:、ここに例があります: CVImageBufferRefをUIImageに変換する方法

于 2012-07-26T01:06:14.497 に答える
0

接続の出力設定を変更するだけです。

outputSettings出力の圧縮設定。

@property(nonatomic, copy) NSDictionary *outputSettings

サポートされている値のNSDictionaryを次のコマンドで取得できます。

availableImageDataCodecTypesoutputSettingsで指定できるサポートされている画像コーデック形式。(読み取り専用)

@property(nonatomic, readonly) NSArray *availableImageDataCodecTypes
于 2012-07-20T01:34:41.023 に答える