使用渲染脚本的摄像机图像的镜像对称性

时间:2019-11-08 13:20:27

标签: renderscript android-renderscript

我想拍摄一个输入图像并产生一个关于中心轴对称的输出,即关于中心垂直轴从右向左反射。

使用渲染脚本如何实现?

示例输入图像: enter image description here

示例输出图像: enter image description here

1 个答案:

答案 0 :(得分:0)

您可以编写一个内核,以通过图像的左半部分调用该内核(通过LaunchOptions),然后执行以下操作:

  int imageWidth;
  rs_allocation inputImage;

  <yourReturnType> RS_KERNEL mirror(<yourImageType> in, uint32_t x, uint32_t y){
      return rs_GetElementAt(inputImage, imageWidth - x, y);
  }

您应该能够直接覆盖输入的图像,因为您只读取图像的一侧,而只写入另一侧。