看板 C_and_CPP 關於我們 聯絡資訊
現在是使用openCV從camera抓frame下來,不存成BMP image 目的是為了提升效能 然後存成openGL的texture,再把多張texture連續地產生在openGL的視窗裡 程式碼如下: //openCV VideoCature cap(0); Mat frame; frame>>cap; //openGL //存texture loop for() glGenTextures(1, &textures[frame_count-1]); glBindTexture(GL_TEXTURE_2D,textures[frame_count-1]); glTexImage2D(GL_TEXTURE_2D, 0, 3,frame.cols, frame.rows, 0, GL_BGR_EXT, GL_UNSIGNED_BYTE, frame.data); glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR); glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);{ } Display()//call back { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glClearColor(1.0, 1.0, 1.0, 1.0); //背景white glMatrixMode(GL_MODELVIEW); glLoadIdentity(); glBegin(GL_QUADS); glTexCoord2f(0,0); glVertex3f(-11,-11,0); glTexCoord2f(1,0); glVertex3f(11,-11,0); glTexCoord2f(1,1); glVertex3f(11,11,0); glBindTexture(GL_TEXTURE_2D, textures[0]); glutReshapeFunc(WindowSize); //glutKeyboardFunc(Keyboard); glutDisplayFunc(Display); glutMainLoop(); } 目前只先印第一張texture 我在每一次Display()執行時便會printf一次訊息 結果只print兩次 畫面都全白 請前輩指點迷津,謝謝! -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 140.113.68.157