2022年4月19日 星期二

(圖學筆記)電腦圖學Week09

 step01 複習考試會考的十行程式碼


step02 導讀

1. jsyeh.org/3dcg10 下載 windows.zip, data.zip source.zip

2. windows.zip => 下載\windows\Texture.exe

3. data.zip    => 下載\windows\data\圖檔

4. Texture.exe 貼圖 


step03-1 Opencv

1.下載 OpenCV-2.1.0-win32-vs2008.exe

2.安裝時,Add PATH選第二個加上預設的路徑(亂改會不好處理

3.安裝後要將CodeBlocks重開

4.CodeBlocks內設定:Setting -> Compiler -> Search directories

    三個訣竅

    Include:Compiler,Add,C:\opencv2.1\include

    Lib:Linker,Add,C:\opencv2.1\lib

    Linker settings,Add,cv210、cxcore210、highgui210


#include <opencv/highgui.h> 

int main()

{

IplImage  *  img  = cvLoadImage("檔名.png");

cvShowImage( "week09", img ); 

cvWaitKey( 0 );

}


step03-2 結合

1. 結合 OpenCV 和 OpenGL 

2. 設定/程式碼 用剪貼的

3. 最簡單的整合: 把 10行GLUT範例 3-5行OpenCV讀圖秀圖

4.File-New-Project, GLUT專案

5.寫出

7. 加入 3-5行 OpenCV 的程式

8. 圖檔要放在 工作目錄 (in C:\Users...\freeglut\bin)


#include <GL/glut.h>

#include <opencv/highgui.h>

void myTexture()

{

    IplImage * img = cvLoadImage("earth.jpg");

    cvShowImage("opencv", img);

}

void display()

{

    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

        glutSolidTeapot( 0.3 );

    glutSwapBuffers();

}

int main( int argc, char**argv )

{

    glutInit(&argc, argv);

    glutInitDisplayMode(GLUT_DOUBLE |GLUT_DEPTH);

    glutCreateWindow("week09 texture");

    glutDisplayFunc(display);

    myTexture();

    glutMainLoop();

}

step03-3

實作: 貼圖設定


沒有留言:

張貼留言

VERY BEAUTIFUL, VERY POWERFUL

一.     一樣先安裝且設定好freeglut,OpecCV, 開啟CodeBlocks建立新專案 week11_gundam,                 把 MyGundam.zip下載解壓縮後的data資料夾放到freeglut/bin裡面 把week09_openc...