2016-07-09 19 views
3

ビデオにテキストをオーバーレイしようとしていますが、これまでに何も成功していません。GPUImage iOSでテキストオーバーレイが表示されない

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]; 

すべてが例外をスローせずに実行されますが、見つかるテキストはありません。

誰かが私が間違っているのを見ていますか?

ありがとうございました。

+0

cropFilterが小さすぎます。それは1x1です。 CGRectMake(0,0,1,1)。 – WasimSafdar

答えて

1

カメラのキャプチャを開始した直後にUIElementInputのアップデートを実行しましたか?そうでない場合は、提供したコードの最後にこのコードを追加してください。

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

それが動作しないか、あなたはすでにそれをやってきた場合、あなたは問題が解決しないかどうかを確認するための基本的なフィルタ(なしカスタムフィルタ)で試してみてください場合。

関連する問題