All Projects → imaginary-cloud → Cameramanager

imaginary-cloud / Cameramanager

Licence: mit
Simple Swift class to provide all the configurations you need to create custom camera view in your app

Programming Languages

swift
15916 projects

Projects that are alternatives of or similar to Cameramanager

Fontblaster
Programmatically load custom fonts into your iOS and tvOS app.
Stars: ✭ 1,000 (-11.5%)
Mutual labels:  cocoapods, carthage, swift-package-manager
Zephyr
Effortlessly synchronize UserDefaults over iCloud.
Stars: ✭ 722 (-36.11%)
Mutual labels:  cocoapods, carthage, swift-package-manager
Swiftframeworktemplate
A template for new Swift iOS / macOS / tvOS / watchOS Framework project ready with travis-ci, cocoapods, Carthage, SwiftPM and a Readme file
Stars: ✭ 527 (-53.36%)
Mutual labels:  cocoapods, carthage, swift-package-manager
Wstagsfield
An iOS text field that represents tags, hashtags, tokens in general.
Stars: ✭ 1,013 (-10.35%)
Mutual labels:  cocoapods, carthage, swift-package-manager
Swiftlyext
SwiftlyExt is a collection of useful extensions for Swift 3 standard classes and types 🚀
Stars: ✭ 31 (-97.26%)
Mutual labels:  cocoapods, carthage, swift-package-manager
Keyboardshortcuts
Add user-customizable global keyboard shortcuts to your macOS app in minutes
Stars: ✭ 500 (-55.75%)
Mutual labels:  cocoapods, carthage, swift-package-manager
Guitar
A Cross-Platform String and Regular Expression Library written in Swift.
Stars: ✭ 641 (-43.27%)
Mutual labels:  cocoapods, carthage, swift-package-manager
Web3.swift
A pure swift Ethereum Web3 library
Stars: ✭ 295 (-73.89%)
Mutual labels:  cocoapods, carthage, swift-package-manager
Preferences
⚙ Add a preferences window to your macOS app in minutes
Stars: ✭ 898 (-20.53%)
Mutual labels:  cocoapods, carthage, swift-package-manager
Statusalert
Display Apple system-like self-hiding status alerts. It is well suited for notifying user without interrupting user flow in iOS-like way.
Stars: ✭ 809 (-28.41%)
Mutual labels:  cocoapods, carthage, swift-package-manager
Sketchkit
A lightweight auto-layout DSL library for iOS & tvOS.
Stars: ✭ 40 (-96.46%)
Mutual labels:  cocoapods, carthage, swift-package-manager
Sica
🦌 Simple Interface Core Animation. Run type-safe animation sequencially or parallelly
Stars: ✭ 980 (-13.27%)
Mutual labels:  cocoapods, carthage, swift-package-manager
Tweetextfield
Lightweight set of text fields with nice animation and functionality. 🚀 Inspired by https://uimovement.com/ui/2524/input-field-help/
Stars: ✭ 421 (-62.74%)
Mutual labels:  cocoapods, carthage, swift-package-manager
Openssl
OpenSSL package for SPM, CocoaPod, and Carthage, for iOS and macOS
Stars: ✭ 515 (-54.42%)
Mutual labels:  cocoapods, carthage, swift-package-manager
Functionkit
A framework for functional types and operations designed to fit naturally into Swift.
Stars: ✭ 302 (-73.27%)
Mutual labels:  cocoapods, carthage, swift-package-manager
Sablurimageview
You can use blur effect and it's animation easily to call only two methods.
Stars: ✭ 538 (-52.39%)
Mutual labels:  cocoapods, carthage, swift-package-manager
Stepperview
SwiftUI iOS component for Step Indications.
Stars: ✭ 281 (-75.13%)
Mutual labels:  cocoapods, carthage, swift-package-manager
Kyshutterbutton
KYShutterButton is a custom button that is similar to the shutter button of the camera app
Stars: ✭ 293 (-74.07%)
Mutual labels:  camera, cocoapods, carthage
Defaults
Swifty and modern UserDefaults
Stars: ✭ 734 (-35.04%)
Mutual labels:  cocoapods, carthage, swift-package-manager
Bfkit Swift
BFKit-Swift is a collection of useful classes, structs and extensions to develop Apps faster.
Stars: ✭ 963 (-14.78%)
Mutual labels:  cocoapods, carthage, swift-package-manager

Camera Manager

CocoaPods Carthage compatible

This is a simple Swift class to provide all the configurations you need to create custom camera view in your app. It follows orientation change and updates UI accordingly, supports front and rear camera selection, pinch to zoom, tap to focus, exposure slider, different flash modes, inputs and outputs and QRCode detection. Just drag, drop and use.

We've also written a blog post about it. You can read it here.

Installation with CocoaPods

The easiest way to install the CameraManager is with CocoaPods

Podfile

use_frameworks!

pod 'CameraManager', '~> 5.1'

Installation with Swift Package Manager

The Swift Package Manager is a tool for managing the distribution of Swift code.

Add CameraManager as a dependency in your Package.swift file:

import PackageDescription

let package = Package(
    dependencies: [
        .Package(url: "https://github.com/imaginary-cloud/CameraManager", from: "5.1.3")
    ]
)

Installation with Carthage

Carthage is another dependency management tool written in Swift.

Add the following line to your Cartfile:

github "imaginary-cloud/CameraManager" >= 5.1

And run carthage update to build the dynamic framework.

