[opencv&opengl]多窗口显示

OPENGL:

main()函数

    int window1 = 0,window2 = 0;
    glutInit(&argc,argv);
    glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB);
    glutInitWindowSize(ImageWidth,ImageHeight);

    glutInitWindowPosition(1920,0);
    window1 = glutCreateWindow("1");
    glutDisplayFunc(display1);

    glutInitWindowPosition(1920+1280,0);
    window2 = glutCreateWindow("2");
    glutDisplayFunc(display2);

    glutMainLoop();
void display1()
{
    glClear(GL_COLOR_BUFFER_BIT);
    glDrawPixels(ImageWidth,ImageHeight,GL_BGR_EXT,GL_UNSIGNED_BYTE,PixelData1);
    glutSwapBuffers();
}

void display2()
{
    glClear(GL_COLOR_BUFFER_BIT);
    glDrawPixels(ImageWidth,ImageHeight,GL_BGR_EXT,GL_UNSIGNED_BYTE,PixelData2);
    glutSwapBuffers();
}

 

OPENCV:

    stringstream winName;
    for(int i = 0;i < DISPLAYWINDOWS;i++)
    {
        winName.clear();winName.str("");
        winName<<i;
        namedWindow(winName.str(),CV_WINDOW_NORMAL);
        cv::moveWindow(winName.str(),1920 + ImageWidth * i,0);
        setWindowProperty(winName.str(), CV_WND_PROP_FULLSCREEN, CV_WINDOW_FULLSCREEN );
    }
    
    for(int i = 0;i < DISPLAYWINDOWS;i++)
    {
        winName.clear();winName.str("");
        winName<<i;
        imshow(winName.str(),disLoop[i]);
        waitKey(1);
    }
主要用到的是moveWindow这个函数。

代码下载:https://github.com/zhanxiage1994/multi-WindowsDisplay.git
posted @ 2016-12-09 19:51  战侠歌1994  阅读(717)  评论(0编辑  收藏  举报