New iPhone Camera Hack!

0b8ad408b31cb9d5cff2828086c65d58?s=47 temoki
October 01, 2016

New iPhone Camera Hack!

Mobile Act NAGOYA #2 の LT 資料
https://mobileactnagoya.connpass.com/event/38805/

- iPhone 7 Plus Dual Camera
- iOS 10 camera API

0b8ad408b31cb9d5cff2828086c65d58?s=128

temoki

October 01, 2016
Tweet

Transcript

  1. None
  2. None
  3.  ➓

  4. None
  5. None
  6. AVCaptureDeviceDiscoverySession let discoverySession = AVCaptureDeviceDiscoverySession( deviceTypes: [.builtInDuoCamera], mediaType: AVMediaTypeVideo, position:

    .back) let devices: [AVCaptureDevice]? = discoverySession?.devices
  7. AVCaptureDeviceType .builtInWideAngleCamera .builtInTelephotoCamera .builtInDuoCamera

  8. None
  9. None
  10. .builtInDuoCamera

  11. .builtInTelephotoCamera .builtInTelephotoCamera let captureSession = AVCaptureSession() captureSession.addInput(wideAngleCameraDevice) captureSession.addInput(telephotoCameraDevice)

  12. None
  13. AVCaptureStillImageOutput AVCapturePhotoOutput

  14. None
  15. None
  16. None
  17. UIImagePickerController AVFoundation AVCapturePhotoOutput

  18. AVCapturePhotoOutput let types = photoOutput.availableRawPhotoPixelFormatTypes let type = types.first!.uint32Value let

    settings = AVCapturePhotoSettings(rawPixelFormatType: type) photoOutput.capturePhoto(with: settings, delegate: self)
  19. AVCapturePhotoCaptureDelegate rawSampleBuffer: CMSampleBuffer? func capture(_ captureOutput: AVCapturePhotoOutput, didFinishProcessingRawPhotoSampleBuffer rawSampleBuffer: CMSampleBu

    previewPhotoSampleBuffer: CMSampleBuffer?, resolvedSettings: AVCaptureResolvedPhotoSettings, bracketSettings: AVCaptureBracketedStillImageSettings?, error: Error?) { }
  20. CVPixelBuffer “rgg4” kCVPixelFormatType_14Bayer_RGGB // CVPixelBuffer? let pixelBuffer = CMSampleBufferGetImageBuffer(rawSampleBuffer!)

  21. // Data? let data = AVCapturePhotoOutput.dngPhotoDataRepresentation( forRawSampleBuffer: rawSampleBuffer!, previewPhotoSampleBuffer: previewPhotoSampleBuffer)

  22. import CoreImage.framework CIFilter CIFilter CIImage let rawFilter = CIFilter(imageURL: rawURL,

    options: nil) // Noise Reduction let nrKey = kCIInputLuminanceNoiseReductionAmountKey if let nr = rawFilter?.value(forKey: nrKey) { rawFilter.setValue(nr.doubleValue + 0.1, forKey: nrKey) } let image: CIImage? = rawFilter?.outputImage // ‐> CGImage, UIImage, JPEG, ...