OpenCV  3.2.0-dev
Open Source Computer Vision
OpenGL interoperability

This section describes OpenGL interoperability. More...

Collaboration diagram for OpenGL interoperability:

Modules

 CUDA-accelerated Computer Vision
 

Namespaces

 cv::cuda
 
 cv::ogl::ocl
 

Classes

class  cv::ogl::Arrays
 Wrapper for OpenGL Client-Side Vertex arrays. More...
 
class  cv::ogl::Buffer
 Smart pointer for OpenGL buffer object with reference counting. More...
 
class  cv::ogl::Texture2D
 Smart pointer for OpenGL 2D texture memory with reference counting. More...
 

Enumerations

enum  cv::ogl::Buffer::Access {
  cv::ogl::Buffer::READ_ONLY = 0x88B8,
  cv::ogl::Buffer::WRITE_ONLY = 0x88B9,
  cv::ogl::Buffer::READ_WRITE = 0x88BA
}
 
enum  cv::ogl::Texture2D::Format {
  cv::ogl::Texture2D::NONE = 0,
  cv::ogl::Texture2D::DEPTH_COMPONENT = 0x1902,
  cv::ogl::Texture2D::RGB = 0x1907,
  cv::ogl::Texture2D::RGBA = 0x1908
}
 An Image Format describes the way that the images in Textures store their data. More...
 
enum  cv::ogl::RenderModes {
  cv::ogl::POINTS = 0x0000,
  cv::ogl::LINES = 0x0001,
  cv::ogl::LINE_LOOP = 0x0002,
  cv::ogl::LINE_STRIP = 0x0003,
  cv::ogl::TRIANGLES = 0x0004,
  cv::ogl::TRIANGLE_STRIP = 0x0005,
  cv::ogl::TRIANGLE_FAN = 0x0006,
  cv::ogl::QUADS = 0x0007,
  cv::ogl::QUAD_STRIP = 0x0008,
  cv::ogl::POLYGON = 0x0009
}
 render mode More...
 
enum  cv::ogl::Buffer::Target {
  cv::ogl::Buffer::ARRAY_BUFFER = 0x8892,
  cv::ogl::Buffer::ELEMENT_ARRAY_BUFFER = 0x8893,
  cv::ogl::Buffer::PIXEL_PACK_BUFFER = 0x88EB,
  cv::ogl::Buffer::PIXEL_UNPACK_BUFFER = 0x88EC
}
 The target defines how you intend to use the buffer object. More...
 

Functions

 cv::ogl::Arrays::Arrays ()
 Default constructor. More...
 
 cv::ogl::Buffer::Buffer ()
 The constructors. More...
 
 cv::ogl::Buffer::Buffer (int arows, int acols, int atype, unsigned int abufId, bool autoRelease=false)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More...
 
 cv::ogl::Buffer::Buffer (Size asize, int atype, unsigned int abufId, bool autoRelease=false)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More...
 
 cv::ogl::Buffer::Buffer (int arows, int acols, int atype, Target target=ARRAY_BUFFER, bool autoRelease=false)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More...
 
 cv::ogl::Buffer::Buffer (Size asize, int atype, Target target=ARRAY_BUFFER, bool autoRelease=false)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More...
 
 cv::ogl::Buffer::Buffer (InputArray arr, Target target=ARRAY_BUFFER, bool autoRelease=false)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More...
 
 cv::ogl::Texture2D::Texture2D ()
 The constructors. More...
 
 cv::ogl::Texture2D::Texture2D (int arows, int acols, Format aformat, unsigned int atexId, bool autoRelease=false)
 
 cv::ogl::Texture2D::Texture2D (Size asize, Format aformat, unsigned int atexId, bool autoRelease=false)
 
 cv::ogl::Texture2D::Texture2D (int arows, int acols, Format aformat, bool autoRelease=false)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More...
 
 cv::ogl::Texture2D::Texture2D (Size asize, Format aformat, bool autoRelease=false)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More...
 
 cv::ogl::Texture2D::Texture2D (InputArray arr, bool autoRelease=false)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More...
 
void cv::ogl::Buffer::bind (Target target) const
 Binds OpenGL buffer to the specified buffer binding point. More...
 
