Pratical AI and Vision

Lea Marie mairet bede
2 min readJan 13, 2023

--

This is really about the code and making the applications follow me into thi journey that might give you the envy to do some applications…

What we are going to it is an application with

Face Detection

Barcode Detection

Saliency Detection

Image Similarity

Image Classification

Drawing Recognition

Style Classification

1- Open X code

2- For this you would need to open Xcode Chosing the Single View APP

3- File Menu > New> File = Adding a new face swift to the project Faces.swift

Import UI Kits.

Import Vision

4- Follow the imports add the following extension on UI image.

Extension UI image {

Func DetectFaces( completion: @escaping ( [ VN FaceObservation]?) ()0

{ guard let image= self.cgImage else { return completion(nil) }

DispatchQueu.global () .async {

let handler = VNImageRequestHandler (

cgImage: image,

orientation: self.cfImageOrientation

)

try? handler.perform ([request])

guard let observations = request.results.as? [CNFaceObservation] {

}

Completion (observations)

}
}

}

}

Next > create a new file calles Views.swift witch we use to define some swift elements in our App.

1- import Swift UI & add a new view Struct called TwoStateButton:

struct.twoStateButton:View{

private let text: String

private let disable: bool

private let background : color

private let action : () -> Void

and then …

How to make the UI KIT frame work within Swift UI

--

--

Lea Marie mairet bede
Lea Marie mairet bede

Written by Lea Marie mairet bede

Hello There! I am a product designer and mostly it is what I believe I can change the world though my design and ideas

No responses yet