gpt4 book ai didi

ios - 尝试将 CIImage 与从视频文件帧获得的纹理一起使用时,CIImage 为空白

转载 作者:塔克拉玛干 更新时间:2023-11-02 08:34:07 24 4
gpt4 key购买 nike

我正在尝试创建一个将过滤器应用于视频文件的应用程序。我想使用核心图像过滤器

    imageBuffer obtained from AVAssetReaderInput

int height = (int)CVPixelBufferGetHeight(imageBuffer);
int width = (int)CVPixelBufferGetWidth(imageBuffer);

glActiveTexture(GL_TEXTURE0);
CVReturn error;
CVOpenGLESTextureRef _textureRef;
error = CVOpenGLESTextureCacheCreateTextureFromImage (kCFAllocatorDefault,
self.openGLContext.textureCache,
imageBuffer,
NULL, // texture attributes
GL_TEXTURE_2D,
GL_RGBA, // opengl format
width,
height,
GL_BGRA,
GL_UNSIGNED_BYTE, // native iOS format
0,
&_textureRef);

if (error) {
NSLog(@"Error while creating Texture");
}


glBindTexture(CVOpenGLESTextureGetTarget(_textureRef), CVOpenGLESTextureGetName(_textureRef));
GLint texture = CVOpenGLESTextureGetName(_textureRef);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);

CIContext *context = [CIContext contextWithEAGLContext:self.openGLContext.context options:nil];

CIImage *my_image = [CIImage imageWithTexture:texture size:CGSizeMake(1280, 720) flipped:NO colorSpace:nil];

CIImage (my_image) 始终为空白(即显示为黑色)并且不包含视频纹理。我正在 iPhone 6 设备上测试它。我哪里错了?

最佳答案

你为什么不用它来创建你的 CIImage:

     CIImage *inputImage = [CIImage imageWithCVPixelBuffer:imageBuffer options:nil];

您可以将滤镜应用于此图像。

关于ios - 尝试将 CIImage 与从视频文件帧获得的纹理一起使用时,CIImage 为空白,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35137482/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com