Giter VIP home page Giter VIP logo

semanticimage's Introduction

SemanticImage

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

How to use

Setting Up

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

Filter Collection

Image

Get Person Mask

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

Swap the background of a person

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

Blur the backgrond of a person

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

Get a prominent object mask

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

Swap the background of the prominent object

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

Crop a face rectangle

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

Crop a body rectangle

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

Crop face rectangles

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

Crop body rectangles

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

Crop an animal(Cat/Dog) rectangle

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

Crop multiple animal(Cat/Dog) rectangles

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

Crop and warp document

let documentImage:UIImage? = semanticImage.getDocumentImage(image: image)

Video

Apply CIFilter to Video

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.

Add virtual background of the person video

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.

Add virtual background of the salient object video

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.

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: [email protected]

semanticimage's People

Contributors

john-rocky avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.