Giter VIP home page Giter VIP logo

motion-capture's Introduction

motion-capture

Camera support for custom camera controllers

Usage

motion_capture = Motion::Capture.new
motion_capture = Motion::Capture.new(device: :front) # specify camera
motion_capture = Motion::Capture.new(preset: AVCaptureSessionPreset640x480) # specify a different preset (defaults to high resolution photo)

motion_capture.attach(view) # apply a AVCaptureVideoPreviewLayer to the specified view

motion_capture.toggle_camera # Switch between front/rear cameras
motion_capture.toggle_flash  # Switch bettwen flash on/off

motion_capture.turn_flash_on
motion_capture.turn_flash_off

motion_capture.use_camera(:default)
motion_capture.use_camera(:front)
motion_capture.use_camera(:rear)

# When you're ready to start the capture session:
motion_capture.start!

# Capturing Single Photos

motion_capture.capture do |image_data|
  # Use NSData
end

motion_capture.capture_image do |image|
  # Use UIImage
end

# Saving captured images to the Photos library

motion_capture.capture_and_save do |image_data, asset_url|
  # Use NSData and NSURL
end

motion_capture.capture_image_and_save do |image, asset_url|
  # Use UIImage and NSURL
end

# When you're done using the camera and are ready to stop the capture session:
motion_capture.stop!

Setup

Add this line to your application's Gemfile:

gem 'motion-capture'

And then execute:

$ bundle

Or install it yourself as:

$ gem install motion-capture

Add the necessary frameworks to your app configuration in your Rakefile:

app.frameworks << 'AVFoundation'
app.frameworks << 'Photos' # if you will be saving to the Photo library and targeting iOS 8+
app.frameworks << 'AssetsLibrary' # if you will be targeting iOS 4-7

Then update your app configuration in your Rakefile to specify the message that will be displayed when asking the user for permission to use the camera:

app.info_plist['NSCameraUsageDescription'] = 'Camera will be used for taking your profile photo.'

If you will be saving photos to the Photo Library, you will also need to specify the message that will be displayed to the user:

app.info_plist['NSPhotoLibraryUsageDescription'] = 'Photos taken will be saved to your library.'

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

motion-capture's People

Contributors

dblandin avatar andrewhavens avatar

Watchers

James Cloos avatar  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.