| OpenCV 3.4.1 Open Source Computer Vision

Modules | Namespaces | Classes | Enumerations | Enumerator | Functions
OpenGL interoperability
Core functionality

## 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)
| cv::ogl::Buffer::Buffer (Size asize, int atype, unsigned int abufId, bool autoRelease=false)
| cv::ogl::Buffer::Buffer (int arows, int acols, int atype, Target target=ARRAY_BUFFER, bool autoRelease=false)
| cv::ogl::Buffer::Buffer (Size asize, int atype, Target target=ARRAY_BUFFER, bool autoRelease=false)
| cv::ogl::Buffer::Buffer (InputArray arr, Target target=ARRAY_BUFFER, bool autoRelease=false)
| 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)
| cv::ogl::Texture2D::Texture2D (Size asize, Format aformat, bool autoRelease=false)
| cv::ogl::Texture2D::Texture2D (InputArray arr, bool autoRelease=false)
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)
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)
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
Context & | cv::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))
void | cv::ogl::render (const Arrays &arr, InputArray indices, int mode=POINTS, Scalar color=Scalar::all(255))
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

## § Access

enum cv::ogl::Buffer::Access

Enumerator
READ_ONLY |
WRITE_ONLY |
READ_WRITE |

## § Format

enum cv::ogl::Texture2D::Format

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.

## § RenderModes

enum cv::ogl::RenderModes

render mode

Enumerator
POINTS Python: cv.ogl.POINTS |
LINES Python: cv.ogl.LINES |
LINE_LOOP Python: cv.ogl.LINE_LOOP |
LINE_STRIP Python: cv.ogl.LINE_STRIP |
TRIANGLES Python: cv.ogl.TRIANGLES |
TRIANGLE_STRIP Python: cv.ogl.TRIANGLE_STRIP |
TRIANGLE_FAN Python: cv.ogl.TRIANGLE_FAN |
QUADS Python: cv.ogl.QUADS |
QUAD_STRIP Python: cv.ogl.QUAD_STRIP |
POLYGON Python: cv.ogl.POLYGON |

## § Target

enum cv::ogl::Buffer::Target

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

## § Arrays()

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

Default constructor.

## § Buffer() [1/6]

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

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.

## § Buffer() [2/6]

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.

Parameters

  arows | Number of rows in a 2D array.
  acols | Number of columns in a 2D array.
  atype | Array type ( CV_8UC1, ..., CV_64FC4 ). See Mat for details.
  abufId | Buffer object name.
  autoRelease | Auto release mode (if true, release will be called in object's destructor).

## § Buffer() [3/6]

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.

Parameters

  asize | 2D array size.
  atype | Array type ( CV_8UC1, ..., CV_64FC4 ). See Mat for details.
  abufId | Buffer object name.
  autoRelease | Auto release mode (if true, release will be called in object's destructor).

## § Buffer() [4/6]

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.

Parameters

  arows | Number of rows in a 2D array.
  acols | Number of columns in a 2D array.
  atype | Array type ( CV_8UC1, ..., CV_64FC4 ). See Mat for details.
  target | Buffer usage. See cv::ogl::Buffer::Target .
  autoRelease | Auto release mode (if true, release will be called in object's destructor).

## § Buffer() [5/6]

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.

Parameters

  asize | 2D array size.
  atype | Array type ( CV_8UC1, ..., CV_64FC4 ). See Mat for details.
  target | Buffer usage. See cv::ogl::Buffer::Target .
  autoRelease | Auto release mode (if true, release will be called in object's destructor).

## § Buffer() [6/6]

cv::ogl::Buffer::Buffer | ( | InputArray | arr,
|  | Target | target = `ARRAY_BUFFER`,
|  | bool | autoRelease = `false`
| ) |  |
| explicit

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

Parameters

  arr | Input array (host or device memory, it can be Mat , cuda::GpuMat or std::vector ).
  target | Buffer usage. See cv::ogl::Buffer::Target .
  autoRelease | Auto release mode (if true, release will be called in object's destructor).

## § Texture2D() [1/6]

cv::ogl::Texture2D::Texture2D | ( |  | ) |

The constructors.

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

## § Texture2D() [2/6]

cv::ogl::Texture2D::Texture2D | ( | int | arows,
|  | int | acols,
|  | Format | aformat,
|  | unsigned int | atexId,
|  | 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.

## § Texture2D() [3/6]

cv::ogl::Texture2D::Texture2D | ( | Size | asize,
|  | Format | aformat,
|  | unsigned int | atexId,
|  | 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.

## § Texture2D() [4/6]

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.

Parameters

  arows | Number of rows.
  acols | Number of columns.
  aformat | Image format. See cv::ogl::Texture2D::Format .
  autoRelease | Auto release mode (if true, release will be called in object's destructor).

## § Texture2D() [5/6]

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.

Parameters

  asize | 2D array size.
  aformat | Image format. See cv::ogl::Texture2D::Format .
  autoRelease | Auto release mode (if true, release will be called in object's destructor).

## § Texture2D() [6/6]

cv::ogl::Texture2D::Texture2D | ( | InputArray | arr,
|  | bool | autoRelease = `false`
| ) |  |
| explicit

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

Parameters

  arr | Input array (host or device memory, it can be Mat , cuda::GpuMat or ogl::Buffer ).
  autoRelease | Auto release mode (if true, release will be called in object's destructor).

## § bind() [1/3]

void cv::ogl::Buffer::bind | ( | Target | target | ) | const

Binds OpenGL buffer to the specified buffer binding point.

Parameters

  target | Binding point. See cv::ogl::Buffer::Target .

## § bind() [2/3]

void cv::ogl::Texture2D::bind | ( |  | ) | const

Binds texture to current active texture unit for GL_TEXTURE_2D target.

## § bind() [3/3]

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

Binds all vertex arrays.

## § bufId()

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

get OpenGL opject id

## § channels()

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

## § clone()

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.

Parameters

  target | Buffer usage for destination buffer.
  autoRelease | Auto release mode for destination buffer.

## § cols() [1/2]

int cv::ogl::Buffer::cols | ( |  | ) | const

## § cols() [2/2]

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

## § convertFromGLTexture2D()

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

Converts Texture2D object to OutputArray.

Parameters

  texture | - source Texture2D object.
  dst | - destination OutputArray.

## § convertToGLTexture2D()

void cv::ogl::convertToGLTexture2D | ( | InputArray | src,
|  | Texture2D & | texture
| ) |  |

Converts InputArray to Texture2D object.

Parameters

  src | - source InputArray.
  texture | - destination Texture2D object.

## § copyFrom() [1/3]

void cv::ogl::Buffer::copyFrom | ( | InputArray | arr,
|  | Target | target = `ARRAY_BUFFER`,
|  | bool | autoRelease = `false`
| ) |  |

Copies from host/device memory to OpenGL buffer.

Parameters

  arr | Input array (host or device memory, it can be Mat , cuda::GpuMat or std::vector ).
  target | Buffer usage. See cv::ogl::Buffer::Target .
  autoRelease | Auto release mode (if true, release will be called in object's destructor).

## § copyFrom() [2/3]

void cv::ogl::Buffer::copyFrom | ( | InputArray | arr,
|  | cuda::Stream & | stream,
|  | 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.

## § copyFrom() [3/3]

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

Copies from host/device memory to OpenGL texture.

Parameters

  arr | Input array (host or device memory, it can be Mat , cuda::GpuMat or ogl::Buffer ).
  autoRelease | Auto release mode (if true, release will be called in object's destructor).

## § copyTo() [1/3]

void cv::ogl::Buffer::copyTo | ( | OutputArray | arr | ) | const

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

Parameters

  arr | Destination array (host or device memory, can be Mat , cuda::GpuMat , std::vector or ogl::Buffer ).

## § copyTo() [2/3]

void cv::ogl::Buffer::copyTo | ( | OutputArray | arr,
|  | cuda::Stream & | stream
| ) |  | const

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

## § copyTo() [3/3]

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.

Parameters

  arr | Destination array (host or device memory, can be Mat , cuda::GpuMat , ogl::Buffer or ogl::Texture2D ).
  ddepth | Destination depth.
  autoRelease | Auto release mode for destination buffer (if arr is OpenGL buffer or texture).

## § create() [1/4]

void cv::ogl::Buffer::create | ( | int | arows,
|  | int | acols,
|  | int | atype,
|  | Target | target = `ARRAY_BUFFER`,
|  | bool | autoRelease = `false`
| ) |  |

Allocates memory for ogl::Buffer object.

Parameters

  arows | Number of rows in a 2D array.
  acols | Number of columns in a 2D array.
  atype | Array type ( CV_8UC1, ..., CV_64FC4 ). See Mat for details.
  target | Buffer usage. See cv::ogl::Buffer::Target .
  autoRelease | Auto release mode (if true, release will be called in object's destructor).

## § create() [2/4]

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.

Parameters

  asize | 2D array size.
  atype | Array type ( CV_8UC1, ..., CV_64FC4 ). See Mat for details.
  target | Buffer usage. See cv::ogl::Buffer::Target .
  autoRelease | Auto release mode (if true, release will be called in object's destructor).

## § create() [3/4]

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

Allocates memory for ogl::Texture2D object.

Parameters

  arows | Number of rows.
  acols | Number of columns.
  aformat | Image format. See cv::ogl::Texture2D::Format .
  autoRelease | Auto release mode (if true, release will be called in object's destructor).

## § create() [4/4]

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.

Parameters

  asize | 2D array size.
  aformat | Image format. See cv::ogl::Texture2D::Format .
  autoRelease | Auto release mode (if true, release will be called in object's destructor).

## § depth()

int cv::ogl::Buffer::depth | ( |  | ) | const

## § elemSize()

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

## § elemSize1()

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

## § empty() [1/3]

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

## § empty() [2/3]

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

## § empty() [3/3]

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

## § format()

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

## § initializeContextFromGL()

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

Creates OpenCL context from GL.

Returns
  Returns reference to OpenCL Context

## § mapDevice() [1/2]

cuda::GpuMat cv::ogl::Buffer::mapDevice | ( |  | ) |

map to device memory (blocking)

## § mapDevice() [2/2]

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

Maps OpenGL buffer to CUDA device memory.

This operation 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.

## § mapGLBuffer()

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

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

## § mapHost()

Mat cv::ogl::Buffer::mapHost | ( | Access | access | ) |

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

  access | Access 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 .

## § release() [1/3]

void cv::ogl::Buffer::release | ( |  | ) |

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

The function will call setAutoRelease(true) .

## § release() [2/3]

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

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

The function will call setAutoRelease(true) .

## § release() [3/3]

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

Releases all inner buffers.

## § render() [1/3]

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.

Parameters

  tex | Texture to draw.
  wndRect | Region of window, where to draw a texture (normalized coordinates).
  texRect | Region of texture to draw (normalized coordinates).

## § render() [2/3]

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.

Parameters

  arr | Array of privitives vertices.
  mode | Render mode. One of cv::ogl::RenderModes
  color | Color for all vertices. Will be used if arr doesn't contain color array.

## § render() [3/3]

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.

Parameters

  arr | Array of privitives vertices.
  indices | Array of vertices indices (host or device memory).
  mode | Render mode. One of cv::ogl::RenderModes
  color | Color for all vertices. Will be used if arr doesn't contain color array.

## § resetColorArray()

void cv::ogl::Arrays::resetColorArray | ( |  | ) |

Resets vertex colors.

## § resetNormalArray()

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

Resets vertex normals.

## § resetTexCoordArray()

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

Resets vertex texture coordinates.

## § resetVertexArray()

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

Resets vertex coordinates.

## § rows() [1/2]

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

## § rows() [2/2]

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

## § setAutoRelease() [1/3]

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

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

  flag | Auto release mode (if true, release will be called in object's destructor).

## § setAutoRelease() [2/3]

void cv::ogl::Texture2D::setAutoRelease | ( | bool | flag | ) |

Sets auto release mode.

Parameters

  flag | Auto 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.

## § setAutoRelease() [3/3]

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

Sets auto release mode all inner buffers.

Parameters

  flag | Auto release mode.

## § setColorArray()

void cv::ogl::Arrays::setColorArray | ( | InputArray | color | ) |

Sets an array of vertex colors.

Parameters

  color | array with vertex colors, can be both host and device memory.

## § setGlDevice()

void cv::cuda::setGlDevice | ( | int | device = `0` | ) |

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

  device | System index of a CUDA device starting with 0.

## § setNormalArray()

void cv::ogl::Arrays::setNormalArray | ( | InputArray | normal | ) |

Sets an array of vertex normals.

Parameters

  normal | array with vertex normals, can be both host and device memory.

## § setTexCoordArray()

void cv::ogl::Arrays::setTexCoordArray | ( | InputArray | texCoord | ) |

Sets an array of vertex texture coordinates.

Parameters

  texCoord | array with vertex texture coordinates, can be both host and device memory.

## § setVertexArray()

void cv::ogl::Arrays::setVertexArray | ( | InputArray | vertex | ) |

Sets an array of vertex coordinates.

Parameters

  vertex | array with vertex coordinates, can be both host and device memory.

## § size() [1/3]

Size cv::ogl::Buffer::size | ( |  | ) | const

## § size() [2/3]

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

## § size() [3/3]

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

Returns the vertex count.

## § texId()

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

get OpenGL opject id

## § type()

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

## § unbind()

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

Unbind any buffers from the specified binding point.

Parameters

  target | Binding point. See cv::ogl::Buffer::Target .

## § unmapDevice() [1/2]

void cv::ogl::Buffer::unmapDevice | ( |  | ) |

## § unmapDevice() [2/2]

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

Unmaps OpenGL buffer.

## § unmapGLBuffer()

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

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().

## § unmapHost()

void cv::ogl::Buffer::unmapHost | ( |  | ) |

Unmaps OpenGL buffer.