Camera frame to UIImage to OpenGL rendering gives an odd image

China☆狼群 提交于 2020-01-07 06:15:46

问题


I'm extracting a UIImage with

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

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.

this are the coordinates:

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);`

回答1:


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



来源:https://stackoverflow.com/questions/8068463/camera-frame-to-uiimage-to-opengl-rendering-gives-an-odd-image

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!