相机帧到 UIImage 到 OpenGL 渲染给出了一个奇怪的图像 [英] Camera frame to UIImage to OpenGL rendering gives an odd image

查看:76
本文介绍了相机帧到 UIImage 到 OpenGL 渲染给出了一个奇怪的图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用

NSData *imageData = [AVCaptureStillImageOutput jpegStillImageNSDataRepresentation:imageDataSampleBuffer];
UIImage *image = [UIImage imageWithData:imageData];

然后我创建一个 OpenGL 纹理并渲染它.然后我从帧缓冲区中提取了一个 UIImage,但如您所见,结果是错误的.

then i'm creating an OpenGL texture and render it. then i extract a UIImage from the frame buffer but it comes out wrong as you can see.

我尝试使用纹理顶点数组,但它保持不变.

i tried playing with texture vertices array but it stayed the same.

这是坐标:

const GLfloat squareVertices[] = {
-1.0f, -1.0f,
1.0f, -1.0f,
-1.0f,  1.0f,
1.0f,  1.0f,
};


const GLfloat textureVertices[] = {
1.0f, 1.0f,
1.0f, 0.0f,
0.0f,  1.0f,
0.0f,  0.0f,
};


 glVertexAttribPointer(ATTRIB_VERTEX, 2, GL_FLOAT, 0, 0, squareVertices);
    glEnableVertexAttribArray(ATTRIB_VERTEX);
    glVertexAttribPointer(ATTRIB_TEXTUREPOSITON, 2, GL_FLOAT, 0, 0, textureVertices);
    glEnableVertexAttribArray(ATTRIB_TEXTUREPOSITON);`

推荐答案

你的纹理坐标有问题.正确检查它们.

It is problem with your texture coordinates. Check them properly.

这篇关于相机帧到 UIImage 到 OpenGL 渲染给出了一个奇怪的图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