GPUImage 的 GPUImageOpacityFilter 行为不符合预期,不会更改 Alpha 通道

2024-04-22

我正在尝试做一个Overlay Blend具有相机源输出的库存图像,其中库存图像的不透明度小于 100%。我想我可以放一个GPUImageOpacityFilter在过滤器堆栈中,一切都会好起来的:

  1. GPUImageVideoCamera -> MY_GPUImageOverlayBlendFilter
  2. GPUImagePicture -> GPUImageOpacityFilter (不透明度 0.1f) -> MY_GPUImageOverlayBlendFilter
  3. MY_GPUImageOverlayBlendFilter -> GPUImageView

但结果并不是将 GPUImagePicture 的 0.1f alpha 版本混合到 GPUImageVideoCamera 中,而是软化了 GPUImagePicture 的颜色/对比度并将其混合。所以我做了一些搜索,并根据建议尝试使用 GPUImageOpacity 过滤器获取 UIImageimageFromCurrentlyProcessedOutput并将其发送到 BlendFilter 中:

  1. GPUImagePicture -> MY_GPUImageOpacityFilter(不透明度 0.1f)
  2. [MY_GPUImageOpacityFilter imageFromCurrentlyProcessedOutput]-> MY_alphaedImage
  3. GPUImagePicture (MY_alphaedImage) -> MY_GPUImageOverlayBlendFilter
  4. GPUImageVideoCamera -> MY_GPUImageOverlayBlendFilter
  5. MY_GPUImageOverlayBlendFilter -> GPUImageView

这完全符合我的预期。那么,为什么我必须imageFromCurrentlyProcessedOutput,这不应该发生在队列中吗?以下是上述两种场景的代码片段:

第一:

//Create the GPUPicture
UIImage *image = [UIImage imageNamed:@"someFile"];
GPUImagePicture *textureImage = [[[GPUImagePicture alloc] initWithImage:image] autorelease];

//Create the Opacity filter w/0.5 opacity
GPUImageOpacityFilter *opacityFilter = [[[GPUImageOpacityFilter alloc] init] autorelease];
opacityFilter.opacity = 0.5f
[textureImage addTarget:opacityFilter];

//Create the blendFilter
GPUImageFilter *blendFilter = [[[GPUImageOverlayBlendFilter alloc] init] autorelease];

//Point the cameraDevice's output at the blendFilter
[self._videoCameraDevice addTarget:blendFilter];

//Point the opacityFilter's output at the blendFilter
[opacityFilter addTarget:blendFilter];

[textureImage processImage];

//Point the output of the blendFilter at our previewView
GPUImageView *filterView = (GPUImageView *)self.previewImageView;
[blendFilter addTarget:filterView];

第二个:

//Create the GPUPicture
UIImage *image = [UIImage imageNamed:@"someFile"];
GPUImagePicture *textureImage = [[[GPUImagePicture alloc] initWithImage:image] autorelease];

//Create the Opacity filter w/0.5 opacity
GPUImageOpacityFilter *opacityFilter = [[[GPUImageOpacityFilter alloc] init] autorelease];
opacityFilter.opacity = 0.5f
[textureImage addTarget:opacityFilter];

//Process the image so we get a UIImage with 0.5 opacity of the original
[textureImage processImage];
UIImage *processedImage = [opacityFilter imageFromCurrentlyProcessedOutput];
GPUImagePicture *processedTextureImage = [[[GPUImagePicture alloc] initWithImage:processedImage] autorelease];

//Create the blendFilter
GPUImageFilter *blendFilter = [[[GPUImageOverlayBlendFilter alloc] init] autorelease];

//Point the cameraDevice's output at the blendFilter
[self._videoCameraDevice addTarget:blendFilter];

//Point the opacityFilter's output at the blendFilter
[processedTextureImage addTarget:blendFilter];

[processedTextureImage processImage];

//Point the output of the blendFilter at our previewView
GPUImageView *filterView = (GPUImageView *)self.previewImageView;
[blendFilter addTarget:filterView];

None

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

GPUImage 的 GPUImageOpacityFilter 行为不符合预期,不会更改 Alpha 通道 的相关文章

