I am trying to create a filter for my program (which streams a webcam) which makes the frame flip horizontally, making the webcam act like a mirror.
However, while it compiles and runs, the filter does not seem to have any effect on it.
Here is the code:
CIImage *resultImage = image;
CIFilter *flipFilter = [CIFilter filterWithName:@"CIAffineTransform"];
[flipFilter setValue:resultImage forKey:@"inputTransform"];
NSAffineTransform* flipTransform = [NSAffineTransform transform];
[flipTransform scaleXBy:-1.0 yBy:1.0]; //horizontal flip
[flipFilter setValue:flipTransform forKey:@"inputTransform"];
resultImage = [flipFilter valueForKey:@"outputImage"];
Strangely enough, other filters appear to work. For example:
CIFilter * ciEffectFilter = [CIFilter filterWithName:@"CIGloom"];
[ciEffectFilter setDefaults];
CIImage *resultImage = image;
[ciEffectFilter setValue: resultImage forKey:@"inputImage"];
[ciEffectFilter setValue:[NSNumber numberWithFloat: 0.75]
forKey:@"inputIntensity"];
[ciEffectFilter setValue:[NSNumber numberWithFloat: 20]
forKey:@"inputRadius"];
resultImage = [ciEffectFilter valueForKey:@"outputImage"];
CIFilter *ciCropFilter = [CIFilter filterWithName:@"CICrop"];
[ciCropFilter setDefaults];
[ciCropFilter setValue: resultImage forKey:@"inputImage"];
[ciCropFilter setValue: [CIVector vectorWithX:50 Y:50 Z:300 W:
300] forKey:@"inputRectangle"];
resultImage = [ciCropFilter valueForKey:@"outputImage"];
Is it something to do with NSAffineTransform? I have looked around, but I have not found any answers. Thanks heaps!
[NSValue valueWithBytes:&flipTransform objCType:@encode(CGAffineTransform)];
– Yungyunick