diff options
-rw-r--r-- | video-ps3eye/CMakeLists.txt | 2 | ||||
-rw-r--r-- | video-ps3eye/module.cpp | 33 | ||||
-rw-r--r-- | video-ps3eye/module.hpp | 51 | ||||
m--------- | video-ps3eye/ps3eye-driver | 0 | ||||
-rw-r--r-- | video-ps3eye/shm-layout.hpp | 40 | ||||
-rw-r--r-- | video-ps3eye/wrapper.cxx | 7 |
6 files changed, 132 insertions, 1 deletions
diff --git a/video-ps3eye/CMakeLists.txt b/video-ps3eye/CMakeLists.txt index 98921f4f..2fac5f9c 100644 --- a/video-ps3eye/CMakeLists.txt +++ b/video-ps3eye/CMakeLists.txt @@ -23,6 +23,8 @@ endif() if(TARGET ps3eye-driver) otr_module(video-ps3eye) + link_libraries(ps3eye-driver) + add_executable(ps3eye-subprocess "wrapper.cxx") if(WIN32) set(path "${SDK_LIBUSB}/libusb-1.0.dll") if(EXISTS "${path}") diff --git a/video-ps3eye/module.cpp b/video-ps3eye/module.cpp index b04c6acb..ac6d8807 100644 --- a/video-ps3eye/module.cpp +++ b/video-ps3eye/module.cpp @@ -1,5 +1,5 @@ #include "module.hpp" - +#if 0 #include <libusb.h> int device_count() @@ -48,3 +48,34 @@ bool check_device_exists() return ret; } +static const QString camera_name = QStringLiteral("PS3 Eye open driver"); + +namespace video::impl { + +std::vector<QString> ps3eye_camera_::camera_names() const +{ + if (check_device_exists()) + return { camera_name }; + else + return {}; +} +std::unique_ptr<camera> ps3eye_camera_::make_camera(const QString& name) +{ + if (name == camera_name && check_device_exists()) + return std::make_unique<ps3eye_camera>(); + else + return {}; +} +bool ps3eye_camera_::show_dialog(const QString& camera_name) +{ + // TODO + return false; +} +bool ps3eye_camera_::can_show_dialog(const QString& camera_name) +{ + return false; +} + +} // ns video::impl + +#endif diff --git a/video-ps3eye/module.hpp b/video-ps3eye/module.hpp index a9283d14..357af14c 100644 --- a/video-ps3eye/module.hpp +++ b/video-ps3eye/module.hpp @@ -1,3 +1,54 @@ #pragma once #include "video/camera.hpp" + +#if 0 + +namespace video { + +struct OTR_VIDEO_EXPORT camera_ +{ + camera_(); + virtual ~camera_(); + + virtual std::vector<QString> camera_names() const = 0; + virtual std::unique_ptr<camera> make_camera(const QString& name) = 0; + virtual bool show_dialog(const QString& camera_name) = 0; + virtual bool can_show_dialog(const QString& camera_name) = 0; +}; + +struct OTR_VIDEO_EXPORT camera +{ + struct info final + { + // TODO: expose FOV-based focal length for regular webcams + int width = 0, height = 0, fps = 0; + double fx = 0, fy = 0; // focal length + double P_x = 0, P_y = 0; // principal point + double dist_c[8] {}; // distortion coefficients + }; + + camera(); + virtual ~camera(); + + [[nodiscard]] virtual bool start(info& args) = 0; + virtual void stop() = 0; + virtual bool is_open() = 0; + + virtual std::tuple<const frame&, bool> get_frame() = 0; + [[nodiscard]] virtual bool show_dialog() = 0; +}; + +} // ns video + +#endif + +namespace video::impl { +struct ps3eye_camera_ : camera_ +{ + std::vector<QString> camera_names() const override; + std::unique_ptr<camera> make_camera(const QString& name) override; + bool show_dialog(const QString& camera_name) override; + bool can_show_dialog(const QString& camera_name) override; +}; +} // ns video::impl diff --git a/video-ps3eye/ps3eye-driver b/video-ps3eye/ps3eye-driver -Subproject 730d0dbc0b87c3c4a9a6b196d277ee143b37681 +Subproject 7a2dcb0ff586bd0865d35d964b75c4d0a29b4e9 diff --git a/video-ps3eye/shm-layout.hpp b/video-ps3eye/shm-layout.hpp new file mode 100644 index 00000000..7fa29115 --- /dev/null +++ b/video-ps3eye/shm-layout.hpp @@ -0,0 +1,40 @@ +#pragma once +#include <cstdint> + +namespace ps3eye { + +struct shm_out { + enum class mode : uint8_t { qvga, vga, }; + enum class status : uint8_t { starting, running, fail, terminate, }; + + uint8_t settings_updated; + uint16_t framerate; + mode resolution; + status status_; + uint8_t sharpness, contrast, brightness, hue, saturation; + uint8_t gain, exposure, auto_gain, awb, test_pattern; +}; + +struct shm_in { + uint8_t settings_updated_ack; + uint8_t timecode; + union { + uint8_t data_320x240[320][240][3]; + uint8_t data_640x480[640][480][3]; + }; +}; + +struct shm { + static constexpr unsigned _cacheline_len = 64; + static constexpr unsigned _padding_len = + (_cacheline_len - (sizeof(shm_in) & (_cacheline_len - 1))) & (_cacheline_len - 1); + + using resolution = shm_out::mode; + using status = shm_out::status; + + shm_out out; + const char* _padding[_padding_len]; + shm_in in; +}; + +} // ns ps3eye diff --git a/video-ps3eye/wrapper.cxx b/video-ps3eye/wrapper.cxx new file mode 100644 index 00000000..add62992 --- /dev/null +++ b/video-ps3eye/wrapper.cxx @@ -0,0 +1,7 @@ +#include "shm-layout.hpp" + +int main(int argc, char** argv) +{ + (void)argc; (void)argv; + return 0; +} |