2019年4月11日 星期四

彥の圖學筆記 Week08

電腦圖學

2019-03-28 Week06

(1) 主題: 貼圖 Texture

(2) 範例: Texture.exe

(3) 實作: OpenCV
(下載連結: https://sourceforge.net/projects/opencvlibrary/files/opencv-win/2.1/)
上網搜尋 OpenCV 2.1.0 > 下載並安裝 OpenCV-2.1.0-win32-vs2008.exe

小心,要 Add PATH
(程式碼)

#include <GL/glut.h>
#include <opencv/highgui.h>///貼圖需要
void display()
{
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

    glutSolidTeapot( 0.3 );
    glutSwapBuffers();
}
int main(int argc, char**argv)
{
    IplImage * img=cvLoadImage("earth.jpg");///貼圖需要
    cvShowImage("opencv Window", img);///貼圖需要
    cvWaitKey(0);///貼圖需要

    glutInit(&argc, argv);
    glutInitDisplayMode(GLUT_DOUBLE |GLUT_DEPTH);
    glutCreateWindow("Week08");

    glutDisplayFunc(display);

    glutMainLoop();
}

前置作業(很容易做錯,非常重要!!)
在 06160955_Week08上按右鍵 > 選 Build options...
選 Search directories > 在 Compiler 新增路徑 C:\OpenCV2.1\include
選 Search directories > 在 Linker 新增路徑 C:\OpenCV2.1\lib
選 Linker settings > 新增 cv210 & cxcore210 & highgui210

(4) 實作: OpenCV + OpenGL 貼圖

(5) 期中考: 10行 OpenGL 程式


沒有留言:

張貼留言