Giter Club home page Giter Club logo

metalimage's Introduction

MetalImage

简介

MetalImage是基于Metal框架实现的一套图像滤镜链处理框架。

功能

  • 目前实现主要的框架(Camera/Picture/MovieWriter/Filter/View等)和基本的滤镜

使用说明

1.相机画面分发到视图上

self.camera = [[MetalImageCamera alloc] initWithSessionPreset:AVCaptureSessionPreset640x480 cameraPosition:AVCaptureDevicePositionBack];
MetalImageView *view = [[MetalImageView alloc] initWithFrame:CGRectMake(0, 0, 750 / 2, 1334 / 2)];
    
MetalImageFilter *filter = [[MetalImageFilter alloc] init];
[self.camera addTarget:filter];
    
[self.camera startCapture];
[self.view addSubview:view];

2.相机拍摄画面分发到视图和录制器上

self.camera = [[MetalImageCamera alloc] initWithSessionPreset:AVCaptureSessionPreset640x480 cameraPosition:AVCaptureDevicePositionBack];
MetalImageView *view = [[MetalImageView alloc] initWithFrame:CGRectMake(0, 0, 750 / 2, 1334 / 2)];
MetalImageMovieWriter *movieWriter = [[MetalImageMovieWriter alloc] initWithStorageUrl:outputURL size:CGSizeMake(1080, 640)];
[self.camera addTarget:view];
[self.camera addTarget:movieWriter];
movieWriter.fillMode = MetalImageContentModeScaleAspectFit;
movieWriter.backgroundType = MetalImagContentBackgroundFilter;
movieWriter.backgroundFilter = [[MetalImageiOSBlurFilter alloc] init];
((MetalImageiOSBlurFilter *)movieWriter.backgroundFilter).blurRadiusInPixels = 10.0;
((MetalImageiOSBlurFilter *)movieWriter.backgroundFilter).texelSpacingMultiplier = 2.0;
((MetalImageiOSBlurFilter *)movieWriter.backgroundFilter).saturation = 1.0;
    
[movieWriter startRecording];
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(60 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
    [movieWriter finishRecording];
});
    
[self.camera startCapture];

3.图片滤镜处理

MetalImageSharpenFilter *sharpen = [[MetalImageSharpenFilter alloc] init];
sharpen.sharpness = 2.0;
[self.picture processImageByFilters:@[sharpen] completion:^(UIImage *processedImage) {
    
}];

环境要求

  • iOS版本要求: >= 9.0

metalimage's People

Contributors

david-dai-ubnt avatar hello-david avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  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.