{"id":13602193,"url":"https://github.com/danielebogo/DBCamera","last_synced_at":"2025-04-11T08:31:46.282Z","repository":{"id":13710868,"uuid":"16404838","full_name":"danielebogo/DBCamera","owner":"danielebogo","description":"DBCamera is a simple custom camera with AVFoundation","archived":false,"fork":false,"pushed_at":"2020-10-03T06:42:51.000Z","size":823,"stargazers_count":1259,"open_issues_count":54,"forks_count":261,"subscribers_count":33,"default_branch":"master","last_synced_at":"2025-03-31T20:06:48.818Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Objective-C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/danielebogo.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-01-31T10:11:26.000Z","updated_at":"2025-01-17T15:52:49.000Z","dependencies_parsed_at":"2022-07-08T20:30:50.721Z","dependency_job_id":null,"html_url":"https://github.com/danielebogo/DBCamera","commit_stats":null,"previous_names":[],"tags_count":42,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danielebogo%2FDBCamera","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danielebogo%2FDBCamera/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danielebogo%2FDBCamera/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danielebogo%2FDBCamera/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/danielebogo","download_url":"https://codeload.github.com/danielebogo/DBCamera/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247730068,"owners_count":20986404,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-01T18:01:16.062Z","updated_at":"2025-04-11T08:31:46.232Z","avatar_url":"https://github.com/danielebogo.png","language":"Objective-C","funding_links":[],"categories":["IOS 或 OSX","Objective-C  Stars 1000以内排名整理","etc"],"sub_categories":[],"readme":"![Alt text](http://bogodaniele.com/apps/development/dbcamera/github/dbcamera_splash.png)\n\nDBCamera is a simple custom camera with AVFoundation.\n\n## Getting Started\n\n### Installation\n\nThe recommended approach for installating DBCamera is via the [CocoaPods](http://cocoapods.org/) package manager, as it provides flexible dependency management and dead simple installation.\n\n#### Podfile\n\n```ruby\nplatform :ios, '6.0'\npod 'DBCamera', '~\u003e 2.4'\n```\n\n#### via Apache Cordova\n\nDBCamera is available for use as an apache cordova plugin for ios. Visit [Cordova-DBCamera](https://github.com/vulume/Cordova-DBCamera) for more.\n\n## Example\nIf you use the example project, run ``` pod install ``` to install GPUImage dependency\n\n## Integration\n\nDBCamera has a simple integration:\n\n```objective-c\n#import \"DBCameraViewController.h\"\n#import \"DBCameraContainerViewController.h\"\n```\n\n```objective-c\n//Add DBCameraViewControllerDelegate protocol\n@interface RootViewController () \u003cDBCameraViewControllerDelegate\u003e\n```\n\n```objective-c\n//Present DBCameraViewController with different behaviours\n\n- (void) openCamera\n{\n    DBCameraContainerViewController *cameraContainer = [[DBCameraContainerViewController alloc] initWithDelegate:self];\n    [cameraContainer setFullScreenMode];\n\n    UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:cameraContainer];\n    [nav setNavigationBarHidden:YES];\n    [self presentViewController:nav animated:YES completion:nil];\n}\n\n- (void) openCameraWithoutSegue\n{\n    DBCameraViewController *cameraController = [DBCameraViewController initWithDelegate:self];\n    [cameraController setUseCameraSegue:NO];\n\n    DBCameraContainerViewController *container = [[DBCameraContainerViewController alloc] initWithDelegate:self];\n    [container setCameraViewController:cameraController];\n    [container setFullScreenMode];\n\n    UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:container];\n    [nav setNavigationBarHidden:YES];\n    [self presentViewController:nav animated:YES completion:nil];\n}\n\n- (void) openCameraWithoutContainer\n{\n    UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:[DBCameraViewController initWithDelegate:self]];\n    [nav setNavigationBarHidden:YES];\n    [self presentViewController:nav animated:YES completion:nil];\n}\n```\n\n```objective-c\n//Use your captured image\n#pragma mark - DBCameraViewControllerDelegate\n\n- (void) camera:(id)cameraViewController didFinishWithImage:(UIImage *)image withMetadata:(NSDictionary *)metadata\n{\n    DetailViewController *detail = [[DetailViewController alloc] init];\n    [detail setDetailImage:image];\n    [self.navigationController pushViewController:detail animated:NO];\n    [cameraViewController restoreFullScreenMode];\n    [self.presentedViewController dismissViewControllerAnimated:YES completion:nil];\n}\n\n- (void) dismissCamera:(id)cameraViewController{\n    [self dismissViewControllerAnimated:YES completion:nil];\n    [cameraViewController restoreFullScreenMode];\n}\n```\nBy default, DBCameraViewController has another controller to display the image preview.\nWhen you create DBCameraViewController instance, you can set ``` useCameraSegue: ``` NO, to avoid it.\n```objective-c\n- (void) openCameraWithoutSegue\n{\n    DBCameraContainerViewController *container = [[DBCameraContainerViewController alloc] initWithDelegate:self];\n    DBCameraViewController *cameraController = [DBCameraViewController initWithDelegate:self];\n    [cameraController setUseCameraSegue:NO];\n    [container setCameraViewController:cameraController];\n    UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:container];\n    [nav setNavigationBarHidden:YES];\n    [container setFullScreenMode];\n    [self presentViewController:nav animated:YES completion:nil];\n}\n```\nIf you want, you can force the crop option within segue view controller. Set ``` setForceQuadCrop:``` YES\n```objective-c\n- (void) openCameraWithForceQuad\n{\n    DBCameraViewController *cameraController = [DBCameraViewController initWithDelegate:self];\n    [cameraController setForceQuadCrop:YES];\n\n    DBCameraContainerViewController *container = [[DBCameraContainerViewController alloc] initWithDelegate:self];\n    [container setCameraViewController:cameraController];\n    [container setFullScreenMode];\n\n    UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:container];\n    [nav setNavigationBarHidden:YES];\n    [self presentViewController:nav animated:YES completion:nil];\n}\n```\nYou can use the Library picker as separated view controller.\n```objective-c\n- (void) openLibrary\n{\n    DBCameraLibraryViewController *vc = [[DBCameraLibraryViewController alloc] init];\n    [vc setDelegate:self]; //DBCameraLibraryViewController must have a DBCameraViewControllerDelegate object\n//    [vc setForceQuadCrop:YES]; //Optional\n//    [vc setUseCameraSegue:YES]; //Optional\n    UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:vc];\n    [nav setNavigationBarHidden:YES];\n    [self presentViewController:nav animated:YES completion:nil];\n}\n```\n\n## Customizing the camera\n\n### Basic\nFor simple customizations, you can customize the built-in camera view by sending a cameraSettingsBlock to the view controller.\n```objective-c\n#import \"DBCameraView.h\"\n- (void)openCameraWithSettings:(CDVInvokedUrlCommand*)command\n{\n    DBCameraContainerViewController *cameraContainer = [[DBCameraContainerViewController alloc] initWithDelegate:self cameraSettingsBlock:^(DBCameraView *cameraView, DBCameraContainerViewController *container) {\n        [cameraView.photoLibraryButton setHidden:YES]; //Hide Library button\n\n        //Override the camera grid\n        DBCameraGridView *cameraGridView = [[DBCameraGridView alloc] initWithFrame:cameraView.previewLayer.frame];\n        [cameraGridView setNumberOfColumns:4];\n        [cameraGridView setNumberOfRows:4];\n        [cameraGridView setAlpha:0];\n        [container.cameraViewController setCameraGridView:cameraGridView];\n    }];\n\n    //Set the Tint Color and the Selected Color\n    [cameraContainer setTintColor:[UIColor redColor]];\n    [cameraContainer setSelectedTintColor:[UIColor yellowColor]];\n}\n```\n\n## Customize the Segue View controller\nFor a simple customization, you can use the block ``` cameraSegueConfigureBlock ```\n```objective-c\n#import \"DBCameraSegueViewController.h\"\n[cameraController setCameraSegueConfigureBlock:^( DBCameraSegueViewController *segue ) {\n  segue.cropMode = YES;\n  segue.cropRect = (CGRect){ 0, 0, 200, 400 };\n}];\n```\n\n### Advanced\nYou can also create a custom interface, using a subclass of DBCameraView\n```objective-c\n#import \"DBCameraView.h\"\n\n@interface CustomCamera : DBCameraView\n- (void) buildInterface;\n@end\n```\n```objective-c\n#import \"CustomCamera.h\"\n\n@interface CustomCamera ()\n@property (nonatomic, strong) UIButton *closeButton;\n@property (nonatomic, strong) CALayer *focusBox, *exposeBox;\n@end\n\n@implementation CustomCamera\n\n- (void) buildInterface\n{\n    [self addSubview:self.closeButton];\n\n    [self.previewLayer addSublayer:self.focusBox];\n    [self.previewLayer addSublayer:self.exposeBox];\n\n    [self createGesture];\n}\n\n- (UIButton *) closeButton\n{\n    if ( !_closeButton ) {\n        _closeButton = [UIButton buttonWithType:UIButtonTypeCustom];\n        [_closeButton setBackgroundColor:[UIColor redColor]];\n        [_closeButton setImage:[UIImage imageNamed:@\"close\"] forState:UIControlStateNormal];\n        [_closeButton setFrame:(CGRect){ CGRectGetMidX(self.bounds) - 15, 17.5f, 30, 30 }];\n        [_closeButton addTarget:self action:@selector(close) forControlEvents:UIControlEventTouchUpInside];\n    }\n\n    return _closeButton;\n}\n\n- (void) close\n{\n    if ( [self.delegate respondsToSelector:@selector(closeCamera)] )\n        [self.delegate closeCamera];\n}\n\n#pragma mark - Focus / Expose Box\n\n- (CALayer *) focusBox\n{\n    if ( !_focusBox ) {\n        _focusBox = [[CALayer alloc] init];\n        [_focusBox setCornerRadius:45.0f];\n        [_focusBox setBounds:CGRectMake(0.0f, 0.0f, 90, 90)];\n        [_focusBox setBorderWidth:5.f];\n        [_focusBox setBorderColor:[[UIColor whiteColor] CGColor]];\n        [_focusBox setOpacity:0];\n    }\n\n    return _focusBox;\n}\n\n- (CALayer *) exposeBox\n{\n    if ( !_exposeBox ) {\n        _exposeBox = [[CALayer alloc] init];\n        [_exposeBox setCornerRadius:55.0f];\n        [_exposeBox setBounds:CGRectMake(0.0f, 0.0f, 110, 110)];\n        [_exposeBox setBorderWidth:5.f];\n        [_exposeBox setBorderColor:[[UIColor redColor] CGColor]];\n        [_exposeBox setOpacity:0];\n    }\n\n    return _exposeBox;\n}\n\n- (void) drawFocusBoxAtPointOfInterest:(CGPoint)point andRemove:(BOOL)remove\n{\n    [super draw:_focusBox atPointOfInterest:point andRemove:remove];\n}\n\n- (void) drawExposeBoxAtPointOfInterest:(CGPoint)point andRemove:(BOOL)remove\n{\n    [super draw:_exposeBox atPointOfInterest:point andRemove:remove];\n}\n\n@end\n```\n```objective-c\n//Present DBCameraViewController with a custom view.\n@interface RootViewController () \u003cDBCameraViewControllerDelegate\u003e\n\n- (void) openCustomCamera\n{\n    CustomCamera *camera = [CustomCamera initWithFrame:[[UIScreen mainScreen] bounds]];\n    [camera buildInterface];\n\n    UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:[[DBCameraViewController alloc] initWithDelegate:self\n                                                                                                                                   cameraView:camera]];\n    [nav setNavigationBarHidden:YES];\n    [self presentViewController:nav animated:YES completion:nil];\n}\n```\n\n### iOS Min Required\n6.0\n\n### Version\n2.4.1\n\n### Created By\n\n[Daniele Bogo](https://github.com/danielebogo)\n\n### Credits\n\n[mkcode](https://github.com/mkcode),\n[Jack](https://github.com/xhzengAIB),\n[denadai2](https://github.com/denadai2),\n[leobarrospereira](https://github.com/leobarrospereira),\n[sebastianludwig](https://github.com/sebastianludwig)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdanielebogo%2FDBCamera","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdanielebogo%2FDBCamera","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdanielebogo%2FDBCamera/lists"}