07 透過 OPENGL 顯示OPENCV 加快顯示速度

目的:

透過 OPENGL 顯示OPENCV 加快顯示速度

函數介紹:


參數值:

使用範例:

sample14_OpenGL
/* www.powenko.com
 Author: Powen Ko

 $ g++ main.cpp -o main -I/opt/local/include -L/opt/local/lib -lopencv_core.2.4.10 -lopencv_highgui.2.4.10

 $ g++   main.cpp -o main -I/opt/local/include -L/opt/local/lib -lopencv_core.2.4.10 -lopencv_highgui.2.4.10 -framework GLUT -framework OpenGL

 */
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/opencv.hpp>
#include <iostream>
#include <string.h>
#include <fstream>

#include <stdio.h>

#include <opencv/highgui.h>
#ifdef __APPLE__
#include <GLUT/glut.h>
#else
#include <GL/glut.h>
#endif

void display()
{
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    glPushMatrix();
    glutSolidTeapot(0.3);
    glPopMatrix();
    glFlush();
}

int main(int argc,char* argv[])
{

    IplImage * image=cvLoadImage("1.jpg");
   // cvShowImage("a", image);
   // cvWaitKey(0);

    glutInit(&argc,argv);
    glutCreateWindow("Hello World");
    glutDisplayFunc(display);

    glutMainLoop();
}

結果:

Screen Shot 2015-03-01 at 3.07.37 PM

補充資料:

OpenCV
CH01 簡介CH02 OpenCV APICH03 繪圖CH04 應用範例CH06 haarcascadesCH06 surf和siftCH07 OCRCH09 FaceCH5 輪廓(findContours、drawContours)