What is CVBuffer/ROPPONGI.swift

3e66b3ccfa617b78c59d9dec865aa29f?s=47 noppefoxwolf
December 27, 2018

What is CVBuffer/ROPPONGI.swift

3e66b3ccfa617b78c59d9dec865aa29f?s=128

noppefoxwolf

December 27, 2018
Tweet

Transcript

  1. $7#V⒎FSͷ࿩ 30110/(*TXJGUୈճ๬೥ձ 

  2. OPQQF ! 1PDPDIBJ04ΤϯδχΞ " ͖ͭͶ͔Θ͍͍ # 30110/(*TXJGUॳࢀઓ $ J04%$ͰඳըपΓͷ࿩Λ͠·͠ ͨW

    
  3. 

  4. ಈըΛѻ͏ػձͷ૿Ճ w ಈը഑৴ΞϓϦ΍IFWDͷొ৔ɺ$PSF7JEFPʹ৮ΕΔػ ձ͕૿͍͑ͯΔ w σʔλ΍ϝσΟΞΛѻ͏#V⒎FSܥΫϥεͷར༻ස౓͸ ૿Ճ w ΈΜͳɺؾ࣋ͪͰ$71JYFM#V⒎FSΛ࢖͍ͬͯ·ͤΜ͔ʁ 

  5. #V⒎FSܥΫϥεͷۙگ w ݹ͍ΫϥεͳͷͰɺ΄΅มߋ͸ͳ͍ w ͔͠͠؀ڥ͸มԽɺΫϥΠΞϯτͰͷσίʔυ΍ 0QFO(-&4΍.FUBM΁ͷσʔλ౉͠ʹར༻͞ΕΔ 

  6. $7#V⒎FS 

  7. $7#V⒎FS w $7#V⒎FSͷ$7͸$PSF7JEFPͷ$7 σʔλόοϑΝΛ௚઀৮Βͣʹ؆୯ʹಡΈॻ͖͢Δͨ Ίͷ*' 

  8. 

  9. ୅දతͳ$7#V⒎FSͷ೿ੜ w $7*NBHF#V⒎FS w $71JYFM#V⒎FS w $70QFO(-&45FYUVSF 

  10. $7#V⒎FS͡Όͳ͍ํ w $.4BNQMF#V⒎FS ͜Ε͸ҧ͏ w $.#MPDL#V⒎FS ͜Ε΋ҧ͏ 

  11. ͲΜͳ࣌ʹऔಘͰ͖Δ΋ͷ͔ DJ*NBHFQJYFM#V⒎FS@d ͱ͔ MFUJC$.4BNQMF#V⒎FS(FU*NBHF#V⒎FS TC 

  12. $7#V⒎FSͷਖ਼ମ w $7*NBHF#V⒎FS public typealias CVImageBuffer = CVBuffer w $71JYFM#V⒎FS

    public typealias CVPixelBuffer = CVImageBuffer w $70QFO(-&45FYUVSF public typealias CVOpenGLESTexture = CVImageBuffer 
  13. $71JYFM#V⒎FSWT$7*NBHF#V⒎FS w 2UZQFBMJBTͳΜͩ͠ಉ͡Ͱ͠ΐʁ w "Զʹ΋Θ͔ΒΜ 

  14. $71JYFM#V⒎FSWT$7*NBHF#V⒎FS w $71JYFM#VGGFS ϝϞϦ಺ͷϐΫηϧόοϑΝʹΞΫηε͢ΔͨΊͷΫϥ ε w $7*NBHF#VGGFS ϝϞϦ಺ͷը૾ʹΞΫηε͢ΔͨΊͷΫϥε 

  15. ϐΫηϧ৘ใΞΫηεͷྫ w ॎԣͷαΠζ w σʔλαΠζ ը૾ΞΫηεͷྫ w Χϥʔεϖʔε 

  16. υΩϡϝϯτ $7*NBHF#VGGFS(FU%JTQMBZ4J[F @ "$(4J[FTUSVDUVSFEFpOJOHUIFOPNJOBMEJTQMBZ TJ[FPGUIFCV⒎FS3FUVSOT[FSPTJ[FJGDBMMFE XJUIBOPO$7*NBHF#VGGFS3FGUZQFPS /6-- 

  17. ݕূ var pb: CVPixelBuffer? = nil CVPixelBufferCreate(kCFAllocatorDefault, 128, 128, kCVPixelFormatType_32BGRA,

    nil, &pb) CVImageBufferGetDisplaySize(pb!) // -> (128.0, 128.0) 
  18. ಈըΛѻ͏ػձͷ૿Ճ w ಈը഑৴ΞϓϦ΍IFWDͷొ৔ɺ$PSF7JEFPʹ৮ΕΔػ ձ͕૿͍͑ͯΔ w σʔλ΍ϝσΟΞΛѻ͏#V⒎FSܥΫϥεͷར༻ස౓͸ ૿Ճ w ΈΜͳɺؾ࣋ͪͰ$71JYFM#V⒎FSΛ࢖͍ͬͯ·ͤΜ͔ʁ 

  19. ؾ࣋ͪͰ࢖͍ͬͯΔ 

  20. 6**NBHFͱͷҧ͍ 

  21. 6**NBHFͱͷҧ͍ w $7#V⒎FS ΞυϨεΛࢀর͍ͯ͠Δ͚ͩͳͷͰɺϩοΫ͸͢Δ͕ ίϐʔ΍Ωϟογϡ͸͞Εͳ͍ தؒϨϯμϦϯά΋উखʹ͞Εͳ͍ ϏσΦͷΑ͏ʹߴ଎ʹॲཧ͢Δඞཁ͕͋ΔՕॴʹ࠷ద 

  22. ΞυϨεͷϩοΫ $7#V⒎FSͷσʔλόοϑΝʹ$16͔ΒΞΫηε͢Δ ৔߹͸ΞυϨεΛϩοΫ͢Δඞཁ͕͋Δ CVPixelBufferLockBaseAddress(pb, .readOnly) defer { CVPixelBufferUnlockBaseAddress(pb, .readOnly) }

    
  23. $71JYFM#V⒎FSͷத਎Λදࣔ͢Δ 

  24. Ұ൪؆୯ͳํ๏ $71JYFM#V⒎FS$**NBHF6**NBHF CIImage(cvPixelBuffer: CVPixelBuffer) UIImage(ciImage: ciImage) 

  25. .FUBMͰදࣔ͢Δ CVMetalTextureCacheܦ༝Ͱ $71JYFM#V⒎FS.5-5FYUVSF .5,7JFXͳͲͰදࣔ 

  26. 0QFO(-&4Ͱදࣔ͢Δ CVOpenGLESTextureCacheܦ༝Ͱ $71JYFM#V⒎FS0QFO(-&45FYUVSF (-,7JFXͳͲͰදࣔ 

  27. $.4BNQMF#V⒎FSͱ͸ 

  28. 

  29. $.4BNQMF#V⒎FSͱ͸ ɾඞͣ͠΋$71JYFM#V⒎FS͕ೖ͍ͬͯΔͱ͸ݶΒͳ͍ 

  30. ࿩ͦ͏ͱࢥ͍ͬͯͨ࿩୊ ɾ$71JYFM#V⒎FS͔Β$.4BNQMF#V⒎FSΛ࡞Δ࿩ ɾϢʔεέʔε ɾར఺ 

  31.