diff options
author | Stanislaw Halik <sthalik@misaki.pl> | 2021-08-18 19:44:29 +0200 |
---|---|---|
committer | Stanislaw Halik <sthalik@misaki.pl> | 2021-08-18 19:47:13 +0200 |
commit | 2fc5d7b3490e41952e0e335841d7d7f72a3b76a9 (patch) | |
tree | 0b3da3015ee518849b85303c28fb53e54a1137c5 | |
parent | e8f5b7ec366f1cf7660e870335b4e503e4527990 (diff) |
video/ps3eye: move number of channels to a constant
-rw-r--r-- | video-ps3eye/module.hpp | 2 | ||||
-rw-r--r-- | video-ps3eye/shm-layout.hpp | 6 | ||||
-rw-r--r-- | video-ps3eye/wrapper.cxx | 8 |
3 files changed, 11 insertions, 5 deletions
diff --git a/video-ps3eye/module.hpp b/video-ps3eye/module.hpp index 595d446a..26cfad60 100644 --- a/video-ps3eye/module.hpp +++ b/video-ps3eye/module.hpp @@ -57,7 +57,7 @@ struct ps3eye_camera final : video::impl::camera settings s; frame fr; Timer t; - unsigned char data[640 * 480 * 3] = {}; + unsigned char data[640 * 480 * ps3eye::num_channels] = {}; int framerate = 30, sleep_ms = 1; bool open = false; unsigned timecode = 0; diff --git a/video-ps3eye/shm-layout.hpp b/video-ps3eye/shm-layout.hpp index 3ae406c5..d7905109 100644 --- a/video-ps3eye/shm-layout.hpp +++ b/video-ps3eye/shm-layout.hpp @@ -3,6 +3,8 @@ namespace ps3eye { +static constexpr unsigned num_channels = 1; + struct shm_in { enum class mode : uint8_t { qvga, vga, }; @@ -23,8 +25,8 @@ struct shm_out status status_; char error_string[256]; union { - uint8_t data_320x240[320][240][1]; - uint8_t data_640x480[640][480][1]; + uint8_t data_320x240[320][240][num_channels]; + uint8_t data_640x480[640][480][num_channels]; }; }; diff --git a/video-ps3eye/wrapper.cxx b/video-ps3eye/wrapper.cxx index 2ebdc2e1..0f9344eb 100644 --- a/video-ps3eye/wrapper.cxx +++ b/video-ps3eye/wrapper.cxx @@ -65,12 +65,16 @@ int main(int argc, char** argv) auto* frame = (uint8_t*)out.data_640x480; decltype(out.timecode) timecode = 0; + constexpr auto fmt = ps3eye::num_channels == 1 + ? ps3eye::format::Gray + : ps3eye::format::BGR; + { int framerate = in.framerate; if (framerate <= 0) framerate = 60; - if (!camera->init(get_mode(in.resolution), framerate, ps3eye::format::Gray)) + if (!camera->init(get_mode(in.resolution), framerate, fmt)) error(out, "camera init failed: %s", camera->error_string()); update_settings(*camera, in); @@ -94,7 +98,7 @@ int main(int argc, char** argv) int framerate = in.framerate; if (framerate <= 0) framerate = 60; - if (!camera->init(get_mode(in.resolution), framerate, ps3eye::format::Gray)) + if (!camera->init(get_mode(in.resolution), framerate, fmt)) error(out, "camera init failed: %s", camera->error_string()); if (!camera->start()) error(out, "can't start camera: %s", camera->error_string()); |