OpenCV 4.13.0
开源计算机视觉库 (Open Source Computer Vision)
正在加载...
正在搜索...
未找到匹配项
OpenGL 支持

详细说明

函数

void cv::imshow (const String &winname, const ogl::Texture2D &tex)
 Displays OpenGL 2D texture in the specified window.
 
void cv::setOpenGlContext (const String &winname)
 将指定窗口设置为当前 OpenGL 上下文。
 
void cv::setOpenGlDrawCallback (const String &winname, OpenGlDrawCallback onOpenGlDraw, void *userdata=0)
 设置一个回调函数,用于在显示的图像上方进行绘制。
 
void cv::updateWindow (const String &winname)
 强制窗口重绘其上下文并调用绘制回调(参见 cv::setOpenGlDrawCallback )。
 

函数文档 (Function Documentation)

◆ imshow()

void cv::imshow ( const String & 窗口名称,
const ogl::Texture2D & tex )
Python
cv.imshow(winname, mat) -> None

#include <opencv2/highgui.hpp>

Displays OpenGL 2D texture in the specified window.

参数
窗口名称窗口的名称。
texOpenGL 2D 纹理数据。

◆ setOpenGlContext()

void cv::setOpenGlContext ( const String & 窗口名称)

#include <opencv2/highgui.hpp>

将指定窗口设置为当前 OpenGL 上下文。

参数
窗口名称窗口的名称。

◆ setOpenGlDrawCallback()

void cv::setOpenGlDrawCallback ( const String & 窗口名称,
OpenGlDrawCallback onOpenGlDraw,
void * userdata=0 )

#include <opencv2/highgui.hpp>

设置一个回调函数,用于在显示的图像上方进行绘制。

函数 setOpenGlDrawCallback 可用于在窗口上绘制 3D 数据。请参见下面的回调函数示例。

void on_opengl(void* param)
{
glLoadIdentity();
glTranslated(0.0, 0.0, -1.0);
glRotatef( 55, 1, 0, 0 );
glRotatef( 45, 0, 1, 0 );
glRotatef( 0, 0, 0, 1 );
static const int coords[6][4][3] = {
{ { +1, -1, -1 }, { -1, -1, -1 }, { -1, +1, -1 }, { +1, +1, -1 } },
{ { +1, +1, -1 }, { -1, +1, -1 }, { -1, +1, +1 }, { +1, +1, +1 } },
{ { +1, -1, +1 }, { +1, -1, -1 }, { +1, +1, -1 }, { +1, +1, +1 } },
{ { -1, -1, -1 }, { -1, -1, +1 }, { -1, +1, +1 }, { -1, +1, -1 } },
{ { +1, -1, +1 }, { -1, -1, +1 }, { -1, -1, -1 }, { +1, -1, -1 } },
{ { -1, -1, +1 }, { +1, -1, +1 }, { +1, +1, +1 }, { -1, +1, +1 } }
};
for (int i = 0; i < 6; ++i) {
glColor3ub( i*20, 100+i*10, i*42 );
glBegin(GL_QUADS);
for (int j = 0; j < 4; ++j) {
glVertex3d(0.2 * coords[i][j][0], 0.2 * coords[i][j][1], 0.2 * coords[i][j][2]);
}
glEnd();
}
}
参数
窗口名称窗口的名称。
onOpenGlDraw每帧调用一次的函数指针。此函数应为 void Foo(void*) 形式。
userdata传递给回调函数的指针。(可选

◆ updateWindow()

void cv::updateWindow ( const String & 窗口名称)

#include <opencv2/highgui.hpp>

强制窗口重绘其上下文并调用绘制回调(参见 cv::setOpenGlDrawCallback )。

参数
窗口名称窗口的名称。