Latest 0.1.4
Homepage https://github.com/mingloan/CaptureCenter
License MIT
Platforms ios 9.0
Frameworks UIKit, AVFoundation, Photos
Authors

CaptureCenter(beta)

CI Status
Version
License
Platform

Introduction

CaptureCenter is not a custom camera cature UI libray. It provides a simple interface layer to bridge functionalities of AVFoundation. CaptureCenter provides interfaces for AVCaptureDevice settings such as focusing, adjusting exposure, applying flash, etc. Moreover, CaptureCenter handles photo capture and video recoprding pipelines behind the scene. Developers can build their own camera UI with their own UI components or icons and map the UI actions with the interfaces provided from CaptureCenter.

Example

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

Requirements

Capture Center supports iOS 9.0 or up

Installation

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

pod "CaptureCenter"

or via Carthage

In Cartfile

github "MingLoan/CaptureCenter"

then run

carthage update --platform iOS

Usage

Instantiation

let captureCenter = CaptureCenter(captureMode: .photo)

Only photo capture mode is supported right now, other modes view be supported soon.

public enum CaptureMode {
    case photo
    // unsupport now
    case video(size: VideoSize, location: URL, didStart: () -> (), progress: (CGFloat) -> (), willFinish: () -> (), completion: (AVAsset?) -> ())
    // unsupport now
    case stream
}

You can simply get the camera preview view from CaptureCenter instance and use it as a UIView.

captureCenter.previewView.frame = CGRect(...)
view.addSubview(captureCenter.previewView)

To start capture, call startCapturingWithDevicePosition, you can set device position in advanced.
cameraControlShouldOn enables camera control like tap to focus, pinch to zoom, default is false
The callback will be called after started capturing.

  captureCenter.startCapturingWithDevicePosition(
                .back,
                fromVC: self,
                cameraControlShouldOn: true) { [weak self] finished in
                    guard let strongSelf = self else { return }
                    if finished {
                        // ...
                    }
                }

To stop capture,

    captureCenter.stopCapturing()

take photo

public func captureWithOptions(_ options: ImageOptions, completion: @escaping ((Data?) -> ()))

toggle camera

public func changeCameraWithStartBlock(_ startBlock: (() -> ()), finished endBlock: @escaping ((Bool) -> ()))

configure focus

public func focusWithMode(_ focusMode: AVCaptureFocusMode, exposureMode: AVCaptureExposureMode, at devicePoint: CGPoint, monitorSubjectAreaChange: Bool, showUI: @escaping ((Bool) -> ()))

configure exposure

public func exposeWithBias(_ exposureBias: CGFloat)

configure zoom

public func setZoomScale(_ scale: CGFloat)

Planning

  • support video recording
  • support streaming
  • support RAW capture
  • improve documentation
  • improve error handling

Author

mingloan, [email protected]

License

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

Latest podspec

{
    "name": "CaptureCenter",
    "version": "0.1.4",
    "summary": "CaptureCenter is a camera capture library for iOS. CaptureCenter helps you to do everything besides UI.",
    "description": "CaptureCenter is a custom camera capture library for iOS. You can fit your custom capture layout with CaptureCenter, CaptureCenter helps you to do everything besides UI",
    "homepage": "https://github.com/mingloan/CaptureCenter",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "mingloan": "[email protected]"
    },
    "source": {
        "git": "https://github.com/mingloan/CaptureCenter.git",
        "tag": "0.1.4"
    },
    "social_media_url": "https://twitter.com/mingloan",
    "platforms": {
        "ios": "9.0"
    },
    "source_files": "CaptureCenter/Classes/**/*",
    "ios": {
        "resource_bundles": {
            "CaptureCenter": "CaptureCenter/Assets/icon.xcassets"
        }
    },
    "frameworks": [
        "UIKit",
        "AVFoundation",
        "Photos"
    ],
    "pushed_with_swift_version": "3.0"
}

Pin It on Pinterest

Share This