A collection of easy-to-use image / video filters.
1, Add SemanticImage to your project as Swift Package with Swift Package Manager. Or just drag SemanticImage.swift to your project.
2, Import and initialize SemanticImage
import SemanticImage
let semanticImage = SemanticImage()
Requires iOS 14 or above
let maskImage:UIImage? = semanticImage.personMaskImage(uiImage: yourUIImage)
let swappedImage:UIImage? = semanticImage.swapBackgroundOfPerson(personUIImage: yourUIImage, backgroundUIImage: yourBackgroundUIImage)
let blurredPersonImage:UIImage? = semanticImage.personBlur(uiImage:UIImage, intensity:Float)
// Blur intensity: 0~100
let prominentMaskImage:UIImage? = semanticImage.saliencyMask(uiImage:image)
let backgroundSwapImage:UIImage? = semanticImage.saliencyBlend(objectUIImage: image, backgroundUIImage: bgImage)
let faceImage:UIImage? = semanticImage.faceRectangle(uiImage: image)
let bodyImage:UIImage? = semanticImage.humanRectangle(uiImage: image)
let faceImages:[UIImage] = semanticImage.faceRectangles(uiImage: image)
let bodyImages:[UIImage] = semanticImage.humanRectangles(uiImage: image)
let animalImage:UIImage? = semanticImage.animalRectangle(uiImage: image)
let animalImages:[UIImage] = semanticImage.animalRectangles(uiImage: image)
let documentImage:UIImage? = semanticImage.getDocumentImage(image: image)
guard let ciFilter = CIFilter(name: "CIEdgeWork", parameters: [kCIInputRadiusKey:3.0]) else { return }
semanticImage.ciFilterVideo(videoURL: url, ciFilter: ciFilter, { err, processedURL in
// Handle processedURL in here.
})
// This process takes about the same time as the video playback time.
semanticImage.swapBackgroundOfPersonVideo(videoURL: url, backgroundUIImage: uiImage, { err, processedURL in
// Handle processedURL in here.
})
// This process takes about the same time as the video playback time.
semanticImage.swapBGOfSalientObjectVideo(videoURL: url, backgroundUIImage: uiImage, { err, processedURL in
// Handle processedURL in here.
})
// This process takes about the same time as the video playback time.
semanticImage.applyProcessingOnVideo(videoURL: url, { ciImage in
// Write the processing of ciImage (i.e. video frame) here.
return newImage
}, { err, editedURL in
// The processed video URL is returned
})
Daisuke Majima
Freelance iOS programmer from Japan.
PROFILES:
WORKS:
BLOGS: Medium
CONTACTS: rockyshikoku@gmail.com