void cv::ogl::Texture2D::bind () const
 Binds texture to current active texture unit for GL_TEXTURE_2D target. More...
 
void cv::ogl::Arrays::bind () const
 Binds all vertex arrays. More...
 
unsigned int cv::ogl::Buffer::bufId () const
 get OpenGL opject id More...
 
int cv::ogl::Buffer::channels () const
 
Buffer cv::ogl::Buffer::clone (Target target=ARRAY_BUFFER, bool autoRelease=false) const
 Creates a full copy of the buffer object and the underlying data. More...
 
int cv::ogl::Buffer::cols () const
 
int cv::ogl::Texture2D::cols () const
 
void cv::ogl::convertFromGLTexture2D (const Texture2D &texture, OutputArray dst)
 Converts Texture2D object to OutputArray. More...
 
void cv::ogl::convertToGLTexture2D (InputArray src, Texture2D &texture)
 Converts InputArray to Texture2D object. More...
 
void cv::ogl::Buffer::copyFrom (InputArray arr, Target target=ARRAY_BUFFER, bool autoRelease=false)
 Copies from host/device memory to OpenGL buffer. More...
 
void cv::ogl::Buffer::copyFrom (InputArray arr, cuda::Stream &stream, Target target=ARRAY_BUFFER, bool autoRelease=false)
 
void cv::ogl::Texture2D::copyFrom (InputArray arr, bool autoRelease=false)
 Copies from host/device memory to OpenGL texture. More...
 
void cv::ogl::Buffer::copyTo (OutputArray arr) const
 Copies from OpenGL buffer to host/device memory or another OpenGL buffer object. More...
 
void cv::ogl::Buffer::copyTo (OutputArray arr, cuda::Stream &stream) const
 
void cv::ogl::Texture2D::copyTo (OutputArray arr, int ddepth=CV_32F, bool autoRelease=false) const
 Copies from OpenGL texture to host/device memory or another OpenGL texture object. More...
 
void cv::ogl::Buffer::create (int arows, int acols, int atype, Target target=ARRAY_BUFFER, bool autoRelease=false)
 Allocates memory for ogl::Buffer object. More...
 
void cv::ogl::Buffer::create (Size asize, int atype, Target target=ARRAY_BUFFER, bool autoRelease=false)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More...
 
void cv::ogl::Texture2D::create (int arows, int acols, Format aformat, bool autoRelease=false)
 Allocates memory for ogl::Texture2D object. More...
 
void cv::ogl::Texture2D::create (Size asize, Format aformat, bool autoRelease=false)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More...
 
int cv::ogl::Buffer::depth () const
 
int cv::ogl::Buffer::elemSize () const
 
int cv::ogl::Buffer::elemSize1 () const
 
bool cv::ogl::Buffer::empty () const
 
bool cv::ogl::Texture2D::empty () const
 
bool cv::ogl::Arrays::empty () const
 
Format cv::ogl::Texture2D::format () const
 
Contextcv::ogl::ocl::initializeContextFromGL ()
 Creates OpenCL context from GL. More...
 
cuda::GpuMat cv::ogl::Buffer::mapDevice ()
 map to device memory (blocking) More...
 
cuda::GpuMat cv::ogl::Buffer::mapDevice (cuda::Stream &stream)
 Maps OpenGL buffer to CUDA device memory. More...
 
UMat cv::ogl::mapGLBuffer (const Buffer &buffer, int accessFlags=ACCESS_READ|ACCESS_WRITE)
 Maps Buffer object to process on CL side (convert to UMat). More...
 
Mat cv::ogl::Buffer::mapHost (Access access)
 Maps OpenGL buffer to host memory. More...
 
void cv::ogl::Buffer::release ()
 Decrements the reference counter and destroys the buffer object if needed. More...
 
void cv::ogl::Texture2D::release ()
 Decrements the reference counter and destroys the texture object if needed. More...
 
void cv::ogl::Arrays::release ()
 Releases all inner buffers. More...
 
void cv::ogl::render (const Texture2D &tex, Rect_< double > wndRect=Rect_< double >(0.0, 0.0, 1.0, 1.0), Rect_< double > texRect=Rect_< double >(0.0, 0.0, 1.0, 1.0))
 Render OpenGL texture or primitives. More...
 
