{"id":1208,"url":"https://github.com/imaginary-cloud/CameraManager","last_synced_at":"2025-07-30T20:32:42.606Z","repository":{"id":21724135,"uuid":"25045772","full_name":"imaginary-cloud/CameraManager","owner":"imaginary-cloud","description":"Simple Swift class to provide all the configurations you need to create custom camera view in your app","archived":false,"fork":false,"pushed_at":"2024-07-19T13:58:45.000Z","size":4930,"stargazers_count":1373,"open_issues_count":54,"forks_count":324,"subscribers_count":40,"default_branch":"master","last_synced_at":"2024-11-14T12:13:38.633Z","etag":null,"topics":["camera","carthage","cocoapods","custom-camera","image-captioning","ios","qrcode-reader","swift","swift-package-manager","video-recording"],"latest_commit_sha":null,"homepage":"","language":"Swift","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/imaginary-cloud.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2014-10-10T17:28:06.000Z","updated_at":"2024-11-06T12:00:22.000Z","dependencies_parsed_at":"2022-09-13T17:51:02.112Z","dependency_job_id":"bb01e102-87de-4c4e-9b63-2180e6a82b8d","html_url":"https://github.com/imaginary-cloud/CameraManager","commit_stats":{"total_commits":266,"total_committers":42,"mean_commits":6.333333333333333,"dds":0.6879699248120301,"last_synced_commit":"660d7b8326f43ab1721620cd4729b3928c8a767b"},"previous_names":[],"tags_count":51,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/imaginary-cloud%2FCameraManager","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/imaginary-cloud%2FCameraManager/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/imaginary-cloud%2FCameraManager/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/imaginary-cloud%2FCameraManager/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/imaginary-cloud","download_url":"https://codeload.github.com/imaginary-cloud/CameraManager/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":228187561,"owners_count":17882325,"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":["camera","carthage","cocoapods","custom-camera","image-captioning","ios","qrcode-reader","swift","swift-package-manager","video-recording"],"created_at":"2024-01-05T20:15:41.299Z","updated_at":"2024-12-04T20:31:05.067Z","avatar_url":"https://github.com/imaginary-cloud.png","language":"Swift","readme":"# Camera Manager\n\n[![CocoaPods](https://img.shields.io/cocoapods/v/CameraManager.svg)](https://github.com/imaginary-cloud/CameraManager) [![Carthage compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage)\n\nThis is a simple Swift class to provide all the configurations you need to create custom camera view in your app.\nIt follows orientation change and updates UI accordingly, supports front and rear camera selection, pinch to zoom, tap to focus, exposure slider, different flash modes, inputs and outputs and QRCode detection.\nJust drag, drop and use.\n\nWe've also written a blog post about it. You can read it [here](https://www.imaginarycloud.com/blog/camera-manager/).\n\n## Installation with CocoaPods\n\nThe easiest way to install the CameraManager is with [CocoaPods](http://cocoapods.org)\n\n### Podfile\n\n```ruby\nuse_frameworks!\n\npod 'CameraManager', '~\u003e 5.1'\n```\n\n## Installation with Swift Package Manager\n\nThe [Swift Package Manager](https://swift.org/package-manager/) is a tool for managing the distribution of Swift code.\n\nAdd `CameraManager` as a dependency in your `Package.swift` file:\n\n```\nimport PackageDescription\n\nlet package = Package(\n    dependencies: [\n        .Package(url: \"https://github.com/imaginary-cloud/CameraManager\", from: \"5.1.3\")\n    ]\n)\n```\n\n## Installation with Carthage\n\n[Carthage](https://github.com/Carthage/Carthage) is another dependency management tool written in Swift.\n\nAdd the following line to your Cartfile:\n\n```\ngithub \"imaginary-cloud/CameraManager\" \u003e= 5.1\n```\n\nAnd run `carthage update` to build the dynamic framework.\n\n## How to use\n\nTo use it you just add the preview layer to your desired view, you'll get back the state of the camera if it's unavailable, ready or the user denied access to it. Have in mind that in order to retain the AVCaptureSession you will need to retain cameraManager instance somewhere, ex. as an instance constant.\n\n```swift\nlet cameraManager = CameraManager()\ncameraManager.addPreviewLayerToView(self.cameraView)\n\n```\n\nTo shoot image all you need to do is call:\n\n```swift\ncameraManager.capturePictureWithCompletion({ result in\n    switch result {\n        case .failure:\n            // error handling\n        case .success(let content):\n            self.myImage = content.asImage;\n    }\n})\n```\n\nTo record video you call:\n\n```swift\ncameraManager.startRecordingVideo()\ncameraManager.stopVideoRecording({ (videoURL, recordError) -\u003e Void in\n    guard let videoURL = videoURL else {\n        //Handle error of no recorded video URL\n    }\n    do {\n        try FileManager.default.copyItem(at: videoURL, to: self.myVideoURL)\n    }\n    catch {\n        //Handle error occured during copy\n    }\n})\n```\n\nTo zoom in manually:\n\n```swift\nlet zoomScale = CGFloat(2.0)\ncameraManager.zoom(zoomScale)\n```\n\n### Properties\n\nYou can set input device to front or back camera. `(Default: .Back)`\n\n```swift\ncameraManager.cameraDevice = .front || .back\n```\n\nYou can specify if the front camera image should be horizontally fliped. `(Default: false)`\n\n```swift\ncameraManager.shouldFlipFrontCameraImage = true || false\n```\n\nYou can enable or disable gestures on camera preview. `(Default: true)`\n\n```swift\ncameraManager.shouldEnableTapToFocus = true || false\ncameraManager.shouldEnablePinchToZoom = true || false\ncameraManager.shouldEnableExposure = true || false\n```\n\nYou can set output format to Image, video or video with audio. `(Default: .stillImage)`\n\n```swift\ncameraManager.cameraOutputMode = .stillImage || .videoWithMic || .videoOnly\n```\n\nYou can set the quality based on the [AVCaptureSession.Preset values](https://developer.apple.com/documentation/avfoundation/avcapturesession/preset) `(Default: .high)`\n\n```swift\ncameraManager.cameraOutputQuality = .low || .medium || .high || *\n```\n\n`*` check all the possible values [here](https://developer.apple.com/documentation/avfoundation/avcapturesession/preset)\n\nYou can also check if you can set a specific preset value:\n\n```swift\nif .cameraManager.canSetPreset(preset: .hd1280x720) {\n     cameraManager.cameraOutputQuality = .hd1280x720\n} else {\n    cameraManager.cameraOutputQuality = .high\n}\n```\n\nYou can specify the focus mode. `(Default: .continuousAutoFocus)`\n\n```swift\ncameraManager.focusMode = .autoFocus || .continuousAutoFocus || .locked\n```\n\nYou can specifiy the exposure mode. `(Default: .continuousAutoExposure)`\n\n```swift\ncameraManager.exposureMode = .autoExpose || .continuousAutoExposure || .locked || .custom\n```\n\nYou can change the flash mode (it will also set corresponding flash mode). `(Default: .off)`\n\n```swift\ncameraManager.flashMode = .off || .on || .auto\n```\n\nYou can specify the stabilisation mode to be used during a video record session. `(Default: .auto)`\n\n```swift\ncameraManager.videoStabilisationMode = .auto || .cinematic\n```\n\nYou can get the video stabilization mode currently active. If video stabilization is neither supported or active it will return `.off`.\n\n```swift\ncameraManager.activeVideoStabilisationMode\n```\n\nYou can enable location services for storing GPS location when saving to Camera Roll. `(Default: false)`\n\n```swift\ncameraManager.shouldUseLocationServices = true || false\n```\n\nIn case you use location it's mandatory to add `NSLocationWhenInUseUsageDescription` key to the `Info.plist` in your app. [More Info](https://developer.apple.com/documentation/uikit/protecting_the_user_s_privacy)\n\nFor getting the gps location when calling `capturePictureWithCompletion` you should use the `CaptureResult` as `data` (see [Example App](https://github.com/imaginary-cloud/CameraManager/blob/master/Example%20App/ViewController.swift)).\n\nYou can specify if you want to save the files to phone library. `(Default: true)`\n\n```swift\ncameraManager.writeFilesToPhoneLibrary = true || false\n```\n\nYou can specify the album names for image and video recordings.\n\n```swift\ncameraManager.imageAlbumName =  \"Image Album Name\"\ncameraManager.videoAlbumName =  \"Video Album Name\"\n```\n\nYou can specify if you want to disable animations. `(Default: true)`\n\n```swift\ncameraManager.animateShutter = true || false\ncameraManager.animateCameraDeviceChange = true || false\n```\n\nYou can specify if you want the user to be asked about camera permissions automatically when you first try to use the camera or manually. `(Default: true)`\n\n```swift\ncameraManager.showAccessPermissionPopupAutomatically = true || false\n```\n\nTo check if the device supports flash call:\n\n```swift\ncameraManager.hasFlash\n```\n\nTo change flash mode to the next available one you can use this handy function which will also return current value for you to update the UI accordingly:\n\n```swift\ncameraManager.changeFlashMode()\n```\n\nYou can even setUp your custom block to handle error messages:\nIt can be customized to be presented on the Window root view controller, for example.\n\n```swift\ncameraManager.showErrorBlock = { (erTitle: String, erMessage: String) -\u003e Void in\n    var alertController = UIAlertController(title: erTitle, message: erMessage, preferredStyle: .alert)\n    alertController.addAction(UIAlertAction(title: \"OK\", style: UIAlertAction.Style.default, handler: { (alertAction) -\u003e Void in\n    }))\n\n    let topController = UIApplication.shared.keyWindow?.rootViewController\n\n    if (topController != nil) {\n        topController?.present(alertController, animated: true, completion: { () -\u003e Void in\n            //\n        })\n    }\n\n}\n```\n\nYou can set if you want to detect QR codes:\n\n```swift\ncameraManager.startQRCodeDetection { (result) in\n    switch result {\n    case .success(let value):\n        print(value)\n    case .failure(let error):\n        print(error.localizedDescription)\n    }\n}\n```\n\nand don't forget to call `cameraManager.stopQRCodeDetection()` whenever you done detecting.\n\n## Support\n\nSupports iOS 9 and above. Xcode 11.4 is required to build the latest code written in Swift 5.2.\n\nNow it's compatible with latest Swift syntax, so if you're using any Swift version prior to 5 make sure to use one of the previously tagged releases:\n\n- for Swift 4 see: [v4.4.0](https://github.com/imaginary-cloud/CameraManager/tree/4.4.0).\n- for Swift 3 see: [v3.2.0](https://github.com/imaginary-cloud/CameraManager/tree/3.2.0).\n\n## License\n\nCopyright © 2010-2020 [Imaginary Cloud](https://www.imaginarycloud.com/?utm_source=github). This library is licensed under the MIT license.\n\n## About Imaginary Cloud\n\n[![Imaginary Cloud](https://s3.eu-central-1.amazonaws.com/imaginary-images/Logo_IC_readme.svg)](https://www.imaginarycloud.com/?utm_source=github)\n\nAt Imaginary Cloud, we build world-class web \u0026 mobile apps. Our Front-end developers and UI/UX designers are ready to create or scale your digital product. Take a look at our [website](https://www.imaginarycloud.com/?utm_source=github) and [get in touch!](https://www.imaginarycloud.com/contacts/?utm_source=github) We'll take it from there.\n","funding_links":[],"categories":["Hardware","Swift"],"sub_categories":["Camera","Other free courses"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fimaginary-cloud%2FCameraManager","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fimaginary-cloud%2FCameraManager","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fimaginary-cloud%2FCameraManager/lists"}