How to use

To use it you just add the preview layer to your desired view, you'll get back the state of the camera if it's unavailable, ready or the user denied access to it. Have in mind that in order to retain the AVCaptureSession you will need to retain cameraManager instance somewhere, ex. as an instance constant.

let cameraManager = CameraManager()
cameraManager.addPreviewLayerToView(self.cameraView)

To shoot image all you need to do is call:

cameraManager.capturePictureWithCompletion({ result in
    switch result {
        case .failure:
            // error handling
        case .success(let content):
            self.myImage = content.asImage;
    }
})

To record video you call:

cameraManager.startRecordingVideo()
cameraManager.stopVideoRecording({ (videoURL, recordError) -> Void in
    guard let videoURL = videoURL else {
        //Handle error of no recorded video URL
    }
    do {
        try FileManager.default.copyItem(at: videoURL, to: self.myVideoURL)
    }
    catch {
        //Handle error occured during copy
    }
})

To zoom in manually:

let zoomScale = CGFloat(2.0)
cameraManager.zoom(zoomScale)

Properties

You can set input device to front or back camera. (Default: .Back)

cameraManager.cameraDevice = .front || .back

You can specify if the front camera image should be horizontally fliped. (Default: false)

cameraManager.shouldFlipFrontCameraImage = true || false

You can enable or disable gestures on camera preview. (Default: true)

cameraManager.shouldEnableTapToFocus = true || false
cameraManager.shouldEnablePinchToZoom = true || false
cameraManager.shouldEnableExposure = true || false

You can set output format to Image, video or video with audio. (Default: .stillImage)

cameraManager.cameraOutputMode = .stillImage || .videoWithMic || .videoOnly

You can set the quality based on the AVCaptureSession.Preset values (Default: .high)

cameraManager.cameraOutputQuality = .low || .medium || .high || *

* check all the possible values here

You can also check if you can set a specific preset value:

if .cameraManager.canSetPreset(preset: .hd1280x720) {
     cameraManager.cameraOutputQuality = .hd1280x720
} else {
    cameraManager.cameraOutputQuality = .high
}

You can specify the focus mode. (Default: .continuousAutoFocus)

cameraManager.focusMode = .autoFocus || .continuousAutoFocus || .locked

You can specifiy the exposure mode. (Default: .continuousAutoExposure)

cameraManager.exposureMode = .autoExpose || .continuousAutoExposure || .locked || .custom

You can change the flash mode (it will also set corresponding flash mode). (Default: .off)

cameraManager.flashMode = .off || .on || .auto

You can specify the stabilisation mode to be used during a video record session. (Default: .auto)

cameraManager.videoStabilisationMode = .auto || .cinematic

You can get the video stabilization mode currently active. If video stabilization is neither supported or active it will return .off.

cameraManager.activeVideoStabilisationMode

You can enable location services for storing GPS location when saving to Camera Roll. (Default: false)

cameraManager.shouldUseLocationServices = true || false

In case you use location it's mandatory to add NSLocationWhenInUseUsageDescription key to the Info.plist in your app. More Info

For getting the gps location when calling capturePictureWithCompletion you should use the CaptureResult as data (see Example App).

You can specify if you want to save the files to phone library. (Default: true)

cameraManager.writeFilesToPhoneLibrary = true || false

You can specify the album names for image and video recordings.

cameraManager.imageAlbumName =  "Image Album Name"
cameraManager.videoAlbumName =  "Video Album Name"

You can specify if you want to disable animations. (Default: true)

cameraManager.animateShutter = true || false
cameraManager.animateCameraDeviceChange = true || false

You can specify if you want the user to be asked about camera permissions automatically when you first try to use the camera or manually. (Default: true)

cameraManager.showAccessPermissionPopupAutomatically = true || false

To check if the device supports flash call:

cameraManager.hasFlash

To change flash mode to the next available one you can use this handy function which will also return current value for you to update the UI accordingly:

cameraManager.changeFlashMode()

You can even setUp your custom block to handle error messages: It can be customized to be presented on the Window root view controller, for example.

cameraManager.showErrorBlock = { (erTitle: String, erMessage: String) -> Void in
    var alertController = UIAlertController(title: erTitle, message: erMessage, preferredStyle: .alert)
    alertController.addAction(UIAlertAction(title: "OK", style: UIAlertAction.Style.default, handler: { (alertAction) -> Void in
    }))

    let topController = UIApplication.shared.keyWindow?.rootViewController

    if (topController != nil) {
        topController?.present(alertController, animated: true, completion: { () -> Void in
            //
        })
    }

}

You can set if you want to detect QR codes:

cameraManager.startQRCodeDetection { (result) in
    switch result {
    case .success(let value):
        print(value)
    case .failure(let error):
        print(error.localizedDescription)
    }
}

and don't forget to call cameraManager.stopQRCodeDetection() whenever you done detecting.

Support

Supports iOS 9 and above. Xcode 11.4 is required to build the latest code written in Swift 5.2.

Now it's compatible with latest Swift syntax, so if you're using any Swift version prior to 5 make sure to use one of the previously tagged releases:

License

Copyright © 2010-2020 Imaginary Cloud. This library is licensed under the MIT license.

About Imaginary Cloud

Imaginary Cloud

At Imaginary Cloud, we build world-class web & mobile apps. Our Front-end developers and UI/UX designers are ready to create or scale your digital product. Take a look at our website and get in touch! We'll take it from there.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].