随机推荐

  • PyMongo find() 使用 $or 和 $regex 进行查询

    有一个 MongoDB 文档集合 其中包含有关书籍的信息 我需要使用以下标准查找文档 header包含子串 OR author包含子串 在 mongo shell 中 我使用这个查询效果很好 db books find or author
  • 在linux上编译一个基本的OpenCV + Cuda程序

    我过去在linux上使用过opencv 但没有使用过cuda 几个月来我一直在与以下编译错误作斗争 在尝试了许多解决方案后 我放弃并使用 Windows 不过 我真的很想在 Linux 上工作 这是我用来编译 opencv gpu 网站上给
  • 将 css 添加到 Magento 模板文件的 head 中

    我想在 magento 中的模板 phtml 文件的标签内添加一个 CSS 文件 是否可以 这样做是有原因的 CSS 文件名是动态的 所以直到模板执行时我才知道 可以这样做吗 要在加载布局之后 渲染布局之前从控制器添加 CSS 文件 您需要
  • 如何在 matplotlib 上以对数刻度可视化值?

    我的值差异非常小 例如 0 000001 我想以对数尺度可视化它们 我想知道如何在 matplotlib 中做到这一点 多谢 http matplotlib sourceforge net api pyplot api html matpl
  • “parse”在交互和非交互模式下的行为不同

    我认为这可能是一个错误parse 但想检查一下是否还有其他人有更好的主意 在交互模式 RStudio 下 以下代码可以正常工作 txt lt c c integer 3L 1 3 c integer 1 3 1L TRUE c intege
  • 用颤动绘制虚线弧

    Flutter 有没有办法画虚线弧 目前我正在使用 canvas drawArc 但我不知道如何获得正确的结果 canvas drawArc rectangle startAngle fullArcRadius false Paint co
  • 带有 pfx 文件的 Azure https

    我正在尝试创建一个https我的天蓝色服务的端点 我被给予了p7b我转换成的文件cer文件 来自cer我能够用几行 c 转换为pfx var cert new X509Certificate2 certpath var bytes cert
  • 返回 clickhouse 数组作为列

    Clickhouse 是否可以将包含一对数组的结果转换为列 形成这个结果 f1 f2 f3 a 1 2 3 x y z b 4 5 6 x y z to f1 x y z a 1 2 3 b 4 5 6 这个想法是不必为每行重复标题值 就我
  • Webpack - 如何捆绑/需要文件夹(子文件夹)的所有文件

    我想看看是否有更短的方式来运行 webpack 包 以及为什么我的加载器不起作用 这是我的代码 module exports context path join dirname dist entry ES6bundle js jQuery
  • JS 库来模拟 Internet Explorer?

    Webkit中有一些JS库可以模拟IE吗 例如 IE8不支持border radius目前 可能在 IE10 上 所以我运行一个 JS 库来检查我是否正在使用border radius然后将其删除以制作类似于IE的视觉 我知道这是一个疯狂的
  • Android Accessibility 服务实时音频处理

    有人可以为我提供 Android 辅助功能服务实时音频处理的示例代码吗 我需要处理通话音频 但不知道如何实现这一点 请分享您对此的想法 请找到下面的清单
  • 我如何在create js中更改图形的填充颜色

    我用它来改变创建js中的填充颜色 这不起作用 var shape rect new createjs Shape shape rect graphics beginFill FFD64B drawRect 61 253 398 25 sha
  • 检查混音器线路中的音频播放电平?

    我试图弄清楚 Windows 中是否正在播放任何类型的声音 通过任何应用程序 如果某处有什么东西发出噪音 我想知道 在遵循文档之后 我找到了如何获取机器上的混音器列表以及这些混音器的线路 如果我理解正确的话 这些线路是用于混音器的输入 输出
  • 如何设置选择器的边框

    我有来自 反应本机 Picker Item有 周一 周二 周三等 我想设置选择器的属性 例如borderRadius 10 even style borderRadius 30 没有帮助
  • CSS3 使文本在三角形内居中

    我在页面的左上角有一个三角形图像 以及一些需要在底部居中的文本 使用 CSS3transform rotate 我可以通过一些定位 边距来做到这一点 但它在浏览器中看起来并不相同 它看起来有点向左或向右 有没有办法将其居中 以便它在所有浏览
  • FindFirstFile 和 FindNextFile 问题

    输出 The first file found is LOG 09 TXT Next file name is LOG 10 TXT Next file name is LOG 11 TXT Next fi cut off word fil
  • 当文件名有重音符号时使用 pandas.read_csv 进行编码

    我正在尝试使用 pandas 加载 CSV 但如果文件名有重音符号 则会遇到问题 这显然是一个编码问题 但尽管如此read csv允许您设置文件内文本的编码 我不知道如何正确编码文件名 input file r C Datasets s P
  • 我应该用 C++ 封装 Lua 代码的哪些代码?

    我终于将 LuaBind 配置为与我的 C 项目一起使用 我最近发现 Tiled 地图编辑器可以选择将文件导出为 lua 所以我想尝试一下 我将使用什么代码来封装下面粘贴的代码以使其与我的 C RPG 项目一起使用 return versi
  • 空 Repeater 控件的默认文本

    使用 VS 2008 我有一个 Repeater 控件
  • GPUImage 的 GPUImageOpacityFilter 行为不符合预期,不会更改 Alpha 通道

    我正在尝试做一个Overlay Blend具有相机源输出的库存图像 其中库存图像的不透明度小于 100 我想我可以放一个GPUImageOpacityFilter在过滤器堆栈中 一切都会好起来的 GPUImageVideoCamera gt