我正在与cocoapods合作开发一个Swift项目.这是Podfile:
pod 'GPUImage', '~> 0.1.4'
Run Code Online (Sandbox Code Playgroud)
运行后pod install,我尝试得到导入文件的错误:
导入GPUImage

我从podfile中卸载了GPUImage,然后尝试第二个解决方案,我得到了不同的错误.
这个链接是github上的项目指令.我的步骤是:
将GPUImage.xcodeproj复制并粘贴到项目根目录中,并将其添加到我的项目中.
转到" 构建设置 " - >" 构建阶段 " - >" 目标依赖项 ",添加PUImageFramework,在Link Binary With Libraries部分,添加了GPUImage.framework.
但我得到一个错误:
error: unable to read module map contents from 'Source/iOS/Framework/module.modulemap': Error Domain=NSCocoaErrorDomain Code=260 "The file “module.modulemap” couldn’t be opened because there is no such file." UserInfo=0x7f872cfb0b80 {NSFilePath=/Users/william/A/muguang-ios/Source/iOS/Framework/module.modulemap, NSUnderlyingError=0x7f87413f4dd0 "The operation couldn’t be completed. No such file or directory"}
Run Code Online (Sandbox Code Playgroud)
任何帮助,thx!
编辑:
现在的错误是:
dyld: Library …Run Code Online (Sandbox Code Playgroud) 我试图使用GPUImage框架的GPUImagePoissonBlendFilter来混合我的面部混合应用程序中的两个面.这是我的代码.
- (void)applyPoissonBlendToImage:(UIImage *) rearFace withImage:(UIImage *) frontFace
{
GPUImagePicture* picture1 = [[GPUImagePicture alloc] initWithImage:rearFace];
GPUImagePicture* picture2 = [[GPUImagePicture alloc] initWithImage:frontFace];
GPUImagePoissonBlendFilter * poissonFilter = [[GPUImagePoissonBlendFilter alloc] init];
poissonFilter.mix = .7;
poissonFilter.numIterations = 200;
[picture1 addTarget:poissonFilter];
[picture1 processImage];
[picture2 addTarget:poissonFilter];
[picture2 processImage];
finalResultImage = [poissonFilter imageFromCurrentlyProcessedOutputWithOrientation:rearFace.imageOrientation];
}
Run Code Online (Sandbox Code Playgroud)
即如你所见,我给出了两个图像(rearFace和frontFace)作为此方法的输入.图像正面是一种形状(通过连接相对的眼睛和嘴部位置形成的多边形形状),并且具有与后面图像相同的尺寸i.(为了匹配尺寸,我填充了多边形外部的空间绘图时用透明的颜色).
然而,混合不会像我预期的那样发生.即正面的锋利边缘没有适当地混入后面.在这里,我的假设是PoissonBlendFilter开始从其左上角而不是面部的左上边界混合第二个图像.
问题:我觉得输入图像没有正确送入滤镜.我是否需要对输入图像应用某种掩模?任何人都可以指导我吗?
我有一个几乎是平面颜色的图像.它附着但是纯白色,所以你不能轻易看到它.
我希望能够在运行时动态地为该图像着色,但我需要在iOS 6中不使用UIImageRenderingModeAlwaysTemplate.
图像将全部以纯白色开始,具有圆角的小渐变.
到目前为止,我最好的尝试是在UIImage上使用GPUImage和一个类别
@implementation UIImage (BPAdditions)
- (UIImage *)imageWithColor:(UIColor *)color
{
GPUImageRGBFilter *stillImageFilter = [[GPUImageRGBFilter alloc] init];
CGFloat red = 0.0, green = 0.0, blue = 0.0, alpha =0.0;
[color getRed:&red green:&green blue:&blue alpha:&alpha];
stillImageFilter.red = red;
stillImageFilter.green = green;
stillImageFilter.blue = blue;
GPUImageChromaKeyFilter *stillImageFilter2 = [[GPUImageChromaKeyFilter alloc] init];
[stillImageFilter2 setColorToReplaceRed:0 green:0 blue:0];
stillImageFilter2.thresholdSensitivity = 0.2;
stillImageFilter2.smoothing = 0;
UIImage *img = [stillImageFilter imageByFilteringImage:self];
return [stillImageFilter2 imageByFilteringImage: img];
}
Run Code Online (Sandbox Code Playgroud)
这将是理想的,除非我使用RGB滤镜时将透明背景变为黑色.然后使用色度滤光片将其去除根据使用的颜色具有不同的质量.
目标颜色有可能是黑色,在这种情况下,该解决方案将完全失败.
我正在尝试使用几个GPUImagePictures作为纹理源以及片段着色器来过滤播放视频.
我能够以这种方式处理静止图像,但我似乎无法弄清楚我缺少什么才能让它工作,GPUImageMovie我很感激任何提供的帮助.
@property (nonatomic, strong) GPUImageView *gpuPlayerView;
@property (nonatomic, strong) GPUImageMovie *gpuMovie;
AVPlayerItem *playerItem = [AVPlayerItem playerItemWithAsset:self.video];
self.player = [AVPlayer playerWithPlayerItem:playerItem];
self.player.actionAtItemEnd = AVPlayerActionAtItemEndNone;
[self.player play];
self.gpuMovie = [[GPUImageMovie alloc]initWithPlayerItem:playerItem];
self.gpuMovie.playAtActualSpeed = YES;
GPUImagePicture *sourcePicture1 = [[GPUImagePicture alloc]initWithImage:
[UIImage imageNamed:@"FilterBG"]];
GPUImagePicture *sourcePicture2 = [[GPUImagePicture alloc]initWithImage:
[UIImage imageNamed:@"FilterOverlay"]];
GPUImagePicture *sourcePicture3 = [[GPUImagePicture alloc]initWithImage:
[UIImage imageNamed:@"Filter1Map"]];
GPUImageFilter *filter = [[GPUImageFourInputFilter alloc]initWithFragmentShaderFromString:
kFilter1ShaderString];
[self.gpuMovie addTarget:filter atTextureLocation:0];
if (sourcePicture1)
{
[sourcePicture1 addTarget:filter atTextureLocation:1];
}
if (sourcePicture2)
{
[sourcePicture2 addTarget:filter atTextureLocation:2]; …Run Code Online (Sandbox Code Playgroud) 我正在使用GPUImage框架(一些旧版本)来混合两个图像(将边框叠加添加到某个图像).在我更新到最新的框架版本后,应用这样的混合后,我得到一个空的黑色图像.
我正在使用下一个方法:
- (void)addBorder {
if (currentBorder != kBorderInitialValue) {
GPUImageAlphaBlendFilter *blendFilter = [[GPUImageAlphaBlendFilter alloc] init];
GPUImagePicture *imageToProcess = [[GPUImagePicture alloc] initWithImage:self.imageToWorkWithView.image];
GPUImagePicture *border = [[GPUImagePicture alloc] initWithImage:self.imageBorder];
blendFilter.mix = 1.0f;
[imageToProcess addTarget:blendFilter];
[border addTarget:blendFilter];
[imageToProcess processImage];
self.imageToWorkWithView.image = [blendFilter imageFromCurrentlyProcessedOutput];
[blendFilter release];
[imageToProcess release];
[border release];
}
}
Run Code Online (Sandbox Code Playgroud)
问题是什么?
我正在尝试从Android的GPUImage(ios)重新创建GPUImageTwoPassFilter .我正在完成这里为GPUImage的Android端口所做的工作.该端口实际上适用于许多过滤器.我已经移植了很多着色器,基本上都是排队的,取得了巨大的成功.
问题是要移植一些过滤器,你必须从GPUImage扩展GPUImageTwoPassFilter,而android版本的作者尚未实现.我想写一下它,但不幸的是iOS版本没有文档,所以我不确定TwoPass过滤器应该做什么.
有没有人有任何关于这个的提示?我对openGL知之甚少,但对Android和iOS非常了解.我肯定在这里寻找一个非常的psudocode描述
我想实现一个名片检测功能,如这个应用程序(https://scanbot.io).相机应该检测到一张名片并自动拍照(只有名片).

我的想法是使用BradLarson's GPUImage库,检测角落(使用Harris角点检测算法),计算获得角落的最大矩形并裁剪矩形内的图像.
这是我的代码:
- (void)setupFilter {
videoCamera = [[GPUImageVideoCamera alloc] initWithSessionPreset:AVCaptureSessionPreset640x480 cameraPosition:AVCaptureDevicePositionBack];
filter = [[GPUImageHarrisCornerDetectionFilter alloc] init];
[(GPUImageHarrisCornerDetectionFilter *)filter setThreshold:0.01f];
[(GPUImageHarrisCornerDetectionFilter *)filter setSensitivity:0.5f];
[(GPUImageHarrisCornerDetectionFilter *)filter setBlurRadiusInPixels:2.0f];
[videoCamera addTarget:filter];
videoCamera.runBenchmark = YES;
GPUImageView *filterview = [[GPUImageView alloc] init];
self.view=filterview;
GPUImageCrosshairGenerator *crosshairGenerator = [[GPUImageCrosshairGenerator alloc] init];
crosshairGenerator.crosshairWidth = 22.0;
[crosshairGenerator forceProcessingAtSize:CGSizeMake(480.0, 640.0)];
[(GPUImageHarrisCornerDetectionFilter *)filter setCornersDetectedBlock:^(GLfloat* cornerArray, NSUInteger cornersDetected, CMTime frameTime) {
[crosshairGenerator renderCrosshairsFromArray:cornerArray count:cornersDetected frameTime:frameTime];
}];
GPUImageAlphaBlendFilter *blendFilter = [[GPUImageAlphaBlendFilter alloc] init];
[blendFilter forceProcessingAtSize:CGSizeMake(480.0, 640.0)];
GPUImageGammaFilter *gammaFilter …Run Code Online (Sandbox Code Playgroud) 我想用chromakey过滤器处理视频,输出应该在屏幕上重现.
我开发的代码下面没有显示任何视频,我无法理解为什么:
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
let aSelector : Selector = "start:"
let tapGesture = UITapGestureRecognizer(target: self, action: aSelector)
tapGesture.numberOfTapsRequired = 1
view.addGestureRecognizer(tapGesture)
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
@IBAction func start(sender: AnyObject) {
NSLog("tap pressed")
play()
}
func play(){
let path = NSBundle.mainBundle().pathForResource("glass_buster", ofType: "mp4")
let player = AVPlayer()
let pathURL = NSURL.fileURLWithPath(path!)
NSLog(pathURL.absoluteString)
let …Run Code Online (Sandbox Code Playgroud) 我正在使用OpenTok并用我自己的包含GPUImage的子类版本替换了他们的Publisher.我的目标是添加过滤器.
应用程序构建并运行,但崩溃在这里:
func willOutputSampleBuffer(sampleBuffer: CMSampleBuffer!) {
let imageBuffer = CMSampleBufferGetImageBuffer(sampleBuffer)
CVPixelBufferLockBaseAddress(imageBuffer!, 0)
videoFrame?.clearPlanes()
for var i = 0 ; i < CVPixelBufferGetPlaneCount(imageBuffer!); i++ {
print(i)
videoFrame?.planes.addPointer(CVPixelBufferGetBaseAddressOfPlane(imageBuffer!, i))
}
videoFrame?.orientation = OTVideoOrientation.Left
videoCaptureConsumer.consumeFrame(videoFrame) //comment this out to stop app from crashing. Otherwise, it crashes here.
CVPixelBufferUnlockBaseAddress(imageBuffer!, 0)
}
Run Code Online (Sandbox Code Playgroud)
如果我评论该行,我就可以运行应用程序而不会崩溃.事实上,我看到过滤器正确应用,但它正在闪烁.Nothings发布到Opentok.
我的整个代码库都可以下载.单击此处查看特定文件:这是该类的特定文件.它实际上很容易运行 - 只需在运行之前进行pod安装.
经过检查,可能videoCaptureConsumer是没有初始化.协议参考
我不知道我的代码意味着什么.我直接从这个客观的C文件中翻译了它:Tokbox的示例项目
添加GPUImage到我的Xcode项目后,我的应用因缺少的Info.plist密钥而被拒绝NSCameraUsageDescription。
Info.plist密钥丢失-该应用尝试访问对隐私敏感的数据,而没有使用说明。该应用程序Info.plist必须包含一个NSCameraUsageDescription带有字符串值的 键,该字符串值会向用户说明该应用程序如何使用此数据。
我以几种不同的方式将密钥和说明添加到了我的plist中,并且超过10个版本都遇到了相同的拒绝错误。
这是我的,info.plist带有底部的“相机使用情况”键。
当我在plist中明确定义了为什么仍然拒绝我的任何想法?