https://github.com/dragoncherry/camerapreviewcontroller
Basic camera preview controller based on GPUImage library inside.
https://github.com/dragoncherry/camerapreviewcontroller
camera capture custom filter gpuimage light preview torch video
Last synced: 20 days ago
JSON representation
Basic camera preview controller based on GPUImage library inside.
- Host: GitHub
- URL: https://github.com/dragoncherry/camerapreviewcontroller
- Owner: DragonCherry
- License: mit
- Created: 2017-01-10T05:14:22.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2017-06-09T06:03:38.000Z (almost 8 years ago)
- Last Synced: 2025-04-29T23:00:03.825Z (20 days ago)
- Topics: camera, capture, custom, filter, gpuimage, light, preview, torch, video
- Language: Swift
- Size: 61.5 KB
- Stars: 19
- Watchers: 3
- Forks: 6
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# CameraPreviewController
[](https://travis-ci.org/DragonCherry/CameraPreviewController)
[](http://cocoapods.org/pods/CameraPreviewController)
[](http://cocoapods.org/pods/CameraPreviewController)
[](http://cocoapods.org/pods/CameraPreviewController)## Example
To run the example project, clone the repo, and run `pod install` from the Example directory first.
I'm writing this since I couldn't find a open source with complete basic source to start develop camera application from, and is based on GPUImage library inside.
This example contains the following features.
1) front camera preview / still capture / video capture
2) back camera preview / still capture / video capture
3) flipping camera
4) torch control
5) tap to focus
6) add/remove filter
7) face detection
8) pinch to zoom in/out
I'm going to add more features that every camera application must have.
Please don't hesitate to contribute on this project. Any advice and suggestions will be greatly appreciated.
### Functions
- To take photo,
```Swift
takePhoto({ image in
let photoVC = PhotoViewController()
photoVC.image = image
self.present(photoVC, animated: true, completion: nil)
})
```- To take video,
```Swift
// to start
startRecordingVideo()// to finish
finishRecordingVideo()// to handle success
extension ViewController: CameraPreviewControllerDelegate {
func cameraPreview(_ controller: CameraPreviewController, didSaveVideoAt url: URL) {
// which is file url in temporary directory
}
func cameraPreview(_ controller: CameraPreviewController, didFailSaveVideoWithError error: Error) {
}
...
}
```- To change camera,
```Swift
flipCamera()
switch cameraPosition {
// do something
}
```- To control torch,
```Swift
torchMode = .on
torchMode = .off
torchMode = .auto
```- To add, remove filters
```Swift
add(filter: filter)
removeFilters()
```- To detect face,
```Swift
// set true somewhere
isFaceDetectorEnabled = true// handle result
func cameraPreview(_ controller: CameraPreviewController, detected faceFeatures: [CIFaceFeature]?, aperture: CGRect, orientation: UIDeviceOrientation) {
guard let faces = faceFeatures, faces.count > 0 else {
return
}
// do something
}
```## Requirements
Xcode8, Swift 3
## Dependency
Sample: TinyLog, GPUImage, PureLayout, SwiftARGB, Dimmer
Pods: TinyLog, GPUImage, PureLayout
## Installation
CameraPreviewController is available through [CocoaPods](http://cocoapods.org). To install
it, simply add the following line to your Podfile:```ruby
pod "CameraPreviewController"
```## Author
DragonCherry, [email protected]
## License
CameraPreviewController is available under the MIT license. See the LICENSE file for more info.