2

カメラからの露出値は、写真を撮るときに (SavedPhotos に保存せずに) 取得できます。iPhoneの露出計アプリケーションは、おそらく何らかのプライベート API を使用してこれを行います。

そのアプリケーションは iPhone 3GS でのみ実行するため、画像の作成時にこの情報が取り込まれる EXIF データに何らかの形で関連している可能性があると思います。

これはすべて 3GS に適用されます。

iPhone OS 4.0 で何か変わったことはありますか? これらの値を取得する通常の方法はありますか?

これらのカメラ/写真設定値を取得するための実用的なコード例はありますか?

ありがとうございました

4

4 に答える 4

8

リアルタイム* 露出情報が必要な場合は、AVCaptureVideoDataOutput を使用してビデオをキャプチャできます。各フレーム CMSampleBuffer には、カメラの現在の状態を表す興味深いデータがいっぱいです。

※30fpsまで

于 2011-05-22T07:44:36.633 に答える
2

iOS 4.0 の AVFoundation を使用すると、露出を台無しにすることができます。具体的には AVCaptureDevice を参照してください。リンクはAVCaptureDevice refです。それがまさにあなたが望むものかどうかはわかりませんが、AVFoundation を見回すと、おそらくいくつかの便利なものを見つけることができます

于 2010-07-03T17:02:17.687 に答える
2

ようやく本当の EXIF データへの手がかりを見つけたと思います。実際のコードを投稿するまでにはしばらく時間がかかりますが、それまでの間、これを公開する必要があると考えました。

Google captureStillImageAsynchronouslyFromConnectionこれはAVCaptureStillImageOutputの機能であり、以下はドキュメントからの抜粋です (長い間求められていました):

imageDataSampleBuffer - キャプチャされたデータ。バッファの添付ファイルには、画像データ形式に適したメタデータが含まれている場合があります。たとえば、JPEG データを含むバッファは、添付ファイルとして kCGImagePropertyExifDictionary を運ぶことができます。キーと値のタイプのリストについては、ImageIO/CGImageProperties.h を参照してください。

AVCaptureStillImageOutputの使用例については、AVCamの下にある WWDC 2010 サンプル コードを参照してください

平和、O.

于 2010-08-02T06:45:25.567 に答える
0

これが完全な解決策です。適切なフレームワークとヘッダーをインポートすることを忘れないでください。capturenow メソッドの exifAttachments var で、探しているすべてのデータを見つけることができます。

#import <AVFoundation/AVFoundation.h>
#import <ImageIO/CGImageProperties.h>

AVCaptureStillImageOutput *stillImageOutput;
AVCaptureSession *session;    

- (void)viewDidLoad
    {
        [super viewDidLoad];
        [self setupCaptureSession];
        // Do any additional setup after loading the view, typically from a nib.    
    }

    -(void)captureNow{


        AVCaptureConnection *videoConnection = nil;
        for (AVCaptureConnection *connection in stillImageOutput.connections)
        {
            for (AVCaptureInputPort *port in [connection inputPorts])
            {
                if ([[port mediaType] isEqual:AVMediaTypeVideo] )
                {
                    videoConnection = connection;
                    break;
                }
            }
            if (videoConnection) { break; }
        }

        [stillImageOutput captureStillImageAsynchronouslyFromConnection:videoConnection
         completionHandler:^(CMSampleBufferRef imageDataSampleBuffer, NSError *__strong error) {
            CFDictionaryRef exifAttachments = CMGetAttachment( imageDataSampleBuffer, kCGImagePropertyExifDictionary, NULL);
            if (exifAttachments)
            {
                // Do something with the attachments.
                NSLog(@"attachements: %@", exifAttachments);
            }
            else
              NSLog(@"no attachments");

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

    }


    // Create and configure a capture session and start it running
    - (void)setupCaptureSession
    {
        NSError *error = nil;

        // Create the session
        session = [[AVCaptureSession alloc] init];

        // Configure the session to produce lower resolution video frames, if your
        // processing algorithm can cope. We'll specify medium quality for the
        // chosen device.
        session.sessionPreset = AVCaptureSessionPreset352x288;

        // Find a suitable AVCaptureDevice
        AVCaptureDevice *device = [AVCaptureDevice
                                   defaultDeviceWithMediaType:AVMediaTypeVideo];
        [device lockForConfiguration:nil];

        device.whiteBalanceMode = AVCaptureWhiteBalanceModeLocked;
        device.focusMode = AVCaptureFocusModeLocked;
        [device unlockForConfiguration];

        // Create a device input with the device and add it to the session.
        AVCaptureDeviceInput *input = [AVCaptureDeviceInput deviceInputWithDevice:device
                                                                            error:&error];
        if (!input) {
            // Handling the error appropriately.
        }
        [session addInput:input];




        stillImageOutput = [AVCaptureStillImageOutput new];
        NSDictionary *outputSettings = [[NSDictionary alloc] initWithObjectsAndKeys: AVVideoCodecJPEG, AVVideoCodecKey, nil];
        [stillImageOutput setOutputSettings:outputSettings];
        if ([session canAddOutput:stillImageOutput])
            [session addOutput:stillImageOutput];


        // Start the session running to start the flow of data
        [session startRunning];
        [self captureNow];

    }
于 2013-04-10T04:59:50.193 に答える