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

Vision Framework 入門

Vision Framework 入門

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

Motoki Narita

August 09, 2017
Tweet

More Decks by Motoki Narita

Other Decks in Technology

Transcript

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

    Requests VNDetectBarcodesRequest VNDetectFaceLandmarksRequest VNDetectFaceRectanglesRequest … Observations VNClassificationObservation VNDetectedObjectObservation VNFaceObservation … RequestHandler VNImageRequestHandler
  2. Analyzing an Image The Machinery The Results The Asks Requests

    VNDetectBarcodesRequest VNDetectFaceLandmarksRequest VNDetectFaceRectanglesRequest … Observations VNClassificationObservation VNDetectedObjectObservation VNFaceObservation … RequestHandler VNImageRequestHandler IUUQTEFWFMPQFSBQQMFDPNWJEFPTQMBZXXEDΑΓ
  3. Analyzing an Image The Machinery The Results The Asks Requests

    VNDetectBarcodesRequest VNDetectFaceLandmarksRequest VNDetectFaceRectanglesRequest … Observations VNClassificationObservation VNDetectedObjectObservation VNFaceObservation … RequestHandler VNImageRequestHandler IUUQTEFWFMPQFSBQQMFDPNWJEFPTQMBZXXEDΑΓ
  4. 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 } } }) }()
  5. 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 } } }) }()
  6. 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 } } }) }()
  7. 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
  8. 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