Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Depth APIで簡易クロマキー合成 #geek_garage_ios/depth_api_...

fromkk
June 27, 2017

Depth APIで簡易クロマキー合成 #geek_garage_ios/depth_api_ios11_20170627

GEEK GARAGE iOS vol3で発表したiOS 11から利用出来るDepth APIについて

fromkk

June 27, 2017
Tweet

More Decks by fromkk

Other Decks in Programming

Transcript

  1. More info about HEIF — 503 Introducing HEIF and HEVC

    — 513 High Efficiency Image File Format 16
  2. Disparityը૾ͷऔಘ — طʹࡱӨͨࣸ͠ਅ͔Βऔಘ — PhotoKitΛར༻ let asset: PHAsset = ...

    asset.requestContentEditingInput(with: nil) { (input, info) in guard let imageURL: URL = input?.fullSizeImageURL else { return } if let disparityImage: CIImage = CIImage(contentsOf: imageURL, options: [kCIImageAuxiliaryDisparity: true]) { self.disparityImageView.image = UIImage(ciImage: disparityImage) } } 17
  3. ͪͳΈʹ self.asset.requestContentEditingInput(with: nil) { (input, info) in guard let imageURL:

    URL = input?.fullSizeImageURL else { return } guard let source = CGImageSourceCreateWithURL(imageURL as CFURL, nil) else { return } guard let sourceProperties = CGImageSourceCopyProperties(source, nil) else { return } print(sourceProperties) } ͱ͢Ε͹ 18
  4. { "{FileContents}" = { ImageCount = 1; Images = (

    { AuxiliaryData = ( { AuxiliaryDataType = kCGImageAuxiliaryDataTypeDisparity; Height = 768; Width = 576; } ); } ); }; } ͱ͍ͬͨ৘ใ͕औಘग़དྷΔ 19
  5. ը૾߹੒ͯ͠ΈΔ let ciImage: CIImage = CIImage(image: image) let wallImage: UIImage

    = #imageLiteral(resourceName: "wall") guard let wallCIImage: CIImage = CIImage(image: wallImage) else { return } let maskedImage: CIImage = ciImage.applyingFilter("CIBlendWithMask", withInputParameters: [ kCIInputBackgroundImageKey: wallCIImage, kCIInputMaskImageKey: disparityImage.applyingFilter("CIColorClamp", withInputParameters: nil), ]) self.disparityImageView.image = UIImage(ciImage: maskedImage) 20
  6. ը૾ௐ੔ CIColorMatrix Λར༻ͯ͠άϨʔͷೱ͞Λௐ੔ let maskImage = disparityImage.applyingFilter("CIColorMatrix", withInputParameters: [ "inputRVector"

    : CIVector(x: value, y: 0, z: 0, w: 0), "inputGVector" : CIVector(x: 0, y: value, z: 0, w: 0), "inputBVector" : CIVector(x: 0, y: 0, z: value, w: 0), "inputBiasVector" : CIVector(x: bias, y: bias, z: bias, w: 0)]) 21