[問題] OpenGL Display OpenCV Image

作者: xanushan (騰夜)   2014-04-16 13:23:32
開發平台(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用
作者: xanushan (騰夜)   2014-04-20 15:23:00
感謝K大解惑,已可執行了~~
作者: iamstudent (stu)   2014-04-21 20:31:00
貼圖解析度其實沒有一定要2^n,這個跟顯卡支援有關不過整數次方確實是比較保險的作法

Links booklink

Contact Us: admin [ a t ] ucptt.com