翻转Quicktime预览&捕获 [英] Flipping Quicktime preview & capture

查看:139
本文介绍了翻转Quicktime预览&捕获的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要水平翻转我预览和捕获的视频。

I need to horizontally flip some video I'm previewing and capturing. A-la iChat, I have a webcam and want it to appear as though the user is looking in a mirror.

我在一个<$ c中预览Quicktime视频$ c> QTCaptureView 。我的捕获是逐帧的(因为我不会进入)与类似:

I'm previewing Quicktime video in a QTCaptureView. My capturing is done frame-by-frame (for reasons I won't get 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];

任何提示?

推荐答案

您可以通过使用CIImage从捕获中获取并通过Core Image过滤器运行它来翻转图像。然后,您将生成的图像传递到您的映像代理,而不是原始的。代码看起来像这样:

You could do this by taking the CIImage you're getting from the capture and running it through a Core Image filter to flip the image around. You would then pass the resulting image into your image rep rather than the original one. The code would look something like:

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

这篇关于翻转Quicktime预览&amp;捕获的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