Latest 0.1.4
License 3-clause BSD
Platforms ios 9.0
Dependencies OpenCV-Dynamic
Frameworks QuartzCore, CoreVideo, AssetsLibrary, CoreMedia, CoreImage, CoreGraphics, AVFoundation, Accelerate, UIKit, ImageIO, Foundation

CI Status


To run the example project, clone the repo, and run pod install from the Example directory first.

If this is first time you use OpenCV-Dynamic as the dependency, it’ll take time to install.

How to Use

Just import the framework

import SwiftEyes

In class SEMotionTrackViewController, you can see the example.

Simply use the code below can identify the motion blob.

func processImage(_ image: OCVMat!) {

// Parameters
let blurSize = 10
let sensitivityValue = 20.0
var differenceMat = OCVMat(cgSize: CGSize(width: image.size.width, height: image.size.height), type: image.type, channels: image.channels)

// from BGR to RGB
OCVOperation.convertColor(fromSource: image, toDestination: image, with: .typeBGRA2RGBA)

// set current mat
currentMat = image.clone()

// convert current mat from RGB to GrayScale
OCVOperation.convertColor(fromSource: currentMat, toDestination: currentMat, with: .typeRGBA2GRAY)

if previousMat != nil {
OCVOperation.absoluteDifference(onFirstSource: currentMat, andSecondSource: previousMat, toDestination: differenceMat)
OCVOperation.blur(onSource: differenceMat, toDestination: differenceMat, with: OCVSize(width: blurSize, height: blurSize))
OCVOperation.threshold(onSource: differenceMat, toDestination: differenceMat, withThresh: sensitivityValue, withMaxValue: 255.0, with: .binary)

DispatchQueue.main.sync {
cameraImageView.image = image.image()
displayImageView.image = differenceMat.image()

// use previous mat(frame) to compare with next mat(frame)
previousMat = currentMat



motion tracking
color tracking

motion tracking
color tracking


If you didn’t install CocoaPods yet, you can install from here.

And before you run pod install, please be sure that you have install cmake as well.

To download it, simply use Homebrew to install:

brew install cmake


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

pod "SwiftEyes"


Victor Lee, [email protected]


BSD license, respect OpenCV license as well.

Latest podspec

    "name": "SwiftEyes",
    "version": "0.1.4",
    "summary": "An easy way to access OpenCV library from Swift.",
    "homepage": "",
    "license": {
        "type": "3-clause BSD",
        "file": "LICENSE"
    "authors": {
        "Victor Lee": "[email protected]"
    "social_media_url": "",
    "platforms": {
        "ios": "9.0"
    "source": {
        "git": "",
        "tag": "0.1.4"
    "source_files": "SwiftEyes/Classes/**/*",
    "private_header_files": "SwiftEyes/Classes/Private/*.h",
    "pod_target_xcconfig": {
        "OTHER_LDFLAGS": "-lObjC"
    "frameworks": [
    "libraries": [
    "dependencies": {
        "OpenCV-Dynamic": [
            "~> 3.x"
    "pushed_with_swift_version": "3.0"

Pin It on Pinterest

Share This