DoreSegment
Getting Started
The following instructions will guide you on how to implement the DoreSegment SDK on a specific platform.
IOS
Technical Specifications:
Xcode | 11.3 or Above |
IOS Version | 12.0 or Above |
Supported Device | iPhone6s or Above |
You can implement DoreSegment SDK in your existing/new IOS Xcode project with in just 3 Steps
Step 1:
1. Add this line in your pod file
pod 'DoreSegment'
2. Run pod install, and open project
pod install
3. If xcode version 12 or above, Select "Target" - > "General" -> "Framework" Click plus (Add) icon and choose Frameworks "DoreCoreAI.xcframework" and "DoreSegment.xcframework". make sure to select "Embed & Sign" option
Step 2:
Initiate DoreSegment Manager
private var modelManager: SegmentManager?
modelManager = SegmentManager()
//load license
let isValid:Bool = (modelManager?.init_data(licKey: "insert your license key here") ?? false)
Step 3:
Execute Segment Session with input image
//run and get result
let result:segmentOut = segmentOut ( features: (self.modelManager?.run_model(onFrame: pixelBuffer))! )
//mask image Black - bacground, White - foreground
let ciImage:UIImage = getMaskBW(result.semanticPredictions)!
Get Transparent segment output image
//run model and get result
let result:segmentOut = segmentOut ( features: (self.modelManager?.run_model(onFrame: pixelBuffer))! )
//mask image White - bacground, Black - foreground
let ciImage:UIImage = getMaskWB(result.semanticPredictions)!
//extract image
let rgbCIimage:CIImage = CIImage.init(cvPixelBuffer: pixelBuffer)
let rgbImage:UIImage = convertCItoUIimage(cmage: rgbCIimage)
let finalImage:UIImage = cutoutmaskImage(image: rgbImage, mask: ciImage)
DispatchQueue.main.async {
self.maskoutView.image = finalImage
}
DoreSegmentLite (Lite Version SDK)
DoreSegmentLite is used for reducing app size, all support and library files will be downloaded at runtime (Internet connection required).
Total SDK size will be 1.2MB Max
How to use :
Step 1:
1. Add this line in your pod file
pod 'DoreSegmentLite'
2. Run pod install, and open project
pod install
3. If xcode version 12 or above, Select "Target" - > "General" -> "Framework". Click plus (Add) icon and choose Frameworks "DoreCoreAI.xcframework". make sure to select "Embed & Sign" option
Step 2:
Add "SegmentLiteDelegate" in your view controller
class ImageSegment: UIViewController, SegmentLiteDelegate {
Initiate SegmentLiteManager
private var modelManager: SegmentLiteManager!
modelManager = SegmentLiteManager()
modelManager?.delegate = self
//Load license / start initiating
self.modelManager?.init_data(licKey: "insert your license key here")
Library file will be download at runtime when you initiate "SegmentLiteManager", it will be download and placed in app internal storage, you can get download completion signal through DoreSegmentLiteDelegate callback, use some progress indicator until download completion. this download progress will be processed only on first time, it will load with app internal storage location from second time load.
//===DoreSegmentLiteDelegate===
func onSegmentLiteSuccess(_ info: String) {
self.alertView.dismiss(animated: true, completion: nil)
//DoreSegment Library files downloaded successfully...! Ready to run segment
}
func onSegmentLiteFailure(_ error: String) {
self.alertView.dismiss(animated: true, completion: nil)
//DoreSegment Library files downloading failed..!
print(error)
}
func onSegmentLiteProgressUpdate(_ progress: String) {
//DoreSegment Library files downloading...!
print(progress)
self.progressView!.progress = Float(progress)!
}
func onSegmentLiteDownloadSpeed(_ dps: String) {
print(dps)
}
//==============================
Step 3:
Execute Segment Session with input image
//run and get result
let result:segmentOut = segmentOut ( features: (self.modelManager?.run_model(onFrame: pixelBuffer))! )
//mask image Black - bacground, White - foreground
let ciImage:UIImage = getMaskBW(result.semanticPredictions)!