2022年4月19日 星期二

尖🦉-圖學筆記 Week09

 ◇上課範例程式:Texture.exe 貼圖

 1.glTexCoord2f( 0.0 , 0.0); (貼圖左下角是(0 , 0)逆時鐘算頂點,跟頂點的座標位置不一樣)

◇實作1:設定好OpenCV

 moodle下載opencv 2.1.0 win32 vs2008 (選第二個 add Path,也不要改目錄)

    ☆安裝完Path會多opencv 所以codeblocks要重開 。bin(執行檔)

1.開個空的檔案 

2.寫進程式碼:

    ☆#include <opencv/highgui.h>  //使用opencv外掛(這些外掛都放在OpenCv/include/opencv/....)

 3.要設定才能使用 include 目錄 / Lib 目錄 / 方法:

    在右上

        settings/compiler -> Search directories/Compiler裡add C:\OpenCV2.1\include

        settings/compiler -> Search directories/Linker 裡 add  C:\OpenCV2.1\lib

        settings/compiler -> Linker settings    add cv210、cxcore210、highgui210

        圖檔跟.cpp檔放在一起就能執行


◇實作2:結合OpenCV和OpenGL
    1.開一個新的GLUT檔案
    2.將之前 茶壺程式碼(openGL) 和 剛剛的openCV程式碼 修改後 結合在一起
    3.此時圖檔要放在freeglut\bin資料夾裡!!!!!
☆此時貼圖並沒有貼在茶壺上!!!
    4.去老師的網站複製貼圖的程式碼(改掉原本的void mytexture(),在下面的mytexture("圖片檔")):
        https://gist.github.com/jsyeh/5ed01210559721ec71b659b3ffed2dd7

沒有留言:

張貼留言

VERY BEAUTIFUL, VERY POWERFUL

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