All Projects → gunapandianraj → Ios11 Visionframework

gunapandianraj / Ios11 Visionframework

Licence: mit
Vision Framework IOS WWDC 2017

Programming Languages

swift
15916 projects

Projects that are alternatives of or similar to Ios11 Visionframework

Amazon Sagemaker Examples
Example 📓 Jupyter notebooks that demonstrate how to build, train, and deploy machine learning models using 🧠 Amazon SageMaker.
Stars: ✭ 6,346 (+7365.88%)
Mutual labels:  learning, machine
Mex Vocabulary
MEX Vocabulary: a lightweight machine learning interchange format
Stars: ✭ 19 (-77.65%)
Mutual labels:  learning, machine
Hungabunga
HungaBunga: Brute-Force all sklearn models with all parameters using .fit .predict!
Stars: ✭ 614 (+622.35%)
Mutual labels:  learning, machine
Moviebox
Machine learning movie recommending system
Stars: ✭ 504 (+492.94%)
Mutual labels:  learning, machine
Photoassessment
Photo Assessment using Core ML and Metal.
Stars: ✭ 40 (-52.94%)
Mutual labels:  face-detection, image-analysis
Sklearn Classification
Data Science Notebook on a Classification Task, using sklearn and Tensorflow.
Stars: ✭ 518 (+509.41%)
Mutual labels:  learning, machine
Awesome Machine Learning
🎰 A curated list of machine learning resources, preferably CoreML
Stars: ✭ 716 (+742.35%)
Mutual labels:  learning, machine
pigallery
PiGallery: AI-powered Self-hosted Secure Multi-user Image Gallery and Detailed Image analysis using Machine Learning, EXIF Parsing and Geo Tagging
Stars: ✭ 35 (-58.82%)
Mutual labels:  face-detection, image-analysis
Rapping Neural Network
Rap song writing recurrent neural network trained on Kanye West's entire discography
Stars: ✭ 951 (+1018.82%)
Mutual labels:  learning, machine
Cryptoinscriber
📈 A live cryptocurrency historical trade data blotter. Download live historical trade data from any cryptoexchange, be it for machine learning, backtesting/visualizing trading strategies or for Quantopian/Zipline.
Stars: ✭ 27 (-68.24%)
Mutual labels:  learning, machine
Sharplearning
Machine learning for C# .Net
Stars: ✭ 294 (+245.88%)
Mutual labels:  learning, machine
Ludwig
Data-centric declarative deep learning framework
Stars: ✭ 8,018 (+9332.94%)
Mutual labels:  learning, machine
lobe
Lobe is the world's first AI paralegal.
Stars: ✭ 22 (-74.12%)
Mutual labels:  learning, machine
Machine Learning Mindmap
A mindmap summarising Machine Learning concepts, from Data Analysis to Deep Learning.
Stars: ✭ 5,339 (+6181.18%)
Mutual labels:  learning, machine
simple-image-classifier
Simple image classifier microservice using tensorflow and sanic
Stars: ✭ 22 (-74.12%)
Mutual labels:  learning, machine
Deepj
A deep learning model for style-specific music generation.
Stars: ✭ 681 (+701.18%)
Mutual labels:  learning, machine
Machine Learning For Learning Resources
This ebook from Jason Brownlee. Educational perpose only! Thanks to Jason for the books.
Stars: ✭ 221 (+160%)
Mutual labels:  learning, machine
google-vision-sampler
Code examples for Google Vision API.
Stars: ✭ 47 (-44.71%)
Mutual labels:  face-detection, text-detection
Pytorch Forecasting
Time series forecasting with PyTorch
Stars: ✭ 849 (+898.82%)
Mutual labels:  learning, machine
Gpt2 Telegram Chatbot
GPT-2 Telegram Chat bot
Stars: ✭ 41 (-51.76%)
Mutual labels:  learning, machine

iOS-Vision Framework - Intro

N|Solid N|Solid N|Solid

Intro To Vision :

Vision was introduced in 2017 WWDC along with list of other machine learning frameworks apple released (Core ML,NLP).Vision can be used on both image as well as sequences of image (videos).We can also integrate vision with Core ML Models for example it can used to give Core ML required input parameters example for MINST image classification we can detect numbers as rect in image using vision and send it Core ML model for prediction. Check the WWDC Video

Vision Main Features

  • Face Detection and Recognition
  • Machine Learning Image Analysis
  • Barcode Detection
  • Image Alignment Analysis
  • Text Detection
  • Horizon Detection
  • Object Detection and Tracking

Project Overview

In this project we are gonna look into simple image analysis techniques like marking Rectangle objects,faces ,text boxes,Char on texts

For performing any image analysis operation we need follow this three step process

  • Create a Vision Image Request

  • Create a Image Request Handler

  • Assigning Image Requests To Request handler


Face Detection


