Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
A “keep it simple, stupid” approach to handling photo and video capture with AVFoundation.
branch: master

This branch is 117 commits behind thisandagain:master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
Example
.gitignore
DIYCam.h
DIYCam.m
DIYCamDefaults.h
DIYCamUtilities.h
DIYCamUtilities.m
LICENSE.md
README.md
UIImage+Resize.h
UIImage+Resize.m
UIImage+Save.h
UIImage+Save.m

README.md

DIYCam

DIYCam is a high-level layer built on top of AVFoundation that enables simple setup and implementation of photo and video capture within iOS. It is pretty darn opinionated though... if you are looking for lots of configuration options then this is probably not the best way to go. If you are looking for something simple but hopefully not "too" simple then read on:

Getting Started

The fastest way to get started with DIYCam is to look through the included "Example" project, but the setup and use is designed to be really minimal.

// Init camera
cam = [[DIYCam alloc] init];
[[self cam] setDelegate:self];
[[self cam] setup];

// Preview
cam.preview.frame       = display.frame;
[display.layer addSublayer:cam.preview];

CGRect bounds           = display.layer.bounds;
cam.preview.bounds      = bounds;
cam.preview.position    = CGPointMake(CGRectGetMidX(bounds), CGRectGetMidY(bounds));

Required Frameworks

AssetsLibrary.framework
AVFoundation.framework
CoreGraphics.framework
CoreMedia.framework
MobileCoreServices.framework
QuartzCore.framework

Configuration

Default configuration settings can be modified within DIYCamDefaults.h where options for asset library use, orientation, device settings, and quality can be modified.

Methods

- (void)setup;
- (void)startPhotoCapture;
- (void)startVideoCapture;
- (void)stopVideoCapture;
- (NSString *)createAssetFilePath:(NSString *)extension;

Delegate Methods

- (void)camReady:(DIYCam *)cam;
- (void)camDidFail:(DIYCam *)cam withError:(NSError *)error;
- (void)camCaptureStarted:(DIYCam *)cam;
- (void)camCaptureStopped:(DIYCam *)cam;
- (void)camCaptureProcessing:(DIYCam *)cam;
- (void)camCaptureComplete:(DIYCam *)cam withAsset:(NSDictionary *)asset;

Properties

@property (nonatomic, assign) id <DIYCamDelegate> delegate;
@property (nonatomic, retain) AVCaptureSession *session;
@property (nonatomic, assign) AVCaptureVideoPreviewLayer *preview;
@property (nonatomic, assign) BOOL isRecording;
Something went wrong with that request. Please try again.