Git Product home page Git Product logo

videocamera's Introduction

Shakuro VideoCamera

VideoCamera

Version Platform License MIT

Wrapper around AVFoundation camera. Works with several data outputs, such as metadata, video data, still image capture.

Requirements

  • iOS 11.0+
  • Xcode 11.0+
  • Swift 5.0+

Installation

CocoaPods

To integrate VideoCamera into your Xcode project with CocoaPods, specify it in your Podfile:

pod 'Shakuro.VideoCamera'

Then, run the following command:

$ pod install

Manually

If you prefer not to use CocoaPods, you can integrate Shakuro.VideoCamera simply by copying it to your project.

Usage

Each VideoCamera must be provided with VideoCameraConfiguration structure. Go though it's extensive array of settings. For a simple setup of back-facing camera, that provides only video data preview without ability to get still images:

private var camera: VideoCamera?

override func viewDidLoad() {
    super.viewDidLoad()
    
    // ...
    
    var cameraConfig = VideoCameraConfiguration()
    cameraConfig.cameraDelegate = self
    cameraConfig.captureSessionPreset = .high
    cameraConfig.capturePhotoEnabled = false
    cameraConfig.videoFeedDelegate = self
    cameraConfig.simulatedImage = UIImage(named: "card_backside.png")?.cgImage
    let videoCamera = VideoCameraFactory.createCamera(configuration: cameraConfig)
    camera = videoCamera
    
    // ...
}

To display camera preview, one of the simplest ways is to prepare container view in storyboard and than add camera's preview to it:

@IBOutlet private var cameraPreviewContainerView: UIView!

override func viewDidLoad() {
    super.viewDidLoad()
    
    // setup camera (see above)

    let preview = videoCamera.previewView
    preview.translatesAutoresizingMaskIntoConstraints = true
    preview.autoresizingMask = [UIViewAutoresizing.flexibleHeight, UIViewAutoresizing.flexibleWidth]
    preview.frame = cameraPreviewContainerView.bounds
    cameraPreviewContainerView.insertSubview(preview, at: 0)
    
    // ...
}

Changes of camera's properties are observed via delegate:

extension MyViewController: VideoCameraDelegate {

    func videoCamera(_ videoCamera: VideoCamera, error: Error) {
        // display/process error
    }

    func videoCameraInitialized(_ videoCamera: VideoCamera, errors: [VideoCameraError]) {
        // update UI - such as flash button (with actual state of camera)
    }

    func videoCamera(_ videoCamera: VideoCamera, flashModeForPhotoDidChanged newValue: AVCaptureDevice.FlashMode) {
        // update flash button
    }
    
    // ... other delegate functions
    
}

Have a look at the VideoCamera_Example

License

Shakuro.VideoCamera is released under the MIT license. See LICENSE for details.

Give it a try and reach us

Star this tool if you like it, it will help us grow and add new useful things. Feel free to reach out and hire our team to develop a mobile or web project for you.

videocamera's People

Contributors

eugendevios avatar nadejdatryshkina avatar sergeyyypopov avatar

Stargazers

 avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.