CaptureCenter 0.1.4

CaptureCenter 0.1.4

TestsTested
LangLanguage SwiftSwift
License MIT
ReleasedLast Release Aug 2017
SwiftSwift Version 3.0
SPMSupports SPM

Maintained by mingloan.



CaptureCenter(beta)

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.