diff options
| -rw-r--r-- | video-ps3eye/module.cpp | 3 | ||||
| -rw-r--r-- | video-ps3eye/shm-layout.hpp | 2 | ||||
| -rw-r--r-- | video-ps3eye/wrapper.cxx | 5 | ||||
| -rw-r--r-- | video/camera.hpp | 2 | 
4 files changed, 7 insertions, 5 deletions
| diff --git a/video-ps3eye/module.cpp b/video-ps3eye/module.cpp index 25d82170..4279d68d 100644 --- a/video-ps3eye/module.cpp +++ b/video-ps3eye/module.cpp @@ -157,7 +157,7 @@ bool ps3eye_camera::start(info& args)      open = false;      fr = {}; -    fr.channels = 1; +    fr.channels = args.num_channels == 1 ? 1 : 3;      fr.channel_size = 1;      if (!args.width || args.width > 320) @@ -175,6 +175,7 @@ bool ps3eye_camera::start(info& args)      ptr.in.framerate = (uint8_t)std::clamp(args.fps, 30, 187);      ptr.in.gain = (uint8_t)s.gain;      ptr.in.exposure = (uint8_t)s.exposure; +    ptr.in.channels = args.num_channels == 1 ? 1 : 3;      sleep_ms = std::clamp(int(std::floor(450./ptr.in.framerate)), 1, 10); diff --git a/video-ps3eye/shm-layout.hpp b/video-ps3eye/shm-layout.hpp index d7905109..8c770d43 100644 --- a/video-ps3eye/shm-layout.hpp +++ b/video-ps3eye/shm-layout.hpp @@ -9,7 +9,7 @@ struct shm_in {      enum class mode : uint8_t { qvga, vga, };      uint32_t settings_updated; -    uint8_t framerate; +    uint8_t framerate, channels;      mode resolution;      //uint8_t sharpness, contrast, brightness hue, saturation;      uint8_t gain, exposure, auto_gain, test_pattern; diff --git a/video-ps3eye/wrapper.cxx b/video-ps3eye/wrapper.cxx index 0f9344eb..b7f58185 100644 --- a/video-ps3eye/wrapper.cxx +++ b/video-ps3eye/wrapper.cxx @@ -52,6 +52,7 @@ int main(int argc, char** argv)      volatile auto& ptr_ = *(ps3eye::shm*)mem_.ptr();      volatile auto& in = ptr_.in;      volatile auto& out = ptr_.out; +    int num_channels = in.channels;      auto cameras = ps3eye::list_devices(); @@ -65,9 +66,7 @@ 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; +    auto fmt = num_channels == 1 ? ps3eye::format::Gray : ps3eye::format::BGR;      {          int framerate = in.framerate; diff --git a/video/camera.hpp b/video/camera.hpp index c3297876..8d96ff6b 100644 --- a/video/camera.hpp +++ b/video/camera.hpp @@ -48,12 +48,14 @@ struct OTR_VIDEO_EXPORT camera  {      struct info final      { +        enum : unsigned char { channels_gray = 1, channels_bgr = 3 };          // 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          bool use_mjpeg = false; +        int num_channels = channels_bgr;      };      camera(); | 
