Skip to content

sunfjun/SemanticImage

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SemanticImage

CI Status Version License Platform

SemanticImage

A collection of easy-to-use image / video filters.

How to use

1, SemanticImage is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod 'SemanticImage'

2, Import and initialize SemanticImage

```swift
import SemanticImage
let semanticImage = SemanticImage()

Requires iOS 14 or above

Filter Collection

Image

Get Person Mask

let maskImage:UIImage? = semanticImage.personMaskImage(uiImage: yourUIImage)

Swap the background of a person

let swappedImage:UIImage? = sematicImage.swapBackgroundOfPerson(personUIImage: yourUIImage, backgroundUIImage: yourBackgroundUIImage)

Blur the backgrond of a person

let blurredPersonImage:UIImage? = sematicImage.personBlur(uiImage:UIImage, intensity:Float)
// Blur intensity: 0~100 

Get a prominent object mask

let prominentMaskImage:UIImage? = sematicImage.saliencyMask(uiImage:image)

Swap the background of the prominent object

let backgroundSwapImage:UIImage? = sematicImage.saliencyBlend(objectUIImage: image, backgroundUIImage: bgImage)

Crop a face rectangle

let faceImage:UIImage? = sematicImage.faceRectangle(uiImage: image)

Crop a body rectangle

let bodyImage:UIImage? = sematicImage.humanRectangle(uiImage: image)

Crop face rectangles

let faceImages:[UIImage] = sematicImage.faceRectangles(uiImage: image)

Crop body rectangles

let bodyImages:[UIImage] = sematicImage.humanRectangles(uiImage: image)

Crop an animal(Cat/Dog) rectangle

let animalImage:UIImage? = sematicImage.animalRectangle(uiImage: image)

Crop multiple animal(Cat/Dog) rectangles

let animalImages:[UIImage] = sematicImage.animalRectangles(uiImage: image)

Video

Apply CIFilter to Video

guard let ciFilter = CIFilter(name: "CIEdgeWork", parameters: [kCIInputRadiusKey:3.0]) else { return }
sematicImage.ciFilterVideo(videoURL: url, ciFilter: ciFilter, { err, processedURL in
    // Handle processedURL in here.
})
// This process takes about the same time as the video playback time.

Add virtual background of the person video

sematicImage.swapBackgroundOfPersonVideo(videoURL: url, backgroundUIImage: uiImage, { err, processedURL in
    // Handle processedURL in here.
})
    // This process takes about the same time as the video playback time.

Add virtual background of the salient object video

sematicImage.swapBGOfSalientObjectVideo(videoURL: url, backgroundUIImage: uiImage, { err, processedURL in
    // Handle processedURL in here.
})
    // This process takes about the same time as the video playback time.

Process video

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
})

Author

Daisuke Majima

Freelance iOS programmer from Japan.

PROFILES:

WORKS:

BLOGS: Medium

CONTACTS: rockyshikoku@gmail.com

License

SemanticImage is available under the MIT license. See the LICENSE file for more info.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published