# ImageTargetCvPixelBuffer to CIImage

**URL:** <https://discourse.libcinder.org/t/imagetargetcvpixelbuffer-to-ciimage/664>\
**Category:** Uncategorized\
**Created:** [April 20, 2017, 4:04am UTC](https://discourse.libcinder.org/t/imagetargetcvpixelbuffer-to-ciimage/664 "2017-04-20T04:04:30Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![hhit](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.libcinder.org/hhit/32/303_2.png) [@hhit](https://discourse.libcinder.org/u/hhit)\
**Post date:** [April 20, 2017, 4:04am UTC](https://discourse.libcinder.org/t/imagetargetcvpixelbuffer-to-ciimage/664/1 "2017-04-20T04:04:30Z")

</div>

I’m trying to create a CIImage from a ImageTargetCvPixelBuffer.

```
gl::FboRef fbo = gl::Fbo::create (334, 539);
fbo->bindFramebuffer();
    
gl::clear (Color::black());
    
gl::color (Color::hex (0xff66ffcc));
gl::drawLine (vec2 (0.0f, 0.0f), vec2 (fbo->getWidth(), fbo->getHeight()));
    
fbo->unbindFramebuffer();
    
ImageSourceRef sourceRef = fbo->getColorTexture()->createSource();
    
ci::qtime::ImageTargetCvPixelBufferRef r = ci::qtime::ImageTargetCvPixelBuffer::createRef (sourceRef);
CVPixelBufferRef pbr = r->getCvPixelBuffer();
    
CIImage* ciImage = [[CIImage alloc] initWithCVPixelBuffer: pbr];
NSLog (@"ci.extent: %@", NSStringFromCGRect (ciImage.extent));

```

When I inspect the result I get a CIImage with the correct size but it’s empty.

```
Printing description of ciImage:

    <CIImage: 0x174201ff0 extent [0 0 334 539]>
    affine [1 0 0 -1 0 539] extent=[0 0 334 539]
    colormatch "sRGB IEC61966-2.1"-to-workingspace extent=[0 0 334 539]
    provider ARGB8 extent=[0 0 334 539]
```

---

<div class="post-metadata">

**Author:** ![hhit](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.libcinder.org/hhit/32/303_2.png) [@hhit](https://discourse.libcinder.org/u/hhit)\
**Post date:** [April 20, 2017, 4:43am UTC](https://discourse.libcinder.org/t/imagetargetcvpixelbuffer-to-ciimage/664/2 "2017-04-20T04:43:52Z")

</div>

solved. looks like I was missing:

```
sourceRef->load (r);
r->finalize();

```

before:

```
CVPixelBufferRef pbr = r->getCvPixelBuffer();
```
