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

What is CVBuffer/ROPPONGI.swift

noppefoxwolf
December 27, 2018

What is CVBuffer/ROPPONGI.swift

noppefoxwolf

December 27, 2018
Tweet

More Decks by noppefoxwolf

Other Decks in Programming

Transcript

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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


    View full-size slide

  9. $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

    View full-size slide

  10. $71JYFM#V⒎FSWT$7*NBHF#V⒎FS
    w 2UZQFBMJBTͳΜͩ͠ಉ͡Ͱ͠ΐʁ
    w "Զʹ΋Θ͔ΒΜ

    View full-size slide

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

    View full-size slide

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

    View full-size slide

  13. υΩϡϝϯτ
    $7*NBHF#VGGFS(FU%JTQMBZ4J[F @

    "$(4J[FTUSVDUVSFEFpOJOHUIFOPNJOBMEJTQMBZ
    TJ[FPGUIFCV⒎FS3FUVSOT[FSPTJ[FJGDBMMFE
    XJUIBOPO$7*NBHF#VGGFS3FGUZQFPS
    /6--

    View full-size slide

  14. ݕূ
    var pb: CVPixelBuffer? = nil
    CVPixelBufferCreate(kCFAllocatorDefault,
    128, 128,
    kCVPixelFormatType_32BGRA, nil, &pb)
    CVImageBufferGetDisplaySize(pb!)
    // -> (128.0, 128.0)

    View full-size slide

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

    View full-size slide

  16. ؾ࣋ͪͰ࢖͍ͬͯΔ

    View full-size slide

  17. 6**NBHFͱͷҧ͍

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide