2022年4月19日 星期二

瘋狂無敵圖學死亡筆記 Week09

 0.貼圖座標glTexCoord2f(tx,ty)

glTexCoord2f(0.0,0.0)由左下開始(逆時針跑)

(0.0,1.0)    <---    (1.0,1.0)

                                ^

(0.0,0.0)     --->   (1.0,0.0)

1.OpenCV讀圖、秀圖 OpenCV 2.1.0 vs2008 版

安裝時注意事項

(1)選第二個 add PATH(程式執行會去找exe或dll的目錄路徑)

(2)預設目錄

***bin include lib

bin二進位執行檔

include外掛

2.存成week09_opencv.cpp

```c++

#include <opencv/highgui.h>//使用opencv外掛

int main(){

///Ipl:Intel perfromance library

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

    cvShowImage("Week09", img);  //秀圖

    cvWaitKey( 0 ); //等待任意鍵繼續

}

```



2-1.設定Setting-Comiler設定 Include 目錄

2-2.設定Setting-Comiler設定 Lib 目錄

Search Directories

  (Compiler) 對應Include目錄 c:\opencv2.1\include

  (Linker) 對應Lib目錄 c:\opencv2.1\lib

2-3.設定Setting-Comiler設定 咒語 Linker Settings加入 cv210、cxcore210、highgui210



3. 結合OpenCV 和 OpenGL 把10行茶壺glut+3-5行opnecv讀圖秀圖

#include <GL/glut.h> ///使用GLUT外掛,簡化程式
#include <opencv/highgui.h>

void myTextrue(){
     Iplmage *img = cvLoadImage("檔案.png"); //讀檔

    cvShowImage("Week09", img);  //秀圖

    ///cvWaitKey( 0 ); //需要按任意見才能讓茶壺glutMainLoop(),可以不用寫,因為有glutMainLoop()
}
void display()
{
    glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );///畫圖前, 先清畫面
    glutSolidTeapot(0.3); ///實心的茶壼

    glutSwapBuffers();///畫好後,交換出來
}

int main(int argc, char** argv) ///main()主函式 進階版
{
    glutInit( &argc, argv); ///把參數,送給 glutInit 初始化
    glutInitDisplayMode( GLUT_DOUBLE | GLUT_DEPTH ); ///雙緩衡區 + 3D深度功能
    glutCreateWindow("第02週的程式哦!"); ///開 GLUT 視窗

    glutDisplayFunc(display); ///用來顯示的函式
    myTexture();///執行這視窗

    glutMainLoop(); ///主要的程式迴圈
}


3-1圖檔放在 工作目錄 (in C:\Users\User\Desktop\freeglut\bin)

沒有留言:

張貼留言

VERY BEAUTIFUL, VERY POWERFUL

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