LINE Creators Studioで写真を簡単 & きれいに切り抜いてもらいたい話 / Grabcut in LINE Creators Studio

LINE Creators Studioで写真を簡単 & きれいに切り抜いてもらいたい話 / Grabcut in LINE Creators Studio

2019/2/13に開催されたLINE Developer Meetup #50 in Fukuokaでの登壇資料です

53850955f15249a1a9dc49df6113e400?s=128

LINE Developers

February 13, 2019
Tweet

Transcript

  1. -*/&$SFBUPST4UVEJPͰ ࣸਅΛ؆୯ˍ͖Ε͍ʹ ੾Γൈ͍ͯ΋Β͍͍ͨ࿩ LINE Developer meetup #50 in Fukuoka -*/&'VLVPLB։ൃࣨഅݟ੣

    Feb 13, 2019
  2. അݟ੣ -*/&'VLVPLBגࣜձࣾ ։ൃ̏ࣨॴଐ UMAMI MAKOTO @umakoz -*/&$SFBUPST4UVEJPͰࣸਅΛ؆୯ˍ͖Ε͍ʹ੾Γൈ͍ͯ΋Β͍͍ͨ࿩ ›`z

  3. -*/&$SFBUPST4UVEJPͰࣸਅΛ؆୯ˍ͖Ε͍ʹ੾Γൈ͍ͯ΋Β͍͍ͨ࿩ LINE Creators Studio? ɾεϚʔτϑΥϯ͔Β-*/&ελϯϓ͕؆୯ʹ࡞ΕΔ ɾࡱͬͨࣸਅΛՃ޻ͯ͠ελϯϓʹͰ͖Δ ɾελϯϓͷ৹ࠪਃ੥΍ൢച͕Ͱ͖Δ ɹIUUQTDSFBUPSMJOFNFKBTUVEJP ಛ௃

  4. LINE Creators StudioͰͷSticker࡞ྫ -*/&$SFBUPST4UVEJPͰࣸਅΛ؆୯ˍ͖Ε͍ʹ੾Γൈ͍ͯ΋Β͍͍ͨ࿩ IUUQTDSFBUPSMJOFNFKBTUVEJP

  5. LINE Creators Studio Android ɾPure Kotlinʢwithout Libraryʣ ɾMVVM ɾDagger2, RxJava2,

    RxKotlin, RxLifecycle, 
 Retrofit2, OkHttp3, Glide, Realm, Anko, 
 Espresso, Mockito-Kotlin ߏ੒ -*/&$SFBUPST4UVEJPͰࣸਅΛ؆୯ˍ͖Ε͍ʹ੾Γൈ͍ͯ΋Β͍͍ͨ࿩
  6. History 7FS ೥݄೔ ϦϦʔεɺͳͧͬͯ੾Γൈ͖ػೳ 7FS ೥݄೔ ඇެ։ઃఆ 7FS ೥݄೔ ଟݴޠରԠʢӳޠɺλΠޠɺதࠃޠɺΠϯυωγΞޠʣ

    7FS ೥݄೔ ܗͰ੾Γൈ͖ػೳ 7FS ೥݄೔ ফ͠ΰϜػೳ 7FS ೥݄೔ σίϑϨʔϜػೳ 7FS ೥݄೔ 6*มߋ 7FS ೥݄೔ ࣗಈ੾Γൈ͖ػೳʢ"OESPJEʣ 7FS ೥݄೔ ΩϟϯϖʔϯࢀՃػೳ 7FS ೥݄೔ ࣗಈ੾Γൈ͖ػೳʢJ04ʣ -*/&$SFBUPST4UVEJPͰࣸਅΛ؆୯ˍ͖Ε͍ʹ੾Γൈ͍ͯ΋Β͍͍ͨ࿩
  7. History -*/&$SFBUPST4UVEJPͰࣸਅΛ؆୯ˍ͖Ε͍ʹ੾Γൈ͍ͯ΋Β͍͍ͨ࿩ 7FS ೥݄೔ ϦϦʔεɺͳͧͬͯ੾Γൈ͖ػೳ 7FS ೥݄೔ ඇެ։ઃఆ 7FS ೥݄೔

    ଟݴޠରԠʢӳޠɺλΠޠɺதࠃޠɺΠϯυωγΞޠʣ 7FS ೥݄೔ܗͰ੾Γൈ͖ػೳ 7FS ೥݄೔ফ͠ΰϜػೳ 7FS ೥݄೔σίϑϨʔϜػೳ 7FS ೥݄೔ 6*มߋ 7FS ೥݄೔ ࣗಈ੾Γൈ͖ػೳʢ"OESPJEʣ 7FS ೥݄೔ ΩϟϯϖʔϯࢀՃػೳ 7FS ೥݄೔ ࣗಈ੾Γൈ͖ػೳʢJ04ʣ
  8. ੾Γൈ͖ؔ࿈ଟ͗͢ʜ ɾͳͧͬͯ੾Γൈ͖ ɾܗͰ੾Γൈ͖ ɾফ͠ΰϜ ɾσίϑϨʔϜ ɾࣗಈ੾Γൈ͖ ؆୯ͳૢ࡞Ͱ͖Ε͍ʹ੾Γൈ͖͍ͨʂ -*/&$SFBUPST4UVEJPͰࣸਅΛ؆୯ˍ͖Ε͍ʹ੾Γൈ͍ͯ΋Β͍͍ͨ࿩

  9. ͳͧͬͯ੾Γൈ͖ ɾΠϝʔδͷԑΛͳͧͬͯ੾Γൈ͘ ɾύε্ͷ྘ͷ఺ΛҠಈͤ͞Δ͜ͱͰඍௐ੔͢Δ 7FSʙ ɾ௚ײత ௕ॴ ɾࡉ͔͍मਖ਼͕͠ʹ͍͘ ɾҰຊͷύεͰ͔͠੾Γൈ͚ͳ͍ ୹ॴ -*/&$SFBUPST4UVEJPͰࣸਅΛ؆୯ˍ͖Ε͍ʹ੾Γൈ͍ͯ΋Β͍͍ͨ࿩

  10. ܗͰ੾Γൈ͖ ɾԁ΍࢛֯ɺϋʔτɺ੕ͷܗΛબͿ ɾΠϝʔδΛҠಈ΍֦େॖখɺճసͤ͞Δ͜ͱͰඍௐ੔͢Δ 7FSʙ ɾ؆୯ ௕ॴ ɾ༻ҙ͞ΕͨܗͰ͔͠੾Γൈ͚ͳ͍ ୹ॴ -*/&$SFBUPST4UVEJPͰࣸਅΛ؆୯ˍ͖Ε͍ʹ੾Γൈ͍ͯ΋Β͍͍ͨ࿩

  11. ফ͠ΰϜ ɾফ͠ΰϜΛ͔͚ͨ෦෼͕ফ͑Δ ɾम෮ফ͠ΰϜΛ͔͚ͯ෦෼తʹΠϝʔδΛ໭͠ɺඍௐ੔͢Δ 7FSʙ ɾΤοδͷࡉ͔ͳௐ੔͕Ͱ͖Δ ɾෳ਺ͷύεͰ੾Γൈ͖Ͱ͖Δ ௕ॴ ɾ͖Ε͍ʹ੾Γൈ͘ʹ͸ख़࿅ͷٕͱ͕࣌ؒඞཁ ୹ॴ -*/&$SFBUPST4UVEJPͰࣸਅΛ؆୯ˍ͖Ε͍ʹ੾Γൈ͍ͯ΋Β͍͍ͨ࿩

  12. σίϑϨʔϜ ɾΠϝʔδΛσίϨʔγϣϯ͢ΔϑϨʔϜΛબͿ ɾΠϝʔδΛҠಈ΍֦େॖখɺճసͤ͞Δ͜ͱͰඍௐ੔͢Δ 7FSʙ ɾ௒؆୯ʹݟӫ͑ͷ͢Δελϯϓ͕࡞ΕΔ ௕ॴ ɾಉ͡Α͏ͳελϯϓ͕ྔ࢈͞ΕΔ ୹ॴ -*/&$SFBUPST4UVEJPͰࣸਅΛ؆୯ˍ͖Ε͍ʹ੾Γൈ͍ͯ΋Β͍͍ͨ࿩

  13. ࣗಈ੾Γൈ͖ ࠓɺྲྀߦΓͷػցֶशͱ͔࢖ͬͯ ελϯϓʹඞཁͳ෦෼Λ੾Γൈ͚ͳ͍ʁ -*/&$SFBUPST4UVEJPͰࣸਅΛ؆୯ˍ͖Ε͍ʹ੾Γൈ͍ͯ΋Β͍͍ͨ࿩ SFNPWFCH IUUQTXXXSFNPWFCH ػցֶश

  14. ࣗಈ੾Γൈ͖ ɾ'BDF%FUFDUPS ɾ.-,JUGPS'JSFCBTF ɾ:0-0 0CKFDU%FUFDUJPO -*/&$SFBUPST4UVEJPͰࣸਅΛ؆୯ˍ͖Ε͍ʹ੾Γൈ͍ͯ΋Β͍͍ͨ࿩ :0-0 IUUQTQKSFEEJFDPNEBSLOFUZPMP

  15. ࣗಈ੾Γൈ͖ ɾ.BTL3$// *NBHF4FHNFOUBUJPO -*/&$SFBUPST4UVEJPͰࣸਅΛ؆୯ˍ͖Ε͍ʹ੾Γൈ͍ͯ΋Β͍͍ͨ࿩ IUUQTBSYJWPSHQEGQEG

  16. ࣗಈ੾Γൈ͖ 5FOTPS'MPX`TMJHIUXFJHIUTPMVUJPOGPS NPCJMFBOEFNCFEEFEEFWJDFT IUUQTXXXUFOTPSGMPXPSHMJUF -*/&$SFBUPST4UVEJPͰࣸਅΛ؆୯ˍ͖Ε͍ʹ੾Γൈ͍ͯ΋Β͍͍ͨ࿩ 5FOTPS'MPX-JUF

  17. ࣗಈ੾Γൈ͖ ɾࣸਅͷҰ෦͚ͩΛ࢖͏ ɾਓ΍෺ͷશମͰ͸ͳ͘ɺҰ෦͚ͩʢإͱ͔ʣΛ࢖͏ ɹˠྖҬΛݕग़͢Δ͚ͩͰ͸ෆे෼ Ͳ͕͜ελϯϓʹద͍ͯ͠Δ͔Λݕग़Ͱ͖Δ͔ʁ -*/&$SFBUPST4UVEJPͰࣸਅΛ؆୯ˍ͖Ε͍ʹ੾Γൈ͍ͯ΋Β͍͍ͨ࿩ ελϯϓ࡞੒࣌ͷϢʔβʔχʔζ IUUQTDSFBUPSMJOFNFKBTUVEJP

  18. ࣗಈ੾Γൈ͖ ΠϝʔδͷपғΛͬ͘͟ΓͳͧΔ ࣗಈͰ੾Γൈ͍ͯ΋Β͏ ࣗಈͰ੾Γൈ͍ͯཉ͍͠෦෼ʹফ͠ΰϜΛ͔͚Δ ࣗಈͰ੾Γൈ͍ͯཉ͘͠ͳ͍෦෼ʹम෮ফ͠ΰϜΛ͔͚Δ ʙͷૢ࡞Λ܁Γฦͯ͠ඍௐ੔͢Δ 7FSʙ -*/&$SFBUPST4UVEJPͰࣸਅΛ؆୯ˍ͖Ε͍ʹ੾Γൈ͍ͯ΋Β͍͍ͨ࿩

  19. ࣗಈ੾Γൈ͖ ɾ؆୯Ͱ͖Ε͍ʹ੾Γൈ͚Δ ௕ॴ ɾૢ࡞͕ෳࡶͰ׳Ε͕ඞཁ ୹ॴ -*/&$SFBUPST4UVEJPͰࣸਅΛ؆୯ˍ͖Ε͍ʹ੾Γൈ͍ͯ΋Β͍͍ͨ࿩

  20. ࣗಈ੾Γൈ͖ ɾΠϝʔδͷલܠྖҬΛநग़͢Δ ɾ0QFO$7
 IUUQTPQFODWPSH (SBC$VU"MHPSJUIN -*/&$SFBUPST4UVEJPͰࣸਅΛ؆୯ˍ͖Ε͍ʹ੾Γൈ͍ͯ΋Β͍͍ͨ࿩

  21. -*/&$SFBUPST4UVEJPͰࣸਅΛ؆୯ˍ͖Ε͍ʹ੾Γൈ͍ͯ΋Β͍͍ͨ࿩ GrabCut Algorithm Ϣʔβʔ͕બ୒ͨ͠ൣғ͔ΒۣܗΛੜ੒ͯ͠ೖྗ͠ɺ
 ֎ଆ͸എܠʹ಺ଆ͸લܠʹͳΔɻ (..ʢࠞ߹Ψ΢εϞσϧʣͰલܠͱഎܠͷըૉ਺෼෍Λֶश͢Δɻ ϐΫηϧͷ৭৘ใΑΓલܠʗഎܠͰ͋Δ֬཰Λ༧ଌ͢ΔϞσϧΛ࡞Δɻ

  22. -*/&$SFBUPST4UVEJPͰࣸਅΛ؆୯ˍ͖Ε͍ʹ੾Γൈ͍ͯ΋Β͍͍ͨ࿩ GrabCut Algorithm http://www.cs.ru.ac.za/research/g02m1682/ Ϣʔβʔ͕બ୒ͨ͠ൣғ͔ΒۣܗΛੜ੒ͯ͠ೖྗ͠ɺ
 ֎ଆ͸എܠʹ಺ଆ͸લܠʹͳΔɻ (..ʢࠞ߹Ψ΢εϞσϧʣͰલܠͱഎܠͷըૉ਺෼෍Λֶश͢Δɻ ϐΫηϧͷ৭৘ใΑΓલܠʗഎܠͰ͋Δ֬཰Λ༧ଌ͢ΔϞσϧΛ࡞Δɻ ϞσϧΛ༻͍ͯϐΫηϧΛͭͳ͗άϥϑΛߏங͢Δɻ

  23. -*/&$SFBUPST4UVEJPͰࣸਅΛ؆୯ˍ͖Ε͍ʹ੾Γൈ͍ͯ΋Β͍͍ͨ࿩ GrabCut Algorithm http://www.cs.ru.ac.za/research/g02m1682/ Ϣʔβʔ͕બ୒ͨ͠ൣғ͔ΒۣܗΛੜ੒ͯ͠ೖྗ͠ɺ
 ֎ଆ͸എܠʹ಺ଆ͸લܠʹͳΔɻ (..ʢࠞ߹Ψ΢εϞσϧʣͰલܠͱഎܠͷըૉ਺෼෍Λֶश͢Δɻ ϐΫηϧͷ৭৘ใΑΓલܠʗഎܠͰ͋Δ֬཰Λ༧ଌ͢ΔϞσϧΛ࡞Δɻ ϞσϧΛ༻͍ͯϐΫηϧΛͭͳ͗άϥϑΛߏங͢Δɻ ϐΫηϧΛͭͳ͙ΤοδͷॏΈΛܭࢉ͢Δɻ

    ΤοδͷॏΈͷ૯࿨͕࠷খʹͳΔΑ͏ʹ੾அ͢Δɻ
  24. GrabCut Algorithm -*/&$SFBUPST4UVEJPͰࣸਅΛ؆୯ˍ͖Ε͍ʹ੾Γൈ͍ͯ΋Β͍͍ͨ࿩ http://www.cs.ru.ac.za/research/g02m1682/ Ϣʔβʔ͕બ୒ͨ͠ൣғ͔ΒۣܗΛੜ੒ͯ͠ೖྗ͠ɺ
 ֎ଆ͸എܠʹ಺ଆ͸લܠʹͳΔɻ (..ʢࠞ߹Ψ΢εϞσϧʣͰલܠͱഎܠͷըૉ਺෼෍Λֶश͢Δɻ ϐΫηϧͷ৭৘ใΑΓલܠʗഎܠͰ͋Δ֬཰Λ༧ଌ͢ΔϞσϧΛ࡞Δɻ ϞσϧΛ༻͍ͯϐΫηϧΛͭͳ͗άϥϑΛߏங͢Δɻ ϐΫηϧΛͭͳ͙ΤοδͷॏΈΛܭࢉ͢Δɻ

    ΤοδͷॏΈͷ૯࿨͕࠷খʹͳΔΑ͏ʹ੾அ͢Δɻ Ϣʔβʔʹิਖ਼ͷͨΊͷઢΛೖྗͯ͠΋Β͍ɺ࠶ͼܭࢉ͢Δɻ
  25. ࣗಈ੾Γൈ͖ͷ޻෉ (SBC$VUલʹબ୒ྖҬΛج४ͱ͠
 ը૾ΛτϦϛϯά͢Δɻ
 ˞എܠΛશࣦͯ͏ͱਫ਼౓͕མͪΔͷͰ
 ɹϚʔδϯΛ࢒͢ɻ ॲཧ଎౓ͷ޲্ τϦϛϯά -*/&$SFBUPST4UVEJPͰࣸਅΛ؆୯ˍ͖Ε͍ʹ੾Γൈ͍ͯ΋Β͍͍ͨ࿩

  26. ࣗಈ੾Γൈ͖ͷ޻෉ ϚʔΧʔͷαΠζΛ൒෼ʹͯ͠(SBC$VUΛ ࣮ߦ͢Δɻ ॲཧ଎౓ͷ޲্ -*/&$SFBUPST4UVEJPͰࣸਅΛ؆୯ˍ͖Ε͍ʹ੾Γൈ͍ͯ΋Β͍͍ͨ࿩

  27. ࣗಈ੾Γൈ͖ͷ޻෉ 3FOEFS4DSJQUΛ࢖͏
 "OESPJEͰ࠾༻͞Ε͍ͯΔ
 ϐΫηϧ୯ҐͷॲཧΛ
 ߴ଎ʹߦ͏ͨΊͷ4DSJQU ॲཧ଎౓ͷ޲্ -*/&$SFBUPST4UVEJPͰࣸਅΛ؆୯ˍ͖Ε͍ʹ੾Γൈ͍ͯ΋Β͍͍ͨ࿩ QSBHNBWFSTJPO  

    QSBHNBSTKBWB@QBDLBHF@OBNF DPNMJOFDPSQVTFSTUJDLFSST  ST@BMMPDBUJPOJOQVU*NBHF VJOU@U SFDU WPJE@@BUUSJCVUF@@ LFSOFM SPPU VDIBSJO VJOU@UY VJOU@U GMPBUBST6OQBDL$PMPS JO B JG B \ JG YSFDU<> \ SFDU<>Y ^
  28. ࣗಈ੾Γൈ͖ͷ޻෉ ݩը૾ͷେ͖͞Λҡ࣋ͨ͠··੾Γൈ͘
 ˞࠷ऴతʹ࡞Δͷ͸
 ɹελϯϓ º ͳͷͰɺ
 ɹେ͖͗͢Δ࣌͸ϦαΠζ ը࣭ͷ޲্ ݩը૾ σΟεϓϨΠ

    Ҡಈɺ֦େॖখɺճస Matrix Matrix -*/&$SFBUPST4UVEJPͰࣸਅΛ؆୯ˍ͖Ε͍ʹ੾Γൈ͍ͯ΋Β͍͍ͨ࿩
  29. ࣗಈ੾Γൈ͖ͷ޻෉ Τοδʹ΅͔͠Λ͔͚Δɻ
 ͨͩ͠ɺ΅͔ͨ͠ϚʔΧʔΛ(SBC$VUʹ࢖͏ͱ
 ਫ਼౓͕མͪΔͷͰɺσΟεϓϨΠ্͚ͩ΅͔͢ɻ ඒ͠͞ͷ޲্ -*/&$SFBUPST4UVEJPͰࣸਅΛ؆୯ˍ͖Ε͍ʹ੾Γൈ͍ͯ΋Β͍͍ͨ࿩

  30. ࣗಈ੾Γൈ͖ͷ޻෉ ϦΞϧλΠϜʹ΅͔͢ͱॲཧ͕஗͘ͳΔͷͰɺ
 ϚʔΧʔͷ֬ఆ࣌ʹ΅͔͢ɻ ඒ͠͞ͷ޲্ -*/&$SFBUPST4UVEJPͰࣸਅΛ؆୯ˍ͖Ε͍ʹ੾Γൈ͍ͯ΋Β͍͍ͨ࿩

  31. ࣗಈ੾Γൈ͖ ࣸਅΛ؆୯ˍ͖Ε͍ʹ੾Γൈ͍ͯ΋Β͍͍ͨʂ -*/&$SFBUPST4UVEJPͰࣸਅΛ؆୯ˍ͖Ε͍ʹ੾Γൈ͍ͯ΋Β͍͍ͨ࿩

  32. -*/&$SFBUPST4UVEJPͰࣸਅΛ؆୯ˍ͖Ε͍ʹ੾Γൈ͍ͯ΋Β͍͍ͨ࿩ IUUQTMJOFGVLVPLBDPKQKBDBSFFSFOHJOFFS

  33. 5IBOLZPV