Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/shakurocom/videocamera
https://github.com/shakurocom/videocamera
camera capture-video component swift uikit video xcode
Last synced: about 1 month ago
JSON representation
- Host: GitHub
- URL: https://github.com/shakurocom/videocamera
- Owner: shakurocom
- License: mit
- Created: 2022-08-31T06:31:36.000Z (over 2 years ago)
- Default Branch: master
- Last Pushed: 2024-01-19T06:51:59.000Z (12 months ago)
- Last Synced: 2024-11-17T02:34:48.243Z (about 2 months ago)
- Topics: camera, capture-video, component, swift, uikit, video, xcode
- Language: Swift
- Homepage:
- Size: 1.26 MB
- Stars: 3
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
![Shakuro VideoCamera](Resources/title_image.png)
# VideoCamera
![Version](https://img.shields.io/badge/version-1.0.0-blue.svg)
![Platform](https://img.shields.io/badge/platform-iOS-lightgrey.svg)
![License MIT](https://img.shields.io/badge/license-MIT-green.svg)- [Requirements](#requirements)
- [Installation](#installation)
- [Usage](#usage)
- [License](#license)Wrapper around AVFoundation camera. Works with several data outputs, such as metadata, video data, still image capture.
## Requirements
- iOS 11.0+
- Xcode 11.0+
- Swift 5.0+## Installation
### CocoaPods
To integrate VideoCamera into your Xcode project with CocoaPods, specify it in your `Podfile`:
```ruby
pod 'Shakuro.VideoCamera'
```Then, run the following command:
```bash
$ pod install
```### Manually
If you prefer not to use CocoaPods, you can integrate Shakuro.VideoCamera simply by copying it to your project.
## Usage
Each `VideoCamera` must be provided with `VideoCameraConfiguration` structure. Go though it's extensive array of settings. For a simple setup of back-facing camera, that provides only video data preview without ability to get still images:
```swift
private var camera: VideoCamera?override func viewDidLoad() {
super.viewDidLoad()
// ...
var cameraConfig = VideoCameraConfiguration()
cameraConfig.cameraDelegate = self
cameraConfig.captureSessionPreset = .high
cameraConfig.capturePhotoEnabled = false
cameraConfig.videoFeedDelegate = self
cameraConfig.simulatedImage = UIImage(named: "card_backside.png")?.cgImage
let videoCamera = VideoCameraFactory.createCamera(configuration: cameraConfig)
camera = videoCamera
// ...
}
```To display camera preview, one of the simplest ways is to prepare container view in storyboard and than add camera's preview to it:
```swift
@IBOutlet private var cameraPreviewContainerView: UIView!override func viewDidLoad() {
super.viewDidLoad()
// setup camera (see above)let preview = videoCamera.previewView
preview.translatesAutoresizingMaskIntoConstraints = true
preview.autoresizingMask = [UIViewAutoresizing.flexibleHeight, UIViewAutoresizing.flexibleWidth]
preview.frame = cameraPreviewContainerView.bounds
cameraPreviewContainerView.insertSubview(preview, at: 0)
// ...
}
```Changes of camera's properties are observed via delegate:
```swift
extension MyViewController: VideoCameraDelegate {func videoCamera(_ videoCamera: VideoCamera, error: Error) {
// display/process error
}func videoCameraInitialized(_ videoCamera: VideoCamera, errors: [VideoCameraError]) {
// update UI - such as flash button (with actual state of camera)
}func videoCamera(_ videoCamera: VideoCamera, flashModeForPhotoDidChanged newValue: AVCaptureDevice.FlashMode) {
// update flash button
}
// ... other delegate functions
}
```Have a look at the [VideoCamera_Example](https://github.com/shakurocom/VideoCamera/tree/master/VideoCamera_Example)
## License
Shakuro.VideoCamera is released under the MIT license. [See LICENSE](https://github.com/shakurocom/VideoCamera/blob/master/LICENSE.md) for details.
## Give it a try and reach us
Star this tool if you like it, it will help us grow and add new useful things.
Feel free to reach out and hire our team to develop a mobile or web project for you.