ImageTargetCvPixelBuffer to CIImage


#1

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]

#2

solved. looks like I was missing:

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

before:

CVPixelBufferRef pbr = r->getCvPixelBuffer();