2024年3月21日 星期四

11160933第五周

 0.打開桌面 CV

add for all user

install on its default folder

reopen Codeblocks after install

search setting compiler Include menu

search Linker link menu

settings compilers add 3 settings

compiler include add C:\OpenCV2.1\include.

<-- Linker lib add C:\OpenCV2.1\lib

add three settings cv210 cxcore210 hifhgui210

1.open new empty file week05-1_opencv

2.可讀取圖片

#noot = image.jpg#


#include <opencv/highgui.h>

int main()

{

    IplImage * img = cvLoadImage("c:/noot.jpg");

    cvShowImage("week05", img);

    cvWaitKey(0);

}


3.open new empty file week05-1_opencv_webcam

4.open new empty file week05-1_opencv_many_webcam
copy last

paste codes

5.開啟https://jsyeh.org/3dcg10/

data win32 

一堆圖檔

texture.exe


6.new GLUT week05_opencv_cvLoadImage

貼11行GLUT

加3行OpenCV

#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[])

{

glutInit(&argc, argv);

glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);

glutCreateWindow("week05");

glutDisplayFunc(display);

glutMainLoop();

}



#include <opencv/highgui.h>

IplImage * img = cvLoadImage("c:/image.jpg");

cvShowImage("opencv", img);

7.new file week05_opencv_opengl_myTexture

moodle gist copy my texture 18行

(https://gist.github.com/jsyeh/5ed01210559721ec71b659b3ffed2dd7)


8.also copy 10 lines

add myTexture("c:/image.jpg");




9.open new file week05_opencv_opengl_myTexture_glTexCoord2f

copy last code

add

     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();



10.new file week05_rotating_earth

11.download full earth map

12.copy MyTexture

13.add 

GLUquadric * quad = NULL; ///指標

float angle = 0;

     glEnable(GL_DEPTH_TEST);

     glPushMatrix();

        glRotatef(90, 1, 0, 0);

        glRotatef(angle++, 0, 0, 1);

        gluSphere(quad, 1, 30, 30);

     glPopMatrix();

glutIdleFunc(display);

quad = gluNewQuadric(); ///指標

gluQuadricTexture(quad, 1); /// 地球貼圖






























沒有留言:

張貼留言