Flickering video when using crop.

4 replies [Last post]
mrEmpty
User offline. Last seen 8 years 44 weeks ago. Offline
Joined: 07/16/2012
Posts:

Hello.

I'm filtering live video, the last chain of filters is a crop. However the video 'flickers' between the cropped (1:1) and non-cropped (16:9) video rapidly. It will then settle to the cropped output for a second or two, then start flickering again. Any ideas why?

Code:

videoCamera = [[GPUImageVideoCamera alloc] initWithSessionPreset:AVCaptureSessionPreset640x480 cameraPosition:AVCaptureDevicePositionBack];
 
    videoCamera.outputImageOrientation = UIInterfaceOrientationPortrait;
 
    filter = [[GPUImageSepiaFilter alloc] init];
    crop = [[GPUImageCropFilter alloc] init];
    [crop setCropRegion:CGRectMake(0.0, 0.12, 1, 0.75)];
 
    [videoCamera addTarget:filter];
    [videoCamera addTarget:crop];
 
    filteredVideoView = [[GPUImageView alloc] initWithFrame:viewBox.frame];
    [self.viewBox addSubview:filteredVideoView];
 
    [filter addTarget:filteredVideoView];
    [crop addTarget:filteredVideoView];
 
    [videoCamera startCameraCapture];
 
<code>

Brad Larson
Brad Larson's picture
User offline. Last seen 4 years 22 weeks ago. Offline
Joined: 05/14/2008
Posts:

Is this with the very latest code from the repository? The crop filter was slightly broken, so I repaired part of it last night. If you're not already, try with the latest code.

mrEmpty
User offline. Last seen 8 years 44 weeks ago. Offline
Joined: 07/16/2012
Posts:

Same things happens with latest version I'm afraid.

Brad Larson
Brad Larson's picture
User offline. Last seen 4 years 22 weeks ago. Offline
Joined: 05/14/2008
Posts:

Oh, I see it now. You don't have your filter chain set up properly. If you want to apply a sepia tone filter, then a crop filter, you need to do them in order. Right now, you have both filters running in parallel and both outputting to the view. This shouldn't work at all, as the view only takes one input, but I think the crop is sometimes overriding the sepia tone on the input.

What you need to do is set the crop as the target of the camera, set the sepia tone as the target of the crop, and then set the view as the target of the sepia tone. That way, you have the proper linear chain.

mrEmpty
User offline. Last seen 8 years 44 weeks ago. Offline
Joined: 07/16/2012
Posts:

Ahh, ok, the chains make sense now. Thank you, I can now have a real play.

Syndicate content