Search code examples
iosgpuimage

why is my mask scaling when using it with GPUImageMaskFilter?


I have a video camera input masking just fine, however my mask isn't showing as expected. I have 2 versions sized according to the different form factors. Testing on the iPhone 5, the mask image looks like this (regular size shown here, there is a @2x version that is just scaled):

enter image description here

However my preview looks like this:

enter image description here

See how the mask is being scaled and altered? Why is this happening?

_camera = [[GPUImageVideoCamera alloc] initWithSessionPreset:AVCaptureSessionPresetHigh cameraPosition:AVCaptureDevicePositionBack];
_camera.outputImageOrientation = UIInterfaceOrientationLandscapeRight;

GPUImageMaskFilter *maskFilter = [[GPUImageMaskFilter alloc] init];
[maskFilter setBackgroundColorRed:0.7 green:0.7 blue:0.7 alpha:1.0];

[_camera addTarget:maskFilter];

CGRect screenRect = [[UIScreen mainScreen] bounds];
CGFloat screenHeight = screenRect.size.height;
NSString *imageName = (screenHeight == 568 ? @"TallCheckMask" : @"ShortCheckMask");
UIImage *inputImage = [UIImage imageNamed:imageName];
sourcePicture = [[GPUImagePicture alloc] initWithImage:inputImage smoothlyScaleOutput:YES];
[sourcePicture processImage];
[sourcePicture addTarget:maskFilter];

[maskFilter addTarget:_backgroundImageView];
[_camera startCameraCapture];

Solution

  • Mask is portrait while the preview is landscape. Mask is not rotated.