Browse and view Quicktime Quicktime

I need to horizontally flip some video that I view and capture. A-la iChat, I have a webcam and want it to look like the user is looking in the mirror.

I watch Quicktime video in format QTCaptureView. My capture is done frame by frame (for reasons that I won’t go into), with something like:

imageRep = [NSCIImageRep imageRepWithCIImage: [CIImage imageWithCVImageBuffer: frame]];
image = [[NSImage alloc] initWithSize: [imageRep size]];
[image addRepresentation: imageRep];
[movie addImage: image forDuration: someDuration withAttributes: someAttributes];

Any tips?

+2
source share
3 answers

You can do this by taking the CIImage you get from the capture and run it through the Core Image filter to flip the image. Then you will transfer the resulting image to the image, not to the original one. The code will look something like this:

CIImage* capturedImage = [CIImage imageWithCVImageBuffer:buffer];
NSAffineTransform* flipTransform = [NSAffineTransform transform];
CIFilter* flipFilter;
CIImage* flippedImage;

[flipTransform scaleByX:-1.0 y:1.0]; //horizontal flip
flipFilter = [CIImage filterWithName:@"CIAffineTransform"];
[flipFilter setValue:flipTransform forKey:@"inputTransform"];
[flipFilter setValue:capturedImage forKey:@"inputImage"];
flippedImage = [flipFilter valueForKey:@"outputImage"];
imageRep = [NSCIImageRep imageRepWithCIImage:flippedImage];
...
+3
source

. , , , - , , QTCaptureView:

- (CIImage *)view:(QTCaptureView *)view willDisplayImage:(CIImage *)image {
//mirror image across y axis
return [image imageByApplyingTransform:CGAffineTransformMakeScale(-1, 1)];
}
+10

Try it! it will apply filters to CaptureView, but not to the output video.

- (IBAction)Vibrance:(id)sender
{
    CIFilter* CIVibrance = [CIFilter filterWithName:@"CIVibrance" keysAndValues:
                            @"inputAmount", [NSNumber numberWithDouble:2.0f],
                            nil];
    mCaptureView.contentFilters = [NSArray arrayWithObject:CIVibrance];
}

btw, you can apply any filters from this link: https://developer.apple.com/library/mac/#documentation/graphicsimaging/reference/CoreImageFilterReference/Reference/reference.html

0
source

All Articles