开发平台(Platform): (Ex: VC++, GCC, Linux, ...)
vs2010 C++
额外使用到的函数库(Library Used): (Ex: OpenGL, ...)
OpenCV 2.4.2
OpenGL
问题(Question):
主要将OpenCV 读入的image 或video 在OpenGL下呈现。
喂入的资料(Input):
参考这一个网站的code,但无法正确执行。
http://stackoverflow.com/questions/5316529/opengl-texture-inverted
预期的正确结果(Expected Output):
能正确的show图
错误结果(Wrong Output):
http://ppt.cc/JUxQ
程式码(Code):(请善用置底文网页, 记得排版)
gluBuild2DMipmaps(GL_TEXTURE_2D, GL_RGB, image->width, image->height, GL_RGB,
GL_UNSIGNED_BYTE, image->imageData);
跑到这上面那行时,出现上图错误讯息,求各位前辈解答。
作者: kevindiy 2014-04-18 16:44:00
Texture图档要2^n 尺寸 所以可以用glpixelstorei去调整glPixelStorei(GL_UNPACK_ALIGNMENT,(image.step&3)?1:4)glPixelStorei(GL_UNPACK_ROW_LENGTH,image.step/image.elemSize);CV读进去的格式要先调整才能当Texture用