顯示具有 week08 標籤的文章。 顯示所有文章
顯示具有 week08 標籤的文章。 顯示所有文章

2019年5月2日 星期四

ˊ_>ˋ_week08_貼圖 Texture

主題: 貼圖 Texture

(1) 範例: Texture.exe



(2) 實作: OpenCV

step1:下載OpenCV





完成安裝後-->開新的Glut project

(3) 實作: OpenCV + OpenGL 貼圖


#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("FOX.jpg");///貼圖需要
    cvShowImage("opencv Window", img);///貼圖需要
    cvWaitKey(0);///貼圖需要

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

    glutDisplayFunc(display);

    glutMainLoop();
}


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

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 程式


寶欸學習筆記_week08_貼圖


1.下載win32,data,.dll三個檔案
2.把data跟win32解壓縮
3.把data跟.dll拉到win32裡面
4.職名Texture.exe















glTexCoord 調整座標(必須逆時針! ps安培右手定則)




用小畫家畫一個地球存成.jpg放在lib資料夾裡
就可以用程式show出來自己的地球



補充(茶壺程式碼):
   #include <GL/glut.h>
                void display(){
                    glutSolidTeapot( 0.3 );
                    glutSwapBuffers();
                }
                int main(int argc, char**argv){
                    glutInit(&argc,argv);
                    glutInitDisplayMode(GLUT_DOUBLE|GLUT_DEPTH);
                    glutCreateWindow("04160702");
                    glutDisplayFunc(display);
                    glutMainLoop();
                }

金魚腦波學

電腦圖學

1.主題:貼圖Texture2.範例:Texture.exe3.實作:OpenCV4.實作:OpenCV+OpenGL貼圖5.期中考:10行OpenGL程式
http://www.cmlab.csie.ntu.edu.tw/~jsyeh/3dcg10/下載win32 data glut32.dll

範例:Texture.exe


*Texture貼圖
安培右手定則:
大拇指指向前,逆時針旋轉
座標順序(0,0) (1,0) (1,1) (0,1)

圖檔出現
1.https://sourceforge.net/projects/opencvlibrary/files/opencv-win/2.1/
載2008那個
2.小畫家畫地球存在freeglut的bin
3.開啟codeblocks的glut檔
4.左邊Week08按右鍵(Build options)
5.找到目錄(director)add include
6.找到(linker) add lib cv210 cxcore210 highgut210

#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.png");貼圖需要
    cvShowImage("opencv Window",img);
    cvWaitKey(0);
    glutInit(&argc,argv);
    glutInitDisplayMode(GLUT_DOUBLE|GLUT_DEPTH);
    glutCreateWindow("week08");
    glutDisplayFunc(display);

    glutMainLoop();
}







朱書樑的上課筆記w8

一.主題:貼圖Texture
1.到http://www.cmlab.csie.ntu.edu.tw/~jsyeh/3dcg10/下載[data][win32][glut32.dll]
2.將[win32]解壓縮,並將data以及glut32.dll放入資料夾中
3.打開Texture.exe並進行操作即可
二.實作:OpenCV
2.進行安裝程序
注意:出現"是否要加入捷徑"選項時,一定要選第二或第三個

3.下載完成後,打開codeblocks並打開新的Glut project並打入以下程式碼:

程式碼:
#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("06160540");
    glutDisplayFunc(display);
    glutMainLoop();
}

4.將一張圖(jpg檔)放入freeglut的檔案bin中
5.進入codeblock,到左邊的目錄中打開設定介面

6.將OpenCV2.1(下載完成後在c槽中)裡面的include檔案打開,並將上面的位置複製到Search directories的compiler中
7.將OpenCV2.1(下載完成後在c槽中)裡面的lib檔案打開,並將上面的位置複製到Search directories的linker中
8..將OpenCV2.1(下載完成後在c槽中)裡面的lib檔案打開,並將裡面的cv210,cxcore210,highgui210添加到Link settings中
9.設定完畢後,即可執行




06161091蔡萓芹,week08

主題:貼圖Texture

glTexCoord2f(tx,ty); //貼圖座標
Texture 貼圖
Coordinate 座標

範例:Texture.exe
實作:OpenCV
            OpenCV+OpenGL貼圖
期中考:10行OpenGL程式

1.把[data] [window62] [glut32.dll] 下載
2.把data window32 解壓縮
3.把data跟glut32.dll丟進window32資料夾
4.開啟Texture
貼圖Texture實作
程式碼:
#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("4.jpg");
    cvShowImage("opencv Window",img);
    cvWaitKey(0);

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

    glutDisplayFunc(display);
    glutMainLoop();
}

程式執行結果如下:


Week 08 貼圖

1.開啟http://www.cmlab.csie.ntu.edu.tw/~jsyeh/3dcg10/

2.Examples下載win32、data

3.other examples下載glut32.dll

4.解壓縮windows資料夾

5.將data壓縮檔打開(不要解壓縮),直接拖曳到windows資料夾中

6.將glut32.dll放入windows資料夾中

7.打開Texture.exe即可使用


使用OpenCV程式

1.Google:OpenCV 2.1找到第一個裡面OpenCV-2.1.0-win32-vs2008.exe下載安裝

(1)要C:\OpenCV2.1目錄
(2)要選中間Add Path
(3)裝好後才能啟動CodeBlocks

2.安裝freeglut

3.複製程式碼:
#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();
}

4.設定程式:

(1)右邊workspace專案名稱右鍵選build options

(2)分頁選Search directories中的Compiler,Add OpenCV程式所在位置(C:\OpenCV2.1\include)

(3)小分頁選Linker,Add(C:\OpenCV2.1\lib)

(4) 大分頁Linker Setting,Add:(cv210)(cxcore210)(highgui210)


5.earth.jpg圖檔要放到freeglut的bin中即可完成。



Week08-04160453

1.主題;貼圖Texture

下載windows3個檔案打開Texture檔案

2.實作:OpenCV

去網站:https://sourceforge.net/projects/opencvlibrary/files/opencv-win/2.1/

並且安裝好


#include <stdio.h>
#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.png");
    cvShowImage("opencv Window",img);
    cvWaitKey(0);

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

    glutDisplayFunc(display);
    glutMainLoop();
}

右鍵點Build options
Search drectones>Add>C:\OpenCV2.1\include
Link>Add>C:OpenCV2.1\lib
Linker settings>Add>cv210      
                                   cxcore210
                                   highgui210