- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我一直在尝试弄清楚 GPUImage 是否有一个开箱即用的解决方案来满足我想要做的事情。
我有 2 个 LUT 和一个视频文件。目前,我能够成功播放视频文件,并使用 GPUImageView、GPUImageMovie、GPUImagePicture 和 GPUImageLookupFilter 的组合通过两个 LUT 对其进行过滤。
这就是我目前正在做的事情,并且效果很好:
lutPicture1 = [[GPUImagePicture alloc] initWithImage:lutImage1];
lutPicture2 = [[GPUImagePicture alloc] initWithImage:lutImage2];
lutFilter1 = [[GPUImageLookupFilter alloc] init];
lutFilter2 = [[GPUImageLookupFilter alloc] init];
playerItem = [[AVPlayerItem alloc] initWithURL:fileURL];
player = [[AVPlayer alloc] initWithPlayerItem:playerItem];
GPUImageMovie *gpuImageMovie = [[GPUImageMovie alloc] initWithPlayerItem:playerItem];
[gpuImageMovie addTarget: lutFilter1];
[lutPicture1 addTarget: lutFilter1];
[lutPicture1 processImage];
[lutFilter1 addTarget: lutFilter2];
[lutPicture2 addTarget: lutFilter2];
[lutPicture2 processImage];
[lutFilter2 addTarget: gpuImageView];
[gpuImageMovie startProcessing];
[player play];
如果我错了,请纠正我,但输出将是首先将其通过名为“lutFilter1”的过滤器传递,然后将其输出传递通过“lutFilter2”的结果。
但是,我不想按这样的顺序执行过滤器。
我不知道这是否可能,但我希望能够执行以下操作:
我在框架中看到了一个名为 GPUImageSoftEleganceFilter 的过滤器,它看起来可能会使用两个 LUT 执行类似的操作,但对于这个东西来说相对较新,如果有人可以帮助我并告诉我如果我需要什么,我会希望它我尝试做的事情是可以使用 GPUImage 实现的,如果是这样,也许会为我指明正确的方向:)
谢谢!
最佳答案
好的,我发现处理我在 GPUImage 中尝试做的事情的类是 GPUImageThreeInputFilter。
我最终创建了一个 GPUImageThreeInputFilter 的子类,并在我的子类中添加了我的自定义顶点和片段着色器。
如果您有兴趣做同样的事情,这里有一个基本的顶点着色器设置可以帮助您入门:
attribute vec4 position;
attribute vec4 inputTextureCoordinate;
attribute vec4 inputTextureCoordinate2;
attribute vec4 inputTextureCoordinate3;
varying vec2 textureCoordinate;
varying vec2 textureCoordinate2;
varying vec2 textureCoordinate3;
void main()
{
gl_Position = position;
textureCoordinate = inputTextureCoordinate.xy;
textureCoordinate2 = inputTextureCoordinate2.xy;
textureCoordinate3 = inputTextureCoordinate3.xy;
}
还有一个基本的片段着色器。注意:下面的片段着色器没有使用位置 3 处渲染的图像纹理,但如果您愿意,可以直接修改它。另请注意需要设置“强度”,您可以硬编码为 float ,例如1.0 用于演示目的。
varying highp vec2 textureCoordinate;
varying highp vec2 textureCoordinate2;
varying highp vec2 textureCoordinate3;
uniform sampler2D inputImageTexture;
uniform sampler2D inputImageTexture2;
uniform sampler2D inputImageTexture3;
uniform lowp float intensity;
void main()
{
highp vec4 textureColor = texture2D(inputImageTexture, textureCoordinate);
highp float blueColor = textureColor.b * 63.0;
highp vec2 quad1;
quad1.y = floor(floor(blueColor) / 8.0);
quad1.x = floor(blueColor) - (quad1.y * 8.0);
highp vec2 quad2;
quad2.y = floor(ceil(blueColor) / 8.0);
quad2.x = ceil(blueColor) - (quad2.y * 8.0);
highp vec2 texPos1;
texPos1.x = (quad1.x * 0.125) + 0.5/512.0 + ((0.125 - 1.0/512.0) * textureColor.r);
texPos1.y = (quad1.y * 0.125) + 0.5/512.0 + ((0.125 - 1.0/512.0) * textureColor.g);
highp vec2 texPos2;
texPos2.x = (quad2.x * 0.125) + 0.5/512.0 + ((0.125 - 1.0/512.0) * textureColor.r);
texPos2.y = (quad2.y * 0.125) + 0.5/512.0 + ((0.125 - 1.0/512.0) * textureColor.g);
lowp vec4 newColor1 = texture2D(inputImageTexture2, texPos1);
lowp vec4 newColor2 = texture2D(inputImageTexture2, texPos2);
lowp vec4 newColor = mix(newColor1, newColor2, fract(blueColor));
gl_FragColor = mix(textureColor, vec4(newColor.rgb, textureColor.w), intensity);
}
我的 Objective-C 设置如下:
// The URL of the video file in our Bundle we want to play
NSURL *videoFileURL = [NSURL fileURLWithPath: videoFilePath];
playerItem = [[AVPlayerItem alloc] initWithURL: videoFileURL];
player = [[AVPlayer alloc] initWithPlayerItem: playerItem];
// GPUCustomThreeInputFilter inherits from GPUImageThreeInputFilter
customThreeInputFilter = [[GPUCustomThreeInputFilter alloc] init];
GPUImageMovie *gpuImageMovie = [[GPUImageMovie alloc] initWithPlayerItem:playerItem];
[gpuImageMovie addTarget: customThreeInputFilter atTextureLocation:0];
// This texture will be available at "inputImageTexture2" in our fragment shader
[gpuImagePicture1 addTarget: customThreeInputFilter atTextureLocation:1];
[gpuImagePicture1 processImage];
// This texture will be available at "inputImageTexture3" in our fragment shader
[gpuImagePicture2 addTarget: customThreeInputFilter atTextureLocation:2];
[gpuImagePicture2 processImage];
// gpuImageView is an instance of GPUImageView and is added to our ViewController in the normal way via [self.view addSubview: gpuImageView]
[customThreeInputFilter addTarget: gpuImageView];
[gpuImageMovie startProcessing];
[player play];
我希望这可以帮助任何试图做同样事情的人。
关于ios - 如何在不通过序列的情况下在 GPUImage 的视频上混合 2 个 LUT 的输出?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50474664/
最近,我正在研究GPUImage的源代码,以提高我的OpenGL ES技能。当我阅读GPUImageContext类的代码时,我发现它存储了对queue的引用,该引用已在库的其他部分中使用。 例如,在
我正在尝试在一个 View 中实现亮度、对比度和曝光滤镜,就像您在 iPhoto 应用程序中看到的一样。我试图建立组过滤器来做同样的事情。但它显示的是白屏而不是修改后的图片。这是我应用的代码。 GP
我想要一个非水平的GPUImageTiltShiftFilter旋转。我想将其旋转到任意旋转角度。我还希望过滤器速度快,可以使用带有UIRotationGestureRecongizer的UI旋转它。
我想将 GPUImage 的直方图均衡过滤器 ( link to .h ) ( link to .m ) 用于相机应用。我想实时使用它,并将其作为一个选项呈现,以应用于实时摄像头。我知道这可能是一项昂
大家好,Stackoverflow! 我的代码需要您的帮助。我写了一个实时模糊相机的小应用程序。 为此我使用了 GPUImage来自 Brad Larson 的框架(感谢 Brad Larson)!
我在我的项目中使用 GPUImage,我需要一种有效的方法来获取列总和。简单的方法显然是检索原始数据并添加每列的值。有人能建议一种更快的方法吗? 最佳答案 实现此目的的一种方法是使用我对 GPUIma
在图像上应用 GPUImage 滤镜时,我遇到了一个奇怪的问题。我尝试在图像上应用不同的滤镜,但在应用 10-15 个滤镜后,它会向我发出内存警告,然后崩溃。这是代码: sourcePicture =
第一次使用不同的 GPUImage 过滤器时,我看到了奇怪的性能,GPUImage 在实时预览和输出照片之间显示出相当大的差异。 我目前正在使用 GPUImageSobelEdgeDetectionF
我正在开发一个图像拼接应用程序,它从相机获取输入,估计图像变换并通过估计的变换扭曲输入图像。如下图所示,来自相机的图像被输入到链的 2 个分支中。然而,图像变形的处理依赖于变换估计的结果。我的问题是如
我使用 GPUImageLookupFilter 进行图像处理。模拟器似乎没问题,但是当我在真实设备上运行我的应用程序时,我得到了不同的图像结果。 这是两张图片 Simulator Real devi
我在使用 GPUImage 时遇到以下问题:1st 我在相机上添加了一个灰度滤镜,然后我使用 GPUImageAverageColor 来获得平均颜色。问题是我通过 block 获得的颜色不在灰度范围
此代码在执行后约 1 秒崩溃(iOS7): -(void)initializeCamera { GPUImageStillCamera *stillCamera=[[GPUImageStill
我有: 主 GPUImage 预览窗口GPUImage 直方图位于单独的 GPUImageView 上。 //Adding main preview self.previewView = [[GPUI
我已经实现了下面的代码来启用点击对焦相机。它在后置摄像头上工作正常,但在使用前置摄像头时失败,因为_videoCamera.inputCamera.isFocusPointOfInterestSupp
我正在尝试使用 GPUImage 在我的应用程序中实现直方图。 GPUImage github 上名为 FilterShowcase 的示例项目附带了一个很好的直方图生成器,但由于我正在制作的应用程序
我正在使用 Xcode 6.1 和 iOS SDK 8.1。 我按照 Github 自述文件中的描述添加了静态库并添加了这段代码。 GPUImageStillCamera *rearCamera =
我正在尝试对图像应用一些滤镜,所以我使用 GPUImageFilterGroup 来混合滤镜,但我的应用程序崩溃了,这是我的代码: - (IBAction)effectApply:(id)sender
我正在创建一个将图像转换为二进制图像的应用程序。为此,我正在使用 GPUimage 框架。首先,它会将其转换为灰度,然后更改对比度,然后将其转换为二值化图像。 当我使用灰度和对比度滤镜时,它会生成内存
我希望在我的应用程序中实现类似于使用用户触摸的涂抹工具的效果,并且我看过类似 this 的文章关于如何实现它,如果我将代码移植到 iOS。 我已经在应用程序中实现了 GPUImage,它可以很好地过滤
使用 GPUImageAlphaBlendFilter,我在 UI 中也有一个 slider ,它允许我更改mix。它工作得很好,我真的可以快速来回移动 slider ,但如果我滑动太快或滑动超过几秒
我是一名优秀的程序员,十分优秀!