N|Solid N|Solid

  • Creating face detection request
   lazy var faceDetectionRequest : VNDetectFaceRectanglesRequest = {
        let faceRequest = VNDetectFaceRectanglesRequest(completionHandler:self.handleFaceDetection)
        return faceRequest
    }()
  • Create a image request handler
        let handler = VNImageRequestHandler(ciImage: ciImage, orientation: Int32(uiImage.imageOrientation.rawValue))
  • Assigning image requests to request handler
     try handler.perform([self.faceDetectionRequest])
  • Handler code
         func handleFaceDetection (request: VNRequest, error: Error?) {
        guard let observations = request.results as? [VNFaceObservation]
            else { print("unexpected result type from VNFaceObservation")
                return }
        guard observations.first != nil else {
            return
        }
        // Show the pre-processed image
        DispatchQueue.main.async {
            self.analyzedImageView.subviews.forEach({ (s) in
                s.removeFromSuperview()
            })
            for face in observations
            {
                let view = self.CreateBoxView(withColor: UIColor.red)
                view.frame = self.transformRect(fromRect: face.boundingBox, toViewRect: self.analyzedImageView)
                self.analyzedImageView.image = self.originalImageView.image
                self.analyzedImageView.addSubview(view)
                self.loadingLbl.isHidden = true
                
            }
        }
    }
  • Converting vision rect to uikit rect

    one main thing to keep in mind that vision rect values are different from others

    Vision: origin ---> bottom left

    Size ---> Max value of 1

    UIkit : origin ---> top left

    Size ---> UIVIEW bounds

       //Convert Vision Frame to UIKit Frame
      func transformRect(fromRect: CGRect , toViewRect :UIView) -> CGRect {
          
          var toRect = CGRect()
          toRect.size.width = fromRect.size.width * toViewRect.frame.size.width
          toRect.size.height = fromRect.size.height * toViewRect.frame.size.height
          toRect.origin.y =  (toViewRect.frame.height) - (toViewRect.frame.height * fromRect.origin.y )
          toRect.origin.y  = toRect.origin.y -  toRect.size.height
          toRect.origin.x =  fromRect.origin.x * toViewRect.frame.size.width
          
          return toRect
      }
      
    
  • Box view

For drawing rectangle box around our detection

      func CreateBoxView(withColor : UIColor) -> UIView {
        let view = UIView()
        view.layer.borderColor = withColor.cgColor
        view.layer.borderWidth = 2
        view.backgroundColor = UIColor.clear
        return view
    }

CHAR DETECTION


N|Solid N|Solid

  • Creating char detection request

          lazy var textRectangleRequest: VNDetectTextRectanglesRequest = {
          let textRequest = VNDetectTextRectanglesRequest(completionHandler: self.handleTextIdentifiaction)
          textRequest.reportCharacterBoxes = true
          return textRequest
      }()
    
  • Create a image request handler

          let handler = VNImageRequestHandler(ciImage: ciImage, orientation: Int32(uiImage.imageOrientation.rawValue))
    
  • Assigning image requests to request handler

         try handler.perform([self.textRectangleRequest])
    
  • Handler code

        func handleTextIdentifiaction (request: VNRequest, error: Error?) {
        
        guard let observations = request.results as? [VNTextObservation]
            else { print("unexpected result type from VNTextObservation")
                return
            }
        guard observations.first != nil else {
            return
        }
        DispatchQueue.main.async {
            self.analyzedImageView.subviews.forEach({ (s) in
                s.removeFromSuperview()
            })
            for box in observations {
                guard let chars = box.characterBoxes else {
                    print("no char values found")
                    return
                }
                for char in chars
                {
                    let view = self.CreateBoxView(withColor: UIColor.green)
                    view.frame = self.transformRect(fromRect: char.boundingBox, toViewRect: self.analyzedImageView)
                    self.analyzedImageView.image = self.originalImageView.image
                    self.analyzedImageView.addSubview(view)
                    self.loadingLbl.isHidden = true
                }
            }
        }
        
    }  
    

RECTANGLE DETECTION


N|Solid

  • Creating rectangle detection request
       lazy var rectangleBoxRequest: VNDetectRectanglesRequest = {
      return VNDetectRectanglesRequest(completionHandler:self.handleRectangles)
  }()
  • Create a image request handler

          let handler = VNImageRequestHandler(ciImage: ciImage, orientation: Int32(uiImage.imageOrientation.rawValue))
    
  • Assigning image requests to request handler

          try handler.perform([self.rectangleBoxRequest])
    
  • Handler code

         func handleRectangles(request: VNRequest, error: Error?) {
        
        guard let observations = request.results as? [VNRectangleObservation]
            else { print("unexpected result type from VNDetectRectanglesRequest")
                    return
        }
        guard observations.first != nil else {
            return
        }
        // Show the pre-processed image
        DispatchQueue.main.async {
            self.analyzedImageView.subviews.forEach({ (s) in
                s.removeFromSuperview()
            })
            for rect in observations
            {
                let view = self.CreateBoxView(withColor: UIColor.cyan)
                view.frame = self.transformRect(fromRect: rect.boundingBox, toViewRect: self.analyzedImageView)
                self.analyzedImageView.image = self.originalImageView.image
                self.analyzedImageView.addSubview(view)
                self.loadingLbl.isHidden = true
            }
        }
    }
    

You can also group Requests and Perform analysis


    handler.perform([self.textRectangleRequest,self.faceDetectionRequest,self.rectangleBoxRequest])

Here am performing text,face and rectangle box analysis on a single input

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].