GithubHelp home page GithubHelp logo

janak-nirmal / simplecam Goto Github PK

View Code? Open in Web Editor NEW

This project forked from loganwright/simplecam

0.0 2.0 0.0 14.37 MB

A Memory Efficient Drop In Replacement / Alternative for the Native UIImagePicker Camera

License: Mozilla Public License 2.0

simplecam's Introduction

SimpleCam

A Memory Efficient Drop In Replacement / Alternative for the Native UIImagePicker Camera

Why Do I Need It?

SimpleCam was created out of the necessity to have high quality photographs while providing a lightweight memory footprint. Apple's UIImagePicker is a wonderful application, but because it has a lot of features and a lot of options, . . . it uses a lot of MEMORY. This can cause crashes, lag, and an overall poor experience when all you wanted was to give the user an opportunity to take a quick picture.

If you're capturing photographs with UIImagePicker, or via AVFoundation on the highest possible capture resolution, it will return giant image files exceeding thousands of pixels in size. SimpleCam avoids this while still using the highest possible capture resolution by resizing the photo to 2x the size of the phone's screen. This allows the photo to maintain a significantly reduced file size while still looking clean and brilliant on mobile displays.

I hope you find the project as useful as I did!

Features

  • iOS 7 Inspired Design
  • 3.5โ€ & 4โ€ Screen Compatibility
  • Low Memory Usage
  • Drag & Drop Installation
  • Portrait/Landscape Views
  • Front/Rear Camera
  • Touch to Focus
  • Controllable Flash
  • Auto Crop / Scale
  • Selfies Don't Flip

Icon's generously provided by PixelLove:

CocoaPods

pod 'SimpleCam', '~> 0.1'

#Adding SimpleCam to Your Project

###1. Add SimpleCam Folder to Xcode

  • Unzip SimpleCam
  • Drag SimpleCam Folder into your Xcode project
  • Make sure "Copy items into destination group's folder (if needed)" is selected

###2. Your ViewController.h File

  • Import SimpleCam
  • Set up your view controller as a SimpleCam delegate
#import <UIKit/UIKit.h>
#import "SimpleCam.h"

@interface ViewController : UIViewController <SimpleCamDelegate>

@end

###3. Set Up Delegate

  • Add SimpleCam's Delegate method to your ViewController.m file
  • Close SimpleCam

This is how SimpleCam will notify your ViewController that the user is finished with it. If there is an image, then the user took a picture. If there is not, then the user backed out of the camera without taking a photograph. Make sure to close SimpleCam in this method using SimpleCam's custom close. Otherwise, the captureSession may not close properly and may result in memory leaks.

#pragma mark SIMPLE CAM DELEGATE

- (void) simpleCam:(SimpleCam *)simpleCam didFinishWithImage:(UIImage *)image {
    
    if (image) {
        // simple cam finished with image
    }
    else {
        // simple cam finished w/o image
    }
    
    // Close simpleCam - use this as opposed to dismissViewController: to properly end photo session
    [simpleCam closeWithCompletion:^{
        NSLog(@"SimpleCam is done closing ... ");
        // It is safe to launch other ViewControllers, for instance, an editor here.
    }];
}

###4. Launch SimpleCam

  • Add this code wherever you'd like SimpleCam to launch
SimpleCam * simpleCam = [[SimpleCam alloc]init];
simpleCam.delegate = self;    
[self presentViewController:simpleCam animated:YES completion:nil];

If you'd like to launch simple cam when the user presses a button, you could add the above code to the buttonPress method, like so:

- (void) buttonPress:(id)sender {        
  SimpleCam * simpleCam = [[SimpleCam alloc]init];
  simpleCam.delegate = self;    
  [self presentViewController:simpleCam animated:YES completion:nil];
}

That's it, it's as simple as that. SimpleCam will take care of everything else!

#ChangeLog

v1.01 Released 19 May 2014

Thanks @capezzbr & @dkhamsing for their contributions to this commit!

  • You can now capture photos programmatically by calling [simpleCam capturePhoto]
  • Now supports an overlay control system (more interaction possibilities coming soon!)
  • Disable Photo Preview to save photos as soon as they're captured: simpleCam.disablePhotoPreview = YES
  • New delegate method to be notified of when the camera stream is visible:
- (void) simpleCamDidLoadCameraIntoView:(SimpleCam *)simpleCam {
    NSLog(@"Camera loaded ... ");
}

#Screen Shots

###Portrait

Camera (About To Capture)

Preview (Shows Captured Image)

Preview - Rotated (Maintains Captured Image Ratio)

###Landscape

Camera (About To Capture)

Preview (Shows Captured Image)

Preview - Rotated (Maintains Captured Image Ratio)

simplecam's People

Contributors

loganwright avatar capezzbr avatar dkhamsing avatar

Watchers

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