( 1 ) 主題 : 貼圖 Texture
( 2 ) 範例 : Texture.exe
( 3 ) 實作 : OpenCV
( 4 ) 實作 : OpenCV + OpenGL 貼圖
( 5 ) 期中考 : 10行OpenGL程式
打開windows: texture.exe
1.到https://sourceforge.net/projects/opencvlibrary/files/opencv-win/2.1/下載OpenCV-2.1.0-win32-vs2008.exe檔
2.開啟並修改成Add
3.Code:Blocks要重開
4.Code:Blocks要修改
結果:
程式碼:
#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();
}
2.開啟並修改成Add
3.Code:Blocks要重開
4.Code:Blocks要修改
結果:
程式碼:
#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();
}
沒有留言:
張貼留言