Reputation: 11799
I'm trying to do the following to display an image instead of trying to access video when TARGET_IPHONE_SIMULATOR
is true.
UIImage *image = [UIImage imageNamed:@"fake_camera"];
GPUImagePicture *fakeInput = [[GPUImagePicture alloc] initWithImage:image];
GPUImageBuffer *videoBuffer = [[GPUImageBuffer alloc] init];
[fakeInput processImage];
[fakeInput addTarget:videoBuffer];
[videoBuffer addTarget:self.backgroundImageView]; //backgroundImageView is a GPUImageView
This renders my backgroundImageView
in black color without displaying my image.
If I send the output of fakeInput
to backgroundImageView
directly, I see the picture rendered normally in backgroundImageView
.
What's going on here?
EDIT:
As Brad recommended I tried:
UIImage *image = [UIImage imageNamed:@"fake_camera"];
_fakeInput = [[GPUImagePicture alloc] initWithImage:image];
GPUImagePicture *secondFakeInput = [[GPUImagePicture alloc] initWithImage:image];
[_fakeInput processImage];
[secondFakeInput processImage];
[_fakeInput addTarget:_videoBuffer];
[secondFakeInput addTarget:_videoBuffer];
[_videoBuffer addTarget:_backgroundImageView];
I also tried:
UIImage *image = [UIImage imageNamed:@"fake_camera"];
_fakeInput = [[GPUImagePicture alloc] initWithImage:image];
[_fakeInput processImage];
[_fakeInput processImage];
[_fakeInput addTarget:_videoBuffer];
[_videoBuffer addTarget:_backgroundImageView];
None of this two approaches seems to work... should they?
Upvotes: 0
Views: 415
Reputation: 170319
A GPUImageBuffer does as its name suggests, it buffers frames. If you send a still photo to it, that one image is buffered, but is not yet sent out. You'd need to send a second image into it (or use -processImage
a second time) to get the default buffer of one frame deep to display your original frame.
GPUImageBuffer really doesn't serve any purpose for still images. It's intended as a frame-delaying operation for video in order to do frame-to-frame comparisons, like a low-pass filter. If you need to do frame comparisons of still images, a blend is a better way to go.
Upvotes: 1