void cv::ogl::render (const Arrays &arr, int mode=POINTS, Scalar color=Scalar::all(255))
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More...
 
void cv::ogl::render (const Arrays &arr, InputArray indices, int mode=POINTS, Scalar color=Scalar::all(255))
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More...
 
void cv::ogl::Arrays::resetColorArray ()
 Resets vertex colors. More...
 
void cv::ogl::Arrays::resetNormalArray ()
 Resets vertex normals. More...
 
void cv::ogl::Arrays::resetTexCoordArray ()
 Resets vertex texture coordinates. More...
 
void cv::ogl::Arrays::resetVertexArray ()
 Resets vertex coordinates. More...
 
int cv::ogl::Buffer::rows () const
 
int cv::ogl::Texture2D::rows () const
 
void cv::ogl::Buffer::setAutoRelease (bool flag)
 Sets auto release mode. More...
 
void cv::ogl::Texture2D::setAutoRelease (bool flag)
 Sets auto release mode. More...
 
void cv::ogl::Arrays::setAutoRelease (bool flag)
 Sets auto release mode all inner buffers. More...
 
void cv::ogl::Arrays::setColorArray (InputArray color)
 Sets an array of vertex colors. More...
 
void cv::cuda::setGlDevice (int device=0)
 Sets a CUDA device and initializes it for the current thread with OpenGL interoperability. More...
 
void cv::ogl::Arrays::setNormalArray (InputArray normal)
 Sets an array of vertex normals. More...
 
void cv::ogl::Arrays::setTexCoordArray (InputArray texCoord)
 Sets an array of vertex texture coordinates. More...
 
void cv::ogl::Arrays::setVertexArray (InputArray vertex)
 Sets an array of vertex coordinates. More...
 
Size cv::ogl::Buffer::size () const
 
Size cv::ogl::Texture2D::size () const
 
int cv::ogl::Arrays::size () const
 Returns the vertex count. More...
 
unsigned int cv::ogl::Texture2D::texId () const
 get OpenGL opject id More...
 
int cv::ogl::Buffer::type () const
 
static void cv::ogl::Buffer::unbind (Target target)
 Unbind any buffers from the specified binding point. More...
 
void cv::ogl::Buffer::unmapDevice ()
 
void cv::ogl::Buffer::unmapDevice (cuda::Stream &stream)
 Unmaps OpenGL buffer. More...
 
void cv::ogl::unmapGLBuffer (UMat &u)
 Unmaps Buffer object (releases UMat, previously mapped from Buffer). More...
 
void cv::ogl::Buffer::unmapHost ()
 Unmaps OpenGL buffer. More...
 

Detailed Description

This section describes OpenGL interoperability.

To enable OpenGL support, configure OpenCV using CMake with WITH_OPENGL=ON . Currently OpenGL is supported only with WIN32, GTK and Qt backends on Windows and Linux (MacOS and Android are not supported). For GTK backend gtkglext-1.0 library is required.

To use OpenGL functionality you should first create OpenGL context (window or frame buffer). You can do this with namedWindow function or with other OpenGL toolkit (GLUT, for example).

Enumeration Type Documentation

Enumerator
READ_ONLY 
WRITE_ONLY 
READ_WRITE 

An Image Format describes the way that the images in Textures store their data.

Enumerator
NONE 
DEPTH_COMPONENT 

Depth.

RGB 

Red, Green, Blue.

RGBA 

Red, Green, Blue, Alpha.

#include <core/include/opencv2/core/opengl.hpp>

render mode

Enumerator
POINTS 
LINES 
LINE_LOOP 
LINE_STRIP 
TRIANGLES 
TRIANGLE_STRIP 
TRIANGLE_FAN 
QUADS 
QUAD_STRIP 
POLYGON 

The target defines how you intend to use the buffer object.

Enumerator
ARRAY_BUFFER 

The buffer will be used as a source for vertex data.

ELEMENT_ARRAY_BUFFER 

The buffer will be used for indices (in glDrawElements, for example)

PIXEL_PACK_BUFFER 

The buffer will be used for reading from OpenGL textures.

PIXEL_UNPACK_BUFFER 

The buffer will be used for writing to OpenGL textures.

Function Documentation

cv::ogl::Arrays::Arrays ( )

#include <core/include/opencv2/core/opengl.hpp>

Default constructor.

cv::ogl::Buffer::Buffer ( )

#include <core/include/opencv2/core/opengl.hpp>

The constructors.

Creates empty ogl::Buffer object, creates ogl::Buffer object from existed buffer ( abufId parameter), allocates memory for ogl::Buffer object or copies from host/device memory.

cv::ogl::Buffer::Buffer ( int  arows,
int  acols,
int  atype,
unsigned int  abufId,
bool  autoRelease = false 
)

#include <core/include/opencv2/core/opengl.hpp>

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Parameters
arowsNumber of rows in a 2D array.
acolsNumber of columns in a 2D array.
atypeArray type ( CV_8UC1, ..., CV_64FC4 ). See Mat for details.
abufIdBuffer object name.
autoReleaseAuto release mode (if true, release will be called in object's destructor).
cv::ogl::Buffer::Buffer ( Size  asize,
int  atype,
unsigned int  abufId,
bool  autoRelease = false 
)

#include <core/include/opencv2/core/opengl.hpp>

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Parameters
asize2D array size.
atypeArray type ( CV_8UC1, ..., CV_64FC4 ). See Mat for details.
abufIdBuffer object name.
autoReleaseAuto release mode (if true, release will be called in object's destructor).
cv::ogl::Buffer::Buffer ( int  arows,
int  acols,
int  atype,
Target  target = ARRAY_BUFFER,
bool  autoRelease = false 
)

#include <core/include/opencv2/core/opengl.hpp>

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Parameters
arowsNumber of rows in a 2D array.
acolsNumber of columns in a 2D array.
atypeArray type ( CV_8UC1, ..., CV_64FC4 ). See Mat for details.
targetBuffer usage. See cv::ogl::Buffer::Target .
autoReleaseAuto release mode (if true, release will be called in object's destructor).
cv::ogl::Buffer::Buffer ( Size  asize,
int  atype,
Target  target = ARRAY_BUFFER,
bool  autoRelease = false 
)

#include <core/include/opencv2/core/opengl.hpp>

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Parameters
asize2D array size.
atypeArray type ( CV_8UC1, ..., CV_64FC4 ). See Mat for details.
targetBuffer usage. See cv::ogl::Buffer::Target .
autoReleaseAuto release mode (if true, release will be called in object's destructor).
cv::ogl::Buffer::Buffer ( InputArray  arr,
Target  target = ARRAY_BUFFER,
bool  autoRelease = false 
)
explicit

#include <core/include/opencv2/core/opengl.hpp>

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Parameters
arrInput array (host or device memory, it can be Mat , cuda::GpuMat or std::vector ).
targetBuffer usage. See cv::ogl::Buffer::Target .
autoReleaseAuto release mode (if true, release will be called in object's destructor).
cv::ogl::Texture2D::Texture2D ( )

#include <core/include/opencv2/core/opengl.hpp>

The constructors.

Creates empty ogl::Texture2D object, allocates memory for ogl::Texture2D object or copies from host/device memory.

cv::ogl::Texture2D::Texture2D ( int  arows,
int  acols,
Format  aformat,
unsigned int  atexId,
bool  autoRelease = false 
)

#include <core/include/opencv2/core/opengl.hpp>

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

cv::ogl::Texture2D::Texture2D ( Size  asize,
Format  aformat,
unsigned int  atexId,
bool  autoRelease = false 
)

#include <core/include/opencv2/core/opengl.hpp>

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

cv::ogl::Texture2D::Texture2D ( int  arows,
int  acols,
Format  aformat,
bool  autoRelease = false 
)

#include <core/include/opencv2/core/opengl.hpp>

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Parameters
arowsNumber of rows.
acolsNumber of columns.
aformatImage format. See cv::ogl::Texture2D::Format .
autoReleaseAuto release mode (if true, release will be called in object's destructor).
cv::ogl::Texture2D::Texture2D ( Size  asize,
Format  aformat,
bool  autoRelease = false 
)

#include <core/include/opencv2/core/opengl.hpp>

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Parameters
asize2D array size.
aformatImage format. See cv::ogl::Texture2D::Format .
autoReleaseAuto release mode (if true, release will be called in object's destructor).
cv::ogl::Texture2D::Texture2D ( InputArray  arr,
bool  autoRelease = false 
)
explicit

#include <core/include/opencv2/core/opengl.hpp>

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Parameters
arrInput array (host or device memory, it can be Mat , cuda::GpuMat or ogl::Buffer ).
autoReleaseAuto release mode (if true, release will be called in object's destructor).
void cv::ogl::Buffer::bind ( Target  target) const

#include <core/include/opencv2/core/opengl.hpp>

Binds OpenGL buffer to the specified buffer binding point.

Parameters
targetBinding point. See cv::ogl::Buffer::Target .
void cv::ogl::Texture2D::bind ( ) const

#include <core/include/opencv2/core/opengl.hpp>

Binds texture to current active texture unit for GL_TEXTURE_2D target.

void cv::ogl::Arrays::bind ( ) const

#include <core/include/opencv2/core/opengl.hpp>

Binds all vertex arrays.

unsigned int cv::ogl::Buffer::bufId ( ) const

#include <core/include/opencv2/core/opengl.hpp>

get OpenGL opject id

int cv::ogl::Buffer::channels ( ) const

#include <core/include/opencv2/core/opengl.hpp>

Buffer cv::ogl::Buffer::clone ( Target  target = ARRAY_BUFFER,
bool  autoRelease = false 
) const

#include <core/include/opencv2/core/opengl.hpp>

Creates a full copy of the buffer object and the underlying data.

Parameters
targetBuffer usage for destination buffer.
autoReleaseAuto release mode for destination buffer.
int cv::ogl::Buffer::cols ( ) const

#include <core/include/opencv2/core/opengl.hpp>

int cv::ogl::Texture2D::cols ( ) const

#include <core/include/opencv2/core/opengl.hpp>

void cv::ogl::convertFromGLTexture2D ( const Texture2D texture,
OutputArray  dst 
)

#include <core/include/opencv2/core/opengl.hpp>

Converts Texture2D object to OutputArray.

Parameters
texture- source Texture2D object.
dst- destination OutputArray.
void cv::ogl::convertToGLTexture2D ( InputArray  src,
Texture2D texture 
)

#include <core/include/opencv2/core/opengl.hpp>

Converts InputArray to Texture2D object.

Parameters
src- source InputArray.
texture- destination Texture2D object.
void cv::ogl::Buffer::copyFrom ( InputArray  arr,
Target  target = ARRAY_BUFFER,
bool  autoRelease = false 
)

#include <core/include/opencv2/core/opengl.hpp>

Copies from host/device memory to OpenGL buffer.

Parameters
arrInput array (host or device memory, it can be Mat , cuda::GpuMat or std::vector ).
targetBuffer usage. See cv::ogl::Buffer::Target .
autoReleaseAuto release mode (if true, release will be called in object's destructor).
void cv::ogl::Buffer::copyFrom ( InputArray  arr,
cuda::Stream stream,
Target  target = ARRAY_BUFFER,
bool  autoRelease = false 
)

#include <core/include/opencv2/core/opengl.hpp>

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

void cv::ogl::Texture2D::copyFrom ( InputArray  arr,
bool  autoRelease = false 
)

#include <core/include/opencv2/core/opengl.hpp>

Copies from host/device memory to OpenGL texture.

Parameters
arrInput array (host or device memory, it can be Mat , cuda::GpuMat or ogl::Buffer ).
autoReleaseAuto release mode (if true, release will be called in object's destructor).
void cv::ogl::Buffer::copyTo ( OutputArray  arr) const

#include <core/include/opencv2/core/opengl.hpp>

Copies from OpenGL buffer to host/device memory or another OpenGL buffer object.

Parameters
arrDestination array (host or device memory, can be Mat , cuda::GpuMat , std::vector or ogl::Buffer ).
void cv::ogl::Buffer::copyTo ( OutputArray  arr,
cuda::Stream stream 
) const

#include <core/include/opencv2/core/opengl.hpp>

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

void cv::ogl::Texture2D::copyTo ( OutputArray  arr,
int  ddepth = CV_32F,
bool  autoRelease = false 
) const

#include <core/include/opencv2/core/opengl.hpp>

Copies from OpenGL texture to host/device memory or another OpenGL texture object.

Parameters
arrDestination array (host or device memory, can be Mat , cuda::GpuMat , ogl::Buffer or ogl::Texture2D ).
ddepthDestination depth.
autoReleaseAuto release mode for destination buffer (if arr is OpenGL buffer or texture).
void cv::ogl::Buffer::create ( int  arows,
int  acols,
int  atype,
Target  target = ARRAY_BUFFER,
bool  autoRelease = false 
)

#include <core/include/opencv2/core/opengl.hpp>

Allocates memory for ogl::Buffer object.

Parameters
arowsNumber of rows in a 2D array.
acolsNumber of columns in a 2D array.
atypeArray type ( CV_8UC1, ..., CV_64FC4 ). See Mat for details.
targetBuffer usage. See cv::ogl::Buffer::Target .
autoReleaseAuto release mode (if true, release will be called in object's destructor).
void cv::ogl::Buffer::create ( Size  asize,
int  atype,
Target  target = ARRAY_BUFFER,
bool  autoRelease = false 
)

#include <core/include/opencv2/core/opengl.hpp>

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Parameters
asize2D array size.
atypeArray type ( CV_8UC1, ..., CV_64FC4 ). See Mat for details.
targetBuffer usage. See cv::ogl::Buffer::Target .
autoReleaseAuto release mode (if true, release will be called in object's destructor).
void cv::ogl::Texture2D::create ( int  arows,
int  acols,
Format  aformat,
bool  autoRelease = false 
)

#include <core/include/opencv2/core/opengl.hpp>

Allocates memory for ogl::Texture2D object.

Parameters
arowsNumber of rows.
acolsNumber of columns.
aformatImage format. See cv::ogl::Texture2D::Format .
autoReleaseAuto release mode (if true, release will be called in object's destructor).
void cv::ogl::Texture2D::create ( Size  asize,
Format  aformat,
bool  autoRelease = false 
)

#include <core/include/opencv2/core/opengl.hpp>

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Parameters
asize2D array size.
aformatImage format. See cv::ogl::Texture2D::Format .
autoReleaseAuto release mode (if true, release will be called in object's destructor).
int cv::ogl::Buffer::depth ( ) const

#include <core/include/opencv2/core/opengl.hpp>

int cv::ogl::Buffer::elemSize ( ) const

#include <core/include/opencv2/core/opengl.hpp>

int cv::ogl::Buffer::elemSize1 ( ) const

#include <core/include/opencv2/core/opengl.hpp>

bool cv::ogl::Buffer::empty ( ) const

#include <core/include/opencv2/core/opengl.hpp>

bool cv::ogl::Texture2D::empty ( ) const

#include <core/include/opencv2/core/opengl.hpp>

bool cv::ogl::Arrays::empty ( ) const

#include <core/include/opencv2/core/opengl.hpp>

Format cv::ogl::Texture2D::format ( ) const

#include <core/include/opencv2/core/opengl.hpp>

Context& cv::ogl::ocl::initializeContextFromGL ( )

#include <core/include/opencv2/core/opengl.hpp>

Creates OpenCL context from GL.

Returns
Returns reference to OpenCL Context
cuda::GpuMat cv::ogl::Buffer::mapDevice ( )

#include <core/include/opencv2/core/opengl.hpp>

map to device memory (blocking)

cuda::GpuMat cv::ogl::Buffer::mapDevice ( cuda::Stream stream)

#include <core/include/opencv2/core/opengl.hpp>

Maps OpenGL buffer to CUDA device memory.

This operatation doesn't copy data. Several buffer objects can be mapped to CUDA memory at a time.

A mapped data store must be unmapped with ogl::Buffer::unmapDevice before its buffer object is used.

UMat cv::ogl::mapGLBuffer ( const Buffer buffer,
int  accessFlags = ACCESS_READ|ACCESS_WRITE 
)

#include <core/include/opencv2/core/opengl.hpp>

Maps Buffer object to process on CL side (convert to UMat).

Function creates CL buffer from GL one, and then constructs UMat that can be used to process buffer data with OpenCV functions. Note that in current implementation UMat constructed this way doesn't own corresponding GL buffer object, so it is the user responsibility to close down CL/GL buffers relationships by explicitly calling unmapGLBuffer() function.

Parameters
buffer- source Buffer object.
accessFlags- data access flags (ACCESS_READ|ACCESS_WRITE).
Returns
Returns UMat object
Mat cv::ogl::Buffer::mapHost ( Access  access)

#include <core/include/opencv2/core/opengl.hpp>

Maps OpenGL buffer to host memory.

mapHost maps to the client's address space the entire data store of the buffer object. The data can then be directly read and/or written relative to the returned pointer, depending on the specified access policy.

A mapped data store must be unmapped with ogl::Buffer::unmapHost before its buffer object is used.

This operation can lead to memory transfers between host and device.

Only one buffer object can be mapped at a time.

Parameters
accessAccess policy, indicating whether it will be possible to read from, write to, or both read from and write to the buffer object's mapped data store. The symbolic constant must be ogl::Buffer::READ_ONLY , ogl::Buffer::WRITE_ONLY or ogl::Buffer::READ_WRITE .
void cv::ogl::Buffer::release ( )

#include <core/include/opencv2/core/opengl.hpp>

Decrements the reference counter and destroys the buffer object if needed.

The function will call setAutoRelease(true) .

void cv::ogl::Texture2D::release ( )

#include <core/include/opencv2/core/opengl.hpp>

Decrements the reference counter and destroys the texture object if needed.

The function will call setAutoRelease(true) .

void cv::ogl::Arrays::release ( )

#include <core/include/opencv2/core/opengl.hpp>

Releases all inner buffers.

void cv::ogl::render ( const Texture2D tex,
Rect_< double >  wndRect = Rect_< double >(0.0, 0.0, 1.0, 1.0),
Rect_< double >  texRect = Rect_< double >(0.0, 0.0, 1.0, 1.0) 
)

#include <core/include/opencv2/core/opengl.hpp>

Render OpenGL texture or primitives.

Parameters
texTexture to draw.
wndRectRegion of window, where to draw a texture (normalized coordinates).
texRectRegion of texture to draw (normalized coordinates).
void cv::ogl::render ( const Arrays arr,
int  mode = POINTS,
Scalar  color = Scalar::all(255) 
)

#include <core/include/opencv2/core/opengl.hpp>

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Parameters
arrArray of privitives vertices.
modeRender mode. One of cv::ogl::RenderModes
colorColor for all vertices. Will be used if arr doesn't contain color array.
void cv::ogl::render ( const Arrays arr,
InputArray  indices,
int  mode = POINTS,
Scalar  color = Scalar::all(255) 
)

#include <core/include/opencv2/core/opengl.hpp>

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Parameters
arrArray of privitives vertices.
indicesArray of vertices indices (host or device memory).
modeRender mode. One of cv::ogl::RenderModes
colorColor for all vertices. Will be used if arr doesn't contain color array.
void cv::ogl::Arrays::resetColorArray ( )

#include <core/include/opencv2/core/opengl.hpp>

Resets vertex colors.

void cv::ogl::Arrays::resetNormalArray ( )

#include <core/include/opencv2/core/opengl.hpp>

Resets vertex normals.

void cv::ogl::Arrays::resetTexCoordArray ( )

#include <core/include/opencv2/core/opengl.hpp>

Resets vertex texture coordinates.

void cv::ogl::Arrays::resetVertexArray ( )

#include <core/include/opencv2/core/opengl.hpp>

Resets vertex coordinates.

int cv::ogl::Buffer::rows ( ) const

#include <core/include/opencv2/core/opengl.hpp>

int cv::ogl::Texture2D::rows ( ) const

#include <core/include/opencv2/core/opengl.hpp>

void cv::ogl::Buffer::setAutoRelease ( bool  flag)

#include <core/include/opencv2/core/opengl.hpp>

Sets auto release mode.

The lifetime of the OpenGL object is tied to the lifetime of the context. If OpenGL context was bound to a window it could be released at any time (user can close a window). If object's destructor is called after destruction of the context it will cause an error. Thus ogl::Buffer doesn't destroy OpenGL object in destructor by default (all OpenGL resources will be released with OpenGL context). This function can force ogl::Buffer destructor to destroy OpenGL object.

Parameters
flagAuto release mode (if true, release will be called in object's destructor).
void cv::ogl::Texture2D::setAutoRelease ( bool  flag)

#include <core/include/opencv2/core/opengl.hpp>

Sets auto release mode.

Parameters
flagAuto release mode (if true, release will be called in object's destructor).

The lifetime of the OpenGL object is tied to the lifetime of the context. If OpenGL context was bound to a window it could be released at any time (user can close a window). If object's destructor is called after destruction of the context it will cause an error. Thus ogl::Texture2D doesn't destroy OpenGL object in destructor by default (all OpenGL resources will be released with OpenGL context). This function can force ogl::Texture2D destructor to destroy OpenGL object.

void cv::ogl::Arrays::setAutoRelease ( bool  flag)

#include <core/include/opencv2/core/opengl.hpp>

Sets auto release mode all inner buffers.

Parameters
flagAuto release mode.
void cv::ogl::Arrays::setColorArray ( InputArray  color)

#include <core/include/opencv2/core/opengl.hpp>

Sets an array of vertex colors.

Parameters
colorarray with vertex colors, can be both host and device memory.
void cv::cuda::setGlDevice ( int  device = 0)

#include <core/include/opencv2/core/opengl.hpp>

Sets a CUDA device and initializes it for the current thread with OpenGL interoperability.

This function should be explicitly called after OpenGL context creation and before any CUDA calls.

Parameters
deviceSystem index of a CUDA device starting with 0.
void cv::ogl::Arrays::setNormalArray ( InputArray  normal)

#include <core/include/opencv2/core/opengl.hpp>

Sets an array of vertex normals.

Parameters
normalarray with vertex normals, can be both host and device memory.
void cv::ogl::Arrays::setTexCoordArray ( InputArray  texCoord)

#include <core/include/opencv2/core/opengl.hpp>

Sets an array of vertex texture coordinates.

Parameters
texCoordarray with vertex texture coordinates, can be both host and device memory.
void cv::ogl::Arrays::setVertexArray ( InputArray  vertex)

#include <core/include/opencv2/core/opengl.hpp>

Sets an array of vertex coordinates.

Parameters
vertexarray with vertex coordinates, can be both host and device memory.
Size cv::ogl::Buffer::size ( ) const

#include <core/include/opencv2/core/opengl.hpp>

Size cv::ogl::Texture2D::size ( ) const

#include <core/include/opencv2/core/opengl.hpp>

int cv::ogl::Arrays::size ( ) const

#include <core/include/opencv2/core/opengl.hpp>

Returns the vertex count.

unsigned int cv::ogl::Texture2D::texId ( ) const

#include <core/include/opencv2/core/opengl.hpp>

get OpenGL opject id

int cv::ogl::Buffer::type ( ) const

#include <core/include/opencv2/core/opengl.hpp>

static void cv::ogl::Buffer::unbind ( Target  target)
static

#include <core/include/opencv2/core/opengl.hpp>

Unbind any buffers from the specified binding point.

Parameters
targetBinding point. See cv::ogl::Buffer::Target .
void cv::ogl::Buffer::unmapDevice ( )

#include <core/include/opencv2/core/opengl.hpp>

void cv::ogl::Buffer::unmapDevice ( cuda::Stream stream)

#include <core/include/opencv2/core/opengl.hpp>

Unmaps OpenGL buffer.

void cv::ogl::unmapGLBuffer ( UMat u)

#include <core/include/opencv2/core/opengl.hpp>

Unmaps Buffer object (releases UMat, previously mapped from Buffer).

Function must be called explicitly by the user for each UMat previously constructed by the call to mapGLBuffer() function.

Parameters
u- source UMat, created by mapGLBuffer().
void cv::ogl::Buffer::unmapHost ( )

#include <core/include/opencv2/core/opengl.hpp>

Unmaps OpenGL buffer.