• Stars
    star
    416
  • Rank 104,068 (Top 3 %)
  • Language Metal
  • License
    MIT License
  • Created over 5 years ago
  • Updated 10 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

🎨 GPU accelerated image / video and camera filter library based on Metal. Support macOS & iOS. 图像、视频、相机滤镜框架

Harbeth

Animated Still

Carthage compatible CocoaPods Compatible CocoaPods Compatible Platform

Harbeth is a high performance Swift library for GPU accelerated image processing and realtime camera capture and video smooth playback, and then add filters based on Metal, and also compatible for CoreImage filters and using Metal performance shaders filters.

This library is highly inspired by GPUImage.


English | 简体中文

Features

🟣 At the moment, the most important features of metal moudle can be summarized as follows:

  • Support more platform system, macOS and iOS, both UIKit/AppKit and SwiftUI.
  • High performance quickly add filters at these sources:
    • UIImage, NSImage, CIImage, CGImage, CMSampleBuffer, CVPixelBuffer.
  • The built-in metal kernel filters is roughly divided into the following modules:
  • Setup MetalPerformanceShaders filters And also compatible for CoreImage filters.
  • Previews and rendering backed with the power of Metal.
  • Drop-in support for your own custom filters using LUTs or using Cube.
  • Realtime camera capture and video smooth playback with filters.
  • Video source processing video file by Kakapos library.

A total of 100+ kinds of built-in filters are currently available.✌️

Requirements

iOS Target macOS Target Xcode Version Swift Version
iOS 10.0+ macOS 10.13+ Xcode 10.0+ Swift 5.0+

Usage

Image

  • 🎷 Code zero intrusion add filter function for image.
let filter1 = C7ColorMatrix4x4(matrix: Matrix4x4.Color.sepia)
let filter2 = C7Granularity(grain: 0.8)
let filter3 = C7SoulOut(soul: 0.7)

let filters = [filter1, filter2, filter3]

// Use:
let dest = HarbethIO.init(element: originImage, filters: filters)
// Synchronize do something..
ImageView.image = try? dest.output()

// OR Use:
ImageView.image = try? originImage.makeGroup(filters: filters)

// OR Use:
ImageView.image = originImage.filtering(filter1, filter2, filter3)

// OR Use Operator:
ImageView.image = originImage ->> filter1 ->> filter2 ->> filter3
  • Asynchronous do something..

This performance is the best. 🚗🚗

let dest = HarbethIO.init(element: ``Source``, filter: ``filter``)

dest.transmitOutput(success: { [weak self] image in
    // do something..
})

ImageView

// It's used the same way as NSImageView.
let renderView = RenderImageView.init(image: originImage)

renderView.filters = [C7Storyboard(ranks: 2)]

Camera

  • 📸 Camera capture generates pictures.
// Add an edge detection filter:
let filter = C7EdgeGlow(lineColor: .red)

// Generate camera collector:
let camera = C7CollectorCamera.init(delegate: self)
camera.captureSession.sessionPreset = AVCaptureSession.Preset.hd1280x720
camera.filters = [filter]

extension CameraViewController: C7CollectorImageDelegate {
    func preview(_ collector: C7Collector, fliter image: C7Image) {
        // do something..
    }
}

Video

  • 📺 Local video or Network video are simply apply with filters.
lazy var video: C7CollectorVideo = {
    let videoURL = URL.init(string: "Link")!
    let asset = AVURLAsset.init(url: videoURL)
    let playerItem = AVPlayerItem.init(asset: asset)
    let player = AVPlayer.init(playerItem: playerItem)
    let video = C7CollectorVideo.init(player: player, delegate: self)
    let filter = C7ColorMatrix4x4(matrix: Matrix4x4.Color.sepia)
    video.filters = [filter]
    return video
}()

self.video.play()

extension PlayerViewController: C7CollectorImageDelegate {
    func preview(_ collector: C7Collector, fliter image: C7Image) {
        // do something..
    }
}

SwiftUI Support

  • For the direct use HarbethView, it is just a simple implementation.
  • The SwiftUI API is still in-progress and may not be production ready. We're looking for help! 🤲
let filters: [C7FilterProtocol] = [
    CIHighlight(highlight: intensity),
    C7WaterRipple(ripple: intensity),
]
HarbethView(image: inputImage, filters: filters, content: { image in
    image.resizable()
        .aspectRatio(contentMode: .fit)
})

CocoaPods

  • If you want to import Metal module, you need in your Podfile:
pod 'Harbeth'
  • If you want to import OpenCV image module, you need in your Podfile:
pod 'OpencvQueen'

Swift Package Manager

Swift Package Manager is a tool for managing the distribution of Swift code. It’s integrated with the Swift build system to automate the process of downloading, compiling, and linking dependencies.

Xcode 11+ is required to build Harbeth using Swift Package Manager.

To integrate Harbeth into your Xcode project using Swift Package Manager, add it to the dependencies value of your Package.swift:

dependencies: [
    .package(url: "https://github.com/yangKJ/Harbeth.git", branch: "master"),
]

Remarks

The general process is almost like this, the Demo is also written in great detail, you can check it out for yourself.🎷

HarbethDemo

Tip: If you find it helpful, please help me with a star. If you have any questions or needs, you can also issue.

Thanks.🎇

About the author

Buy me a coffee or support me on GitHub.

yellow-button

Alipay or WeChat. Thanks.


License

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


More Repositories

1

KJCategories

Collection of native ios extensions and classes to boost development process. Such as UIKit, Foundation, QuartzCore, Accelerate, OpenCV, CoreGraphics, os and more. 超实用开发加速工具库
Objective-C
474
star
2

RxNetworks

🧚 MVP Network Api library. 插件版网络基础架构,支持响应式。
Swift
221
star
3

KJPlayerDemo

Audio and video player, breakpoint resuming playback, record played time, free watching limit, etc. 🎷多内核多功能播放器
Objective-C
188
star
4

Rickenbacker

🎉 RxSwift extensions and MVVM component project architecture.
Swift
108
star
5

KJNetworkPlugin

🎡A lightweight but powerful Network library. Network Plugin, Support batch and chain operation. 插件机制、上传、下载、批量、链式网络架构
Objective-C
65
star
6

Foggy

Automatic crash protection.自动防护异常崩溃 🌇
Objective-C
45
star
7

Opencv-ios

OpenCV image at iOS system. 🎨
Objective-C++
37
star
8

KJBannerViewDemo

轮播图无限自动循环滚动、缩放布局、缓存预加载读取、支持自定义继承,网络GIF和网图混合轮播,支持Storyboard和Xib中创建并配置属性,多种分页控件选择,自动清理缓存等等
Objective-C
27
star
9

ImageX

👓 GIFs and images displayed. 动态图像滤镜播放图像框架。
Swift
26
star
10

Kakapos

🌀 High-performance and flexible video edit and export framework.
Shell
23
star
11

PT

Automatically generate componentized modules 自动生成组件化模块
Ruby
20
star
12

StudyDatas

整理平时的学习资料源码大礼包 🥁..
Objective-C++
20
star
13

Moonlit

播放器,支持边下边播边缓存的播放器方案,支持免费试看、跳过片头片尾、记忆观看记录、画中画播放等等
Swift
12
star
14

KJEmitterView

OC开发分类加速库,你想要的这都有!!!!
Objective-C
11
star
15

CacheX

📦 Mixed cached storage warehouse with disk and memory. Support OC and Swift.
Swift
8
star
16

Color

🎨. Pixel color extension with Swift and SwiftUI.
Swift
8
star
17

iDay

🫥 Metal Daily Share And Shell Script. 每日分享
Shell
8
star
18

gcd

Objective-C
7
star
19

WebDiscernDemo

长按识别网页图片工具
Objective-C
6
star
20

MajiaDemos

MajiaDemos.
Objective-C
5
star
21

PunchCardDemo

打卡管理器
Swift
5
star
22

MPlanet

♻️MVVM + RxSwift 搭建组件化宿主项目架构
4
star
23

blockchain

区块链钱包相关,支持生成助记词、私钥、公钥、地址等🧸
C
4
star
24

KJXIBAdaptiveDemo

xib适配工具
Objective-C
3
star
25

RxPagerView

FSPagerView appending RxSwift extension.
Swift
3
star
26

KJScanDemo

一款项目提炼出来的扫描二维码工具
Objective-C
2
star
27

RxSkeletonView

RxSkeletonView
Swift
2
star
28

KJNetWorkingDemo

一款基于AFNetWorking和YYCache二次封装网络请求工具 其中包含加密和解密 按App版本缓存数据等等
Objective-C
2
star
29

Boxes

Collect macos extensions.
Swift
2
star
30

KJWorkboxDemo

本地消息推送工具、APNs推送工具 自带缓存机制网络图片下载工具 快速识别网页当中的图片 跳转处理工具 加密解密工具 谓词工具等等
Objective-C
1
star
31

Heyuan

12-26 10:09 最新和源版本
Objective-C
1
star
32

KJPredicateDemo

利用谓词写的一套工具
Objective-C
1
star
33

KJJumpControllerDemo

一款万能控制器跳转工具
Objective-C
1
star
34

Cryptograph

This is blockchain cryptograph library. 区块链密钥相关库
Swift
1
star
35

FFmpeg-ios

FFmpeg static libraries compiled for iOS.
1
star
36

YangKJ

1
star
37

KJBaseHandler

Base
Objective-C
1
star
38

KJMoreTargetDemo

同工程里面创建两个Target,然后通过判断Target来修改代码,这样都是基于同一套代码做修改,只是部分不相同的地方通过Target来添加不同代码,后期修改维护成本低
Objective-C
1
star
39

KJExtensionHandler

持续更新中,Category各种工具集合,Button图文混排、点击事件封装、View圆角渐变、Xib属性、TextView输入框扩展、限制字数、撤销,富文本,多语言,加密解密,数组算法,字符串加减乘除幂运算等等等
Objective-C
1
star