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

Vision Framework 入門

Vision Framework 入門

potatotips #42 https://potatotips.connpass.com/event/60015/
※公開されている情報を元に構成されています

4239ea2bf38d7178476faa8787683105?s=128

Motoki Narita

August 09, 2017
Tweet

Transcript

  1. 7JTJPO'SBNFXPSLೖ໳ !NPUPLJFF QPUBUPUJQT

  2. ࣗݾ঺հ w HJUIVC UXJUUFS!NPUPLJFF w ϝϧΧϦι΢κ΢J04ΤϯδχΞ w ϝϧΧϦΧ΢ϧνʔϜ w J04%$+BQBOελοϑ

  3. 7JTJPO'SBNFXPSLͱ͸

  4. $PSF.-ͱ7JTJPOͷҧ͍͸ʁ

  5. ΞϓϦέʔγϣϯ 7JTJPO /-1 $PSF.- "DDFMFSBUF .14 IUUQTEFWFMPQFSBQQMFDPNWJEFPTQMBZXXEDΛࢀߟʹ࡞੒

  6. ΞϓϦέʔγϣϯ 7JTJPO /-1
 /BUVSBM-BOHVBHF1SPDFTTJOH $PSF.- "DDFMFSBUF .14 %PNBJO4QFDJpD ಛఆͷλεΫʹಛԽͨ͠ը૾ղੳͷͨΊͷϑϨʔϜϫʔΫ

  7. ΞϓϦέʔγϣϯ 7JTJPO /-1
 /BUVSBM-BOHVBHF1SPDFTTJOH $PSF.- "DDFMFSBUF .14 7JTJPO͸ը૾ղੳʹಛԽ͍ͯ͠Δ %PNBJO4QFDJpD

  8. ΞϓϦέʔγϣϯ 7JTJPO /-1
 /BUVSBM-BOHVBHF1SPDFTTJOH $PSF.- "DDFMFSBUF .14 %PNBJO4QFDJpD 7JTJPO͸$PSF.-͕ϕʔεʹͳ͍ͬͯΔ

  9. ΞϓϦέʔγϣϯ 7JTJPO /-1
 /BUVSBM-BOHVBHF1SPDFTTJOH $PSF.- "DDFMFSBUF .14 %PNBJO4QFDJpD ྡΓʹ͋Δ/-1͸'PVOEBUJPOʹ૊Έࠐ·Ε͍ͯͯɺ /4-JOHVJTUJD5BHHFSͳͲͰ࢖ΘΕ͍ͯΔͱͷ͜ͱ

  10. ࠓճ΍Γ͔ͨͬͨͷ͸ɺ 7JTJPOͰόʔίʔυΛݕग़͢Δ͜ͱ

  11. Barcode Detection IUUQTEFWFMPQFSBQQMFDPNWJEFPTQMBZXXEDΑΓ

  12. w 7JTJPOΛ࢖ͬͯόʔίʔυͷݕग़Λ͍ͨ͠ w ݁࿦͔Βݴ͏ͱ7JTJPO .-&YBNQMFͱ͍͏88%$ ͷηογϣϯͰ΋࢖ΘΕ͍ͯͨαϯϓϧΛݩʹػց ֶशͷ஌͕ࣝͳͯ͘΋͢ΜͳΓ7JTJPO͸ಈ͔͢͜ͱ ͕Ͱ͖ͨ w ͨͩ͠ͱ͍͏࿩Λ͢Δ

  13. ࣮૷ํ๏

  14. IUUQTEFWFMPQFSBQQMFDPNWJEFPTQMBZXXEDΑΓ Analyzing an Image The Machinery The Results The Asks

  15. IUUQTEFWFMPQFSBQQMFDPNWJEFPTQMBZXXEDΑΓ Analyzing an Image The Machinery The Results The Asks

    Requests VNDetectBarcodesRequest VNDetectFaceLandmarksRequest VNDetectFaceRectanglesRequest … Observations VNClassificationObservation VNDetectedObjectObservation VNFaceObservation … RequestHandler VNImageRequestHandler
  16. w ը૾͔ΒόʔίʔυΛݕग़ w 7/%FUFDU#BSDPEFT3FRVFTUΛ࢖ͬͯɺը૾͔Β όʔίʔυΛಡΈऔΔ

  17. Analyzing an Image The Machinery The Results The Asks Requests

    VNDetectBarcodesRequest VNDetectFaceLandmarksRequest VNDetectFaceRectanglesRequest … Observations VNClassificationObservation VNDetectedObjectObservation VNFaceObservation … RequestHandler VNImageRequestHandler IUUQTEFWFMPQFSBQQMFDPNWJEFPTQMBZXXEDΑΓ
  18. let handler = VNImageRequestHandler(ciImage: ciImage, orientation: orientation) try! handler.perform([barcodeClassificationRequest])

  19. w ը૾͔Βόʔίʔυͷ*4#/ίʔυΛऔΓग़͢

  20. Analyzing an Image The Machinery The Results The Asks Requests

    VNDetectBarcodesRequest VNDetectFaceLandmarksRequest VNDetectFaceRectanglesRequest … Observations VNClassificationObservation VNDetectedObjectObservation VNFaceObservation … RequestHandler VNImageRequestHandler IUUQTEFWFMPQFSBQQMFDPNWJEFPTQMBZXXEDΑΓ
  21. lazy var barcodeClassificationRequest: VNDetectBarcodesRequest = { return VNDetectBarcodesRequest(completionHandler: { request,

    error in guard let observations = request.results as? [VNBarcodeObservation] else { return } let rects = observations.map { $0.boundingBox } DispatchQueue.main.async { [weak self] in for rect in rects { let view = UIView(frame: convertedRect(rect: rect, to: self!.imageView.frame.size)) view.backgroundColor = .green self?.imageView.addSubview(view) } } let _ = observations.flatMap { observation -> CIBarcodeDescriptor? in if let desc = observation.barcodeDescriptor as? CIBarcodeDescriptor { return desc } else { return nil } } }) }()
  22. lazy var barcodeClassificationRequest: VNDetectBarcodesRequest = { return VNDetectBarcodesRequest(completionHandler: { request,

    error in guard let observations = request.results as? [VNBarcodeObservation] else { return } let rects = observations.map { $0.boundingBox } DispatchQueue.main.async { [weak self] in for rect in rects { let view = UIView(frame: convertedRect(rect: rect, to: self!.imageView.frame.size)) view.backgroundColor = .green self?.imageView.addSubview(view) } } let _ = observations.flatMap { observation -> CIBarcodeDescriptor? in if let desc = observation.barcodeDescriptor as? CIBarcodeDescriptor { return desc } else { return nil } } }) }()
  23. ͱΓ͋͑ͣͰ͖ͨ

  24. ͕ɺ

  25. όʔίʔυ͕Ͳ͜ʹ͋Δ͔͸Θ͔͚ͬͨͲɺ ಺༰ʢ&"/ίʔυʣ͸෼͔Βͳ͔ͬͨʜ

  26. lazy var barcodeClassificationRequest: VNDetectBarcodesRequest = { return VNDetectBarcodesRequest(completionHandler: { request,

    error in guard let observations = request.results as? [VNBarcodeObservation] else { return } let rects = observations.map { $0.boundingBox } DispatchQueue.main.async { [weak self] in for rect in rects { let view = UIView(frame: convertedRect(rect: rect, to: self!.imageView.frame.size)) view.backgroundColor = .green self?.imageView.addSubview(view) } } let _ = observations.flatMap { observation -> CIBarcodeDescriptor? in if let desc = observation.barcodeDescriptor as? CIBarcodeDescriptor { return desc } else { return nil } } }) }()
  27. w $*#BS$PEF%FTDSJQUPSͰ&"/ίʔυ͕औಘͰ͖Δ͸ ͣɺͱࢥ͍͕ͬͯͨɺͦΜͳ΋ͷ͸ͳ͔ͬͨ w $*#BS$PEF%FTDSJQUPS͸/40CKFDUͷαϒΫϥεͰ ಛʹԿ΋࣮૷͞Ε͍ͯͳ͍

  28. IUUQTEFWFMPQFSBQQMFDPNWJEFPTQMBZXXEDΑΓ Framework Barcode Support Several frameworks support various barcodes types

    AVFoundation.framework Vision.framework CoreImage.framework Detection of barcodes
 during capture Detection of barcodes
 after capture Rendering barcodes CIBarcodeDescriptor
  29. IUUQTEFWFMPQFSBQQMFDPNEPDVNFOUBUJPODPSFJNBHFDJCBSDPEFEFTDSJQUPS

  30. w ࣮૷͸$*#BS$PEF%FTDSJQUPSͷαϒΫϥεʹҕͶΒ Ε͍ͯͯɺ͍·ཉ͍͠΋ͷ&"/ίʔυʹରԠͨ͠ ΋ͷ͸ͳ͔ͬͨ IUUQTEFWFMPQFSBQQMFDPNEPDVNFOUBUJPODPSFJNBHFDJCBSDPEFEFTDSJQUPS

  31. w $*23$PEF%FTDSJQUPS w $*"[UFD$PEF%FTDSJQUPS w $*1%'$PEF%FTDSJQUPS w $*%BUB.BUSJY$PEF%FTDSJQUPS ରԠ͍ͯ͠Δ̎࣍ݩίʔυ

  32. Framework Barcode Support Several frameworks support various barcodes types AVFoundation.framework

    Vision.framework CoreImage.framework Detection of barcodes
 during capture Detection of barcodes
 after capture Rendering barcodes CIBarcodeDescriptor
  33. ·ͱΊ w 7JTJPOΛ࢖͏ͱόʔίʔυ͕ը૾ͷதʹ͋Δͱ͍͏ ͜ͱ͸෼͔Δ w ը໘্ͷͲ͜ʹ͋Δ͔ͷ࠲ඪ͸औΕΔͷͰɺؤுͬ ͯ&"/ίʔυม׵·Ͱ͸Ͱ͖Δ͸ͣ w IUUQTEFWFMPQFSBQQMFDPNWJEFPTQMBZ XXED

    UJNF
  34. ͓ΘΓ