|
libmx2 2.2.1
C++20 multimedia and game-engine library (SDL2 / OpenGL / Vulkan)
|
OpenCV video capture source that renders via an OpenGL sprite. More...
#include <gl_cv.hpp>
Public Member Functions | |
| MXCapture ()=default | |
| Default constructor. | |
| ~MXCapture ()=default | |
| Destructor. | |
| MXCapture & | operator= (const MXCapture &)=delete |
| MXCapture & | operator= (MXCapture &&)=delete |
| MXCapture (const MXCapture &)=delete | |
| MXCapture (MXCapture &&)=delete | |
| bool | open (const std::string &filename) |
| Open a video file for capture. | |
| bool | open (int id, int mode=0) |
| Open a camera device for capture. | |
| void | close () |
| Close the video source. | |
| bool | is_open () const |
| Check whether the capture source is open. | |
| bool | createImage (gl::GLWindow *window, size_t width, size_t height, const std::string &vert, const std::string &frag) |
| Create the backing sprite/texture for displaying frames. | |
| gl::GLSprite * | getSprite () |
| Access the internal sprite. | |
| void | draw (int x, int y, int width, int height) |
| Draw the most recently captured frame. | |
| void | draw (int x, int y) |
| Draw using the sprite's native dimensions. | |
| bool | reload (const std::string &vert, const std::string &frag) |
| Replace the shader pair without reopening the source. | |
| bool | read () |
| Grab and decode the next frame from the source. | |
| bool | read (cv::Mat &frame) |
| Grab and decode the next frame into a cv::Mat. | |
| void | set (unsigned int option, double value) |
| Set a VideoCapture property. | |
| double | get (unsigned int option) |
| Query a VideoCapture property. | |
| MXCapture ()=default | |
| Default constructor. | |
| ~MXCapture ()=default | |
| Destructor. | |
| MXCapture & | operator= (const MXCapture &)=delete |
| MXCapture & | operator= (MXCapture &&)=delete |
| MXCapture (const MXCapture &)=delete | |
| MXCapture (MXCapture &&)=delete | |
| bool | open (const std::string &filename) |
| Open a video file. | |
| bool | open (int id, int mode=0) |
| Open a camera device. | |
| void | close () |
| Close the capture device. | |
| bool | is_open () const |
| Check whether the capture device is open. | |
| bool | createImage (VKWindow *window, size_t width, size_t height, const std::string &vert, const std::string &frag) |
| Allocate the VKSprite and upload the initial texture. | |
| VKSprite * | getSprite () |
| Access the backing sprite. | |
| void | draw (int x, int y, int width, int height) |
| Draw the current frame at a specified position and size. | |
| void | draw (int x, int y) |
| Draw using the sprite's native dimensions. | |
| bool | reload (size_t width, size_t height, const std::string &vert, const std::string &frag) |
| Replace the vertex/fragment shaders. | |
| bool | read () |
| Capture and upload the next video frame. | |
| bool | read (cv::Mat &frame) |
| Capture the next frame into a cv::Mat. | |
| void | set (unsigned int option, double value) |
| Set a VideoCapture property. | |
| double | get (unsigned int option) |
| Query a VideoCapture property. | |
Private Attributes | |
| gl::GLSprite | sprite |
| Rendering sprite. | |
| std::unique_ptr< gl::ShaderProgram > | shader |
| Active shader program. | |
| gl::GLWindow * | window = nullptr |
| Parent GL window. | |
| cv::VideoCapture | cap |
| OpenCV capture device. | |
| cv::Mat | frame |
| Most recent decoded frame. | |
| VKSprite * | sprite = nullptr |
| Backing Vulkan sprite. | |
OpenCV video capture source that renders via an OpenGL sprite.
Vulkan OpenCV video capture source.
Opens a video file or camera device, reads frames frame-by-frame, and uploads each frame to a gl::GLSprite texture for display inside a gl::GLWindow with a custom GLSL shader.
Opens a video file or camera, decodes frames, and uploads them to a VKSprite texture for Vulkan-accelerated rendering inside a VKWindow.
|
default |
Default constructor.
Referenced by MXCapture(), MXCapture(), operator=(), and operator=().
|
default |
Destructor.
|
delete |
References MXCapture().
|
delete |
References MXCapture().
|
default |
Default constructor.
|
default |
Destructor.
|
delete |
References MXCapture().
|
delete |
References MXCapture().
| void mx::MXCapture::close | ( | ) |
| void mx::MXCapture::close | ( | ) |
Close the capture device.
| bool mx::MXCapture::createImage | ( | gl::GLWindow * | window, |
| size_t | width, | ||
| size_t | height, | ||
| const std::string & | vert, | ||
| const std::string & | frag ) |
Create the backing sprite/texture for displaying frames.
| window | OpenGL window context. |
| width | Frame display width. |
| height | Frame display height. |
| vert | Path to the vertex shader GLSL file. |
| frag | Path to the fragment shader GLSL file. |
true on success. Definition at line 29 of file gl_cv.cpp.
References gl::createTexture(), shader, sprite, and window.
| bool mx::MXCapture::createImage | ( | VKWindow * | window, |
| size_t | width, | ||
| size_t | height, | ||
| const std::string & | vert, | ||
| const std::string & | frag ) |
| void mx::MXCapture::draw | ( | int | x, |
| int | y ) |
| void mx::MXCapture::draw | ( | int | x, |
| int | y ) |
Draw using the sprite's native dimensions.
| x | Destination X. |
| y | Destination Y. |
| void mx::MXCapture::draw | ( | int | x, |
| int | y, | ||
| int | width, | ||
| int | height ) |
| void mx::MXCapture::draw | ( | int | x, |
| int | y, | ||
| int | width, | ||
| int | height ) |
Draw the current frame at a specified position and size.
| x | Width destination X. |
| y | Width destination Y. |
| width | Display width. |
| height | Display height. |
| double mx::MXCapture::get | ( | unsigned int | option | ) |
| double mx::MXCapture::get | ( | unsigned int | option | ) |
Query a VideoCapture property.
| option | cv::VideoCaptureProperties constant. |
|
inline |
Access the internal sprite.
Definition at line 76 of file gl_cv.hpp.
References sprite.
|
inline |
|
inline |
|
inline |
| bool mx::MXCapture::open | ( | const std::string & | filename | ) |
| bool mx::MXCapture::open | ( | const std::string & | filename | ) |
Open a video file.
| filename | Path to the video file. |
true on success. | bool mx::MXCapture::open | ( | int | id, |
| int | mode = 0 ) |
| bool mx::MXCapture::open | ( | int | id, |
| int | mode = 0 ) |
Open a camera device.
| id | Camera index. |
| mode | Backend hint (0 = auto). |
true on success. References MXCapture().
References MXCapture().
References MXCapture().
References MXCapture().
| bool mx::MXCapture::read | ( | ) |
| bool mx::MXCapture::read | ( | ) |
Capture and upload the next video frame.
true if a frame was available. | bool mx::MXCapture::read | ( | cv::Mat & | frame | ) |
| bool mx::MXCapture::read | ( | cv::Mat & | frame | ) |
| bool mx::MXCapture::reload | ( | const std::string & | vert, |
| const std::string & | frag ) |
| bool mx::MXCapture::reload | ( | size_t | width, |
| size_t | height, | ||
| const std::string & | vert, | ||
| const std::string & | frag ) |
| void mx::MXCapture::set | ( | unsigned int | option, |
| double | value ) |
| void mx::MXCapture::set | ( | unsigned int | option, |
| double | value ) |
Set a VideoCapture property.
| option | cv::VideoCaptureProperties constant. |
| value | Desired value. |
|
private |
|
private |
|
private |
Active shader program.
Definition at line 130 of file gl_cv.hpp.
Referenced by createImage(), and reload().
|
private |
Rendering sprite.
Definition at line 129 of file gl_cv.hpp.
Referenced by createImage(), createImage(), draw(), draw(), getSprite(), read(), and reload().
|
private |
|
private |
Parent GL window.
Definition at line 131 of file gl_cv.hpp.
Referenced by createImage(), createImage(), draw(), and draw().