Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>If you are trying to manipulate the pixels, you could put the following method in the class you are assigning as delegate to AVCaptureVideoDataOutputSampleBufferDelegate:</p> <pre><code>-(void) captureOutput:(AVCaptureOutput *)captureOutput didOutputSampleBuffer:(CMSampleBufferRef)sampleBuffer fromConnection:(AVCaptureConnection *)connection { CVImageBufferRef pb = CMSampleBufferGetImageBuffer(sampleBuffer); if(CVPixelBufferLockBaseAddress(pb, 0)) //zero is success NSLog(@"Error"); size_t bufferHeight = CVPixelBufferGetHeight(pb); size_t bufferWidth = CVPixelBufferGetWidth(pb); size_t bytesPerRow = CVPixelBufferGetBytesPerRow(pb); unsigned char* rowBase= CVPixelBufferGetBaseAddress(pb); CGColorSpaceRef colorSpace=CGColorSpaceCreateDeviceRGB(); if (colorSpace == NULL) NSLog(@"Error"); // Create a bitmap graphics context with the sample buffer data. CGContextRef context= CGBitmapContextCreate(rowBase,bufferWidth,bufferHeight, 8,bytesPerRow, colorSpace, kCGImageAlphaNone); // Create a Quartz image from the pixel data in the bitmap graphics context CGImageRef quartzImage = CGBitmapContextCreateImage(context); UIImage *currentImage=[UIImage imageWithCGImage:quartzImage]; // Free up the context and color space CFRelease(quartzImage); CGContextRelease(context); CGColorSpaceRelease(colorSpace); if(CVPixelBufferUnlockBaseAddress(pb, 0 )) //zero is success NSLog(@"Error"); } </code></pre> <p>And then hookup that image to an UIImageView in your View controller. Lookinto the kCGImageAlphaNone flag. It will depend what you are doing.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload