1. 安裝Moodle OpenCV2.1 vs 2008版本 小心 要把OpenCV的PATH設好
目標 : 用3行程式 讀圖 秀圖
小心 : 要設定三個東西
a. include(Compliar目錄)
b. lib(Linker目錄)
c.lib的三個檔案(Linker Setting)
2. 重啟CodeBlock,week08-1.cpp (不要.c)
#include <opencv/highgui.h>
int main()
{大 I,小 p,小 l,大 I,小 mage
IplImage * img = cvLoadImage ("puipui.jpg") ;
cvShowImage ("week08-1讀圖秀圖", img) ;
cvWaitKey (0) ;
}
3. Texture 貼圖
4. 貼圖設定 Open GL + OpenCV
上半程式 : https://hackmd.io/@jsyeh/opengl
下半程式 : 之前的茶壺
記得 glutMainLoop ( ) 前,要加入 init( )
void display()
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glBegin(GL_POLYGON);
glTexCoord2f( 0, 1 ); glVertex3f(-1, -1, 0);
glTexCoord2f( 1, 1 ); glVertex3f(+1, -1, 0);
glTexCoord2f( 1, 0 ); glVertex3f(+1, +1, 0);
glTexCoord2f( 0, 0 ); glVertex3f(-1, +1, 0);
glEnd();
glutSolidTeapot(0.3);
glutSwapBuffers();
}
int main(int argc, char**argv)
{
glutInit( &argc, argv);
glutInitDisplayMode(GLUT_DOUBLE | GLUT_DEPTH);
glutCreateWindow("week08 texture");
init();
glutDisplayFunc(display);
glutMainLoop();
}
沒有留言:
張貼留言