1

My camera app captures a photo, enhances it in a certain way, and saves it.

To do so, I get the input image from the camera in the form of a CVPixelBuffer (wrapped in a CMSampleBuffer). I perform some modifications on the pixel buffer, and I then want to convert it to a Data object. How do I do this?

Note that I don't want to convert the pixel buffer / image buffer to a UIImage or CGImage since those don't have metadata (like EXIF). I need a Data object. How do I get one from a CVPixelBuffer / CVImageBuffer?


PS: I tried calling AVCapturePhotoOutput.jpegPhotoDataRepresentation() but that fails saying "Not a JPEG sample buffer". Which makes sense since the CMSampleBuffer contains a pixel buffer (a bitmap), not a JPEG.

Kartick Vaddadi
  • 4,818
  • 6
  • 39
  • 55

1 Answers1

0

As you said that you are able to get the CMSampleBuffer, then you can get it using

NSData *myata = [AVCaptureStillImageOutput jpegStillImageNSDataRepresentation:<your_cmsample_buffer_obj‌​>];
bestiosdeveloper
  • 2,339
  • 1
  • 11
  • 28