title: How to convert from YUV to CIImage for iOS
body: <p>I am trying to convert a YUV image to CIIMage and ultimately UIImage. I am fairly novice at these and trying to figure out an easy way to do it. From what I have learnt, from iOS6 YUV can be directly used to create CIImage but as I am trying to create it the CIImage is only holding a nil value. My code is like this -> </p>
  
  <pre><code>NSLog(@"Started DrawVideoFrame\n");
  
  CVPixelBufferRef pixelBuffer = NULL;
  
  CVReturn ret = CVPixelBufferCreateWithBytes(
                                              kCFAllocatorDefault, iWidth, iHeight, kCVPixelFormatType_420YpCbCr8BiPlanarFullRange,
                                              lpData, bytesPerRow, 0, 0, 0, &amp;pixelBuffer
                                              );
  
  if(ret != kCVReturnSuccess)
  {
      NSLog(@"CVPixelBufferRelease Failed");
      CVPixelBufferRelease(pixelBuffer);
  }
  
  NSDictionary *opt =  @{ (id)kCVPixelBufferPixelFormatTypeKey :
                        @(kCVPixelFormatType_420YpCbCr8BiPlanarFullRange) };
  
  CIImage *cimage = [CIImage imageWithCVPixelBuffer:pixelBuffer options:opt];
  NSLog(@"CURRENT CIImage -&gt; %p\n", cimage);
  
  UIImage *image = [UIImage imageWithCIImage:cimage scale:1.0 orientation:UIImageOrientationUp];
  NSLog(@"CURRENT UIImage -&gt; %p\n", image);
  </code></pre>
  
  <p>Here the lpData is the YUV data which is an array of unsigned character.</p>
  
  <p>This also looks interesting : <strong>vImageMatrixMultiply</strong>, can't find any example on this. Can anyone help me with this?</p>