在GPUImage iOS中不显示文本叠加

我正在尝试在video上叠加一些文字,至今尚未取得任何成效。

videoCamera = [[GPUImageStillCamera alloc] initWithSessionPreset:AVCaptureSessionPreset640x480 cameraPosition:AVCaptureDevicePositionBack]; videoCamera.outputImageOrientation = UIInterfaceOrientationPortrait; cropFilter = [[GPUImageCropFilter alloc] initWithCropRegion:CGRectMake(0, 0, 1, 1)]; mCurrentImage = [UIImage imageNamed:@"tex16"]; sourcePicture = [[GPUImagePicture alloc] initWithImage:mCurrentImage smoothlyScaleOutput:NO]; [sourcePicture processImage]; customFilter = [[GPUFilter alloc] initWithFragmentShaderFromFile:@"shader"]; [videoCamera addTarget:cropFilter]; [cropFilter addTarget:customFilter atTextureLocation:0]; [sourcePicture addTarget:customFilter atTextureLocation:1]; [customFilter addTarget:mViewCameraPreview];//(GPUImageView*)mViewCameraPreview]; blendFilter = [[GPUImageAlphaBlendFilter alloc] init]; blendFilter.mix = 1.0; UILabel *timeLabel = [[UILabel alloc] initWithFrame:CGRectMake(0.0, 0.0, 240.0f, 320.0f)]; timeLabel.font = [UIFont systemFontOfSize:17.0f]; timeLabel.text = @"Time: 0.0 s"; timeLabel.textAlignment = NSTextAlignmentCenter; timeLabel.backgroundColor = [UIColor clearColor]; timeLabel.textColor = [UIColor whiteColor]; uiElementInput = [[GPUImageUIElement alloc] initWithView:timeLabel]; [customFilter addTarget:blendFilter]; [uiElementInput addTarget:blendFilter]; [blendFilter addTarget:mViewCameraPreview]; [videoCamera startCameraCapture]; 

一切顺利并且运行,不会抛出任何exception,但是没有文本被发现。

有没有人看到我在做什么错了?

谢谢。

开始相机捕捉后,您是否尝试执行UIElementInput的更新? 如果不是,请尝试在您提供的代码末尾添加此代码。

 __unsafe_unretained GPUImageUIElement *weakUIElementInput = uiElementInput; [filter setFrameProcessingCompletionBlock:^(GPUImageOutput * filter, CMTime frameTime){ [weakUIElementInput update]; }]; 

如果它不工作,或者你已经做了,你应该尝试一个基本的filter(没有自定义filter),看看问题是否依然存在。