From de4fb3195ecf734c8d1c0aa1a683cf22153e7772 Mon Sep 17 00:00:00 2001 From: David OK Date: Wed, 6 Dec 2023 01:14:30 +0000 Subject: [PATCH] ENH: check implementation with video. --- .../Vulkan/hello_vulkan_image/CMakeLists.txt | 1 + .../Shakti/Vulkan/hello_vulkan_image/main.cpp | 25 ++++++++++++++++--- 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/cpp/examples/Shakti/Vulkan/hello_vulkan_image/CMakeLists.txt b/cpp/examples/Shakti/Vulkan/hello_vulkan_image/CMakeLists.txt index 0496e2943..4fa6efe86 100644 --- a/cpp/examples/Shakti/Vulkan/hello_vulkan_image/CMakeLists.txt +++ b/cpp/examples/Shakti/Vulkan/hello_vulkan_image/CMakeLists.txt @@ -4,6 +4,7 @@ target_link_libraries( PRIVATE SignalHandler # DO::Sara::Core # DO::Sara::ImageIO # + DO::Sara::VideoIO # DO::Shakti::Vulkan) set_target_properties(hello_vulkan_image PROPERTIES FOLDER "Examples/Shakti/Vulkan") diff --git a/cpp/examples/Shakti/Vulkan/hello_vulkan_image/main.cpp b/cpp/examples/Shakti/Vulkan/hello_vulkan_image/main.cpp index 1293e45ab..0da6d39c8 100644 --- a/cpp/examples/Shakti/Vulkan/hello_vulkan_image/main.cpp +++ b/cpp/examples/Shakti/Vulkan/hello_vulkan_image/main.cpp @@ -26,6 +26,7 @@ #include #include +#include namespace sara = DO::Sara; @@ -120,8 +121,14 @@ class VulkanImageRenderer : public kvk::GraphicsBackend init_ebos(indices); // Device memory for image data.. - const auto image_fp = program_dir_path / "data" / "dog.jpg"; - const auto image_host = sara::imread(image_fp.string()); + // const auto image_fp = program_dir_path / "data" / "dog.jpg"; + // const auto image_host = sara::imread(image_fp.string()); + + const auto video_fp = std::filesystem::path{ + "/home/david/Desktop/Capoeira/thursday/00372.MTS.mp4" // + }; + _vstream.open(video_fp.string()); + const auto image_host = _vstream.frame().convert(); init_vulkan_image_objects(image_host); init_image_copy_command_buffers(); // Initialize the image data on the device side. @@ -147,6 +154,14 @@ class VulkanImageRenderer : public kvk::GraphicsBackend while (!glfwWindowShouldClose(window)) { glfwPollEvents(); + + if (_vstream.read()) + { + const auto image_host = _vstream.frame().convert(); + copy_image_data_from_host_to_staging_buffer(image_host); + copy_image_data_from_staging_to_device_buffer(); + } + draw_frame(); if (SignalHandler::ctrl_c_hit) @@ -439,7 +454,7 @@ class VulkanImageRenderer : public kvk::GraphicsBackend } private: /* Methods to initialize image data */ - auto init_vulkan_image_objects(const sara::Image& image_host) + auto init_vulkan_image_objects(const sara::ImageView& image_host) -> void { // Temporary image object on the host side. @@ -496,7 +511,7 @@ class VulkanImageRenderer : public kvk::GraphicsBackend } auto copy_image_data_from_host_to_staging_buffer( - const sara::Image& image_host) -> void + const sara::ImageView& image_host) -> void { // Temporary image object on the host side. _image_staging_dmem.copy_from(image_host.data(), image_host.size(), 0); @@ -797,6 +812,8 @@ class VulkanImageRenderer : public kvk::GraphicsBackend private: int _current_frame = 0; + sara::VideoStream _vstream; + // Geometry data (quad) svk::Buffer _vbo; svk::DeviceMemory _vdm;