2019年4月11日 星期四

珮珮學習日誌 Week08

電腦圖學

(1)主題:貼圖Texture


(2)範例:Texture.exe


TODO:首先先到http://www.cmlab.csie.ntu.edu.tw/~jsyeh/3dcg10/ 這個網站

下載:windows.zip解壓縮並下載\windows\Texture.exe

data.zip 解壓縮並下載\windows\data\圖檔

glut32.dll 下載\windows\glut32.dll

下面為顯示圖片

接下來在Google Chrome下載freeglut(window的mingw版) 


https://www.transmissionzero.co.uk/software/freeglut-devel/ 並把他解壓縮到桌面


之後再把解壓縮的freeglut資料夾打開來,並找到lib資料夾


再把lib裡面的libfreeglut.a複製成libglut32.a)





(3)實作:OpenCV


(4)實作:OpenCV+OpenGL貼圖


然後從Google Chrome上下載OpenCV2.0(2008)
<<安裝完OpenCV 2.1之後才可以打開Codeblocks,因為PATH要對才會到C:\OpenCV2.1\bin,找dll檔才會對>>

先把你剛畫的圖片存到freeglut裡的bin

圖片如下


接下來再回到codeblocks裡
你的檔案按右鍵找到build options,找到Search directories按Add 打C:\\OpenCV2.1\include
好了後再按Linker settings按Add打C:\\OpenCV2.1\lib\cv210.lib  C:\\OpenCV2.1\lib\cxcore210.lib
C:\\OpenCV2.1\lib\highgui210.lib

詳細圖如下



程式碼如下:

#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("circle.png");///貼圖需要

    cvShowImage("opencv Window",img);///貼圖需要

    cvWaitKey(0);///貼圖需要


    glutInit(&argc, argv);

    glutInitDisplayMode(GLUT_DOUBLE|GLUT_DEPTH);

    glutCreateWindow("Week08");


    glutDisplayFunc(display);


    glutMainLoop();

}



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


沒有留言:

張貼留言