13#include <opencv2/opencv.hpp>
15#include <opencv2/core/cuda.hpp>
16#include <opencv2/cudaarithm.hpp>
17#include <opencv2/cudaimgproc.hpp>
46 bool open(
const std::string &filename);
54 bool open(
int id,
int mode = 0);
71 bool is_open()
const {
return cap.isOpened(); }
85 bool createImage(VkDevice device, VkPhysicalDevice physDev, VkQueue gQueue,
86 VkCommandPool cmdPool,
size_t width,
size_t height,
87 const std::string &vert,
const std::string &frag);
102 void draw(
int x,
int y,
int width,
int height);
109 void draw(
int x,
int y);
119 bool reload(
size_t width,
size_t height,
const std::string &vert,
const std::string &frag);
126 bool readRgba(cv::Mat &rgba,
bool flipY =
false);
131 bool readGpuRgba(cv::cuda::GpuMat &rgba,
bool flipY =
false);
132 cv::cuda::Stream &cudaStream() {
return cuda_stream; }
140 bool read(cv::Mat &frame);
147 void set(
unsigned int option,
double value);
154 double get(
unsigned int option);
158 bool initializeCuda();
162 std::unique_ptr<VK_Sprite> sprite;
163 cv::VideoCapture cap;
166 bool cudaChecked =
false;
167 bool cudaAvailable =
false;
168 bool cudaMappedInput =
false;
169 bool cudaPipelineLogged =
false;
170 bool cudaFlipYForVulkan =
true;
171 cv::cuda::Stream cuda_stream{};
172 cv::cuda::GpuMat gpuFrame{};
173 cv::cuda::GpuMat gpuRgba{};
174 cv::cuda::GpuMat gpuVulkanRgba{};
175 cv::cuda::HostMem mappedFrame{cv::cuda::HostMem::SHARED};
176 cv::cuda::HostMem pinnedRgba{cv::cuda::HostMem::PAGE_LOCKED};
177 cv::Mat pinnedRgbaMat{};
Convenience wrapper that owns mesh, textures, descriptors, and pipeline state.
VK_Capture(VK_Capture &&)=delete
VK_Capture()=default
Default constructor.
~VK_Capture()=default
Destructor.
VK_Capture & operator=(const VK_Capture &)=delete
bool readToModelTexture(VKAbstractModel &model, bool flipY=false)
bool open(const std::string &filename)
Open a video file.
VK_Capture & operator=(VK_Capture &&)=delete
bool reload(size_t width, size_t height, const std::string &vert, const std::string &frag)
Replace the vertex/fragment shaders.
void resetSprite()
Destroy the current sprite and its Vulkan resources.
VK_Sprite * getSprite()
Access the backing sprite.
VK_Capture(const VK_Capture &)=delete
void close()
Close the capture device.
double get(unsigned int option)
Query a VideoCapture property.
bool readToSprite(VK_Sprite &targetSprite)
bool readRgba(cv::Mat &rgba, bool flipY=false)
bool createImage(VkDevice device, VkPhysicalDevice physDev, VkQueue gQueue, VkCommandPool cmdPool, size_t width, size_t height, const std::string &vert, const std::string &frag)
Allocate the VKSprite and upload the initial texture.
void draw(int x, int y, int width, int height)
Draw the current frame at a specified position and size.
bool is_open() const
Check whether the capture device is open.
bool read()
Capture and upload the next video frame.
void set(unsigned int option, double value)
Set a VideoCapture property.
Vulkan 2-D sprite renderer with optional custom shaders and instancing.
Utilities for loading and saving PNG images.