Skip to content

yoshimin/MetalCamera

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MetalCamera

Camera app using MetalKit

  1. Go to the storyboard and select the View under the View Controller as set its class to a MetalView type under Identity Inspector as seen in the image below.

  1. Create CVPixelBuffer with CMSampleBuffer return from method AVCaptureVideoDataOutputSampleBufferDelegate.
  2. Set the CVPixelBuffer into MetalView.
func captureOutput(_ captureOutput: AVCaptureOutput!, didOutputSampleBuffer sampleBuffer: CMSampleBuffer!, from connection: AVCaptureConnection!) {
    let metalView =  view as! MetalView
    metalView.setPixelBuffer(CMSampleBufferGetImageBuffer(sampleBuffer)!)
}
  1. Call snapshot() to take a photo.
@IBAction func snapshot(_ sender: Any) {
    let metalView =  view as! MetalView
    UIImageWriteToSavedPhotosAlbum(metalView.snapshot(), nil, nil, nil);
}

About

Camera app using MetalKit

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors