الحصول على التعرض القيم من الكاميرا على نظام التشغيل اي فون 4.0

StackOverflow https://stackoverflow.com/questions/3172116

سؤال

التعرض القيم من الكاميرا يمكن الحصول عليها عندما كنت تأخذ الصورة (دون حفظ إلى SavedPhotos).A ضوء متر التطبيق على اي فون يفعل هذا, ربما باستخدام بعض API الخاص.

هذا التطبيق يعمل على اي فون 3GS فقط, لذا أعتقد أنها قد تكون ذات صلة بطريقة أو بأخرى إلى EXIF البيانات التي يتم ملؤها مع هذه المعلومات عندما يتم إنشاء الصورة.

كل هذا ينطبق على 3GS.

هل تغير شيء مع نظام التشغيل اي فون 4.0?هل هناك طريقة منتظمة للحصول على هذه القيم الآن ؟

لا أحد يملك العامل المثال التعليمات البرمجية على أخذ هذه الكاميرا/صور الإعداد القيم ؟

شكرا لك

هل كانت مفيدة؟

المحلول

مع AVFoundation في دائرة الرقابة الداخلية 4.0 يمكنك أن تعبث مع التعرض تشير على وجه التحديد إلى AVCaptureDevice, هنا هو الرابط AVCaptureDevice ref.ليس متأكدا مما إذا كان ما تريده بالضبط ولكن يمكنك البحث حول AVFoundation و ربما تجد بعض الأشياء المفيدة

نصائح أخرى

إذا كنت تريد في الوقت الحقيقي* التعرض المعلومات ، يمكنك التقاط الفيديو باستخدام AVCaptureVideoDataOutput.كل إطار CMSampleBuffer هو الكامل من البيانات مثيرة للاهتمام واصفا الوضع الحالي من الكاميرا.

*ما يصل إلى 30 إطارا في الثانية

أعتقد أنني أخيرا وجدت يؤدي إلى ريال EXIF البيانات.سيستغرق الأمر وقتا قبل أن يكون الرمز الفعلي إلى آخر ، ولكن فكرت يجب أن يكون هذا الإعلان في الوقت الحالي.

جوجل captureStillImageAsynchronouslyFromconnection.إنها وظيفة AVCaptureStillImageOutput و فيما يلي مقتطفات من الوثائق (طويلة سعى):

imageDataSampleBuffer - البيانات التي تم التقاطها.المخزن المؤقت المرفقات قد تحتوي على البيانات الوصفية المناسبة إلى صورة تنسيق البيانات.على سبيل المثال العازلة التي تحتوي JPEG البيانات قد تحمل kCGImagePropertyExifDictionary كمرفق.انظر ImageIO/CGImageProperties.ساعة للحصول على قائمة من مفاتيح أنواع قيمة.

على سبيل المثال من العمل مع AVCaptureStillImageOutput انظر WWDC 2010 نموذج التعليمات البرمجية في إطار AVCam.

السلام O.

هنا هو الحل الكامل.لا ننسى أن استيراد الأطر المناسبة و رؤوس.في exifAttachments فار في capturenow الطريقة سوف تجد جميع البيانات التي تبحث عنها.

#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];

    }
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top