1.opencv安裝
2.選項選2或3
3.不要更換目標資料夾
4.重開codeblocks
5.設定Settings-compiler要加入三個設定
5.1.search 目錄 compiler 的include 目錄 加 C:\OpenCV2.1\include
#include <opencv/highgui.h>
int main()
{///Intel performance library
IplImage * img = cvLoadImage("c:/image.jpg");
cvShowImage("week05",img);
cvWaitKey(0);
}
#include <opencv/highgui.h>
int main()
{
IplImage * img;
CvCapture * cap = cvCreateCameraCapture(0);
while(1){
IplImage * img = cvQueryFrame(cap);
cvShowImage("week05 opencv",img);
int key = cvWaitKey(33);
if(key==27)break;
}
cvReleaseCapture(&cap);
}
13.從上課軟體下載freeglut
14.將壓縮檔解壓到桌面
15.點開freeglut後復製其連結
16.點開lib後將freeglut.a復製
17.改名為libglut32.a (124KB)
18.到codeblock開新的專案 file > project,(當名為week05_opencv_cvLoadImage)
#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("c:/image.jpg");
cvShowImage("opencv",img);
glutInit(&argc,argv);
glutInitDisplayMode(GLUT_DOUBLE|GLUT_DEPTH);
glutCreateWindow("week05");
glutDisplayFunc(display);
glutMainLoop();
}
裡的18行貼上和剛剛的程式碼
22.到codeblock開新的專案 file > project,(檔名為week05_opencv_opengl_myTexture_glTexcoord2f)
23.貼上剛剛的程式碼跟這幾行
glBegin(GL_POLYGON);
glTexCoord2f(0,0);glVertex2f(-1,-1);
glTexCoord2f(0,1);glVertex2f(-1,+1);
glTexCoord2f(1,1);glVertex2f(+1,+1);
glTexCoord2f(1,0);glVertex2f(+1,-1);
glEnd();
26.將剛剛的程式碼貼上
沒有留言:
張貼留言