title: Get pixel value from CVPixelBufferRef in Swift
body: <p>How can I get the RGB (or any other format) pixel value from a CVPixelBufferRef? Ive tried many approaches but no success yet.</p>
  
  <pre><code>func captureOutput(captureOutput: AVCaptureOutput!,
                     didOutputSampleBuffer sampleBuffer: CMSampleBuffer!,
                     fromConnection connection: AVCaptureConnection!) {
    let pixelBuffer: CVPixelBufferRef = CMSampleBufferGetImageBuffer(sampleBuffer)!
                  CVPixelBufferLockBaseAddress(pixelBuffer, 0)
    let baseAddress = CVPixelBufferGetBaseAddress(pixelBuffer)
  
    //Get individual pixel values here
  
    CVPixelBufferUnlockBaseAddress(pixelBuffer, 0)
  }
  </code></pre>