diff --git a/components/rgbd-sources/include/ftl/rgbd/camera.hpp b/components/rgbd-sources/include/ftl/rgbd/camera.hpp index edcff30bddc1f1dd5b08fc9e564d18c6c3b393cf..804a0c2d3ea769e28a89d1663de64ba7a1390d57 100644 --- a/components/rgbd-sources/include/ftl/rgbd/camera.hpp +++ b/components/rgbd-sources/include/ftl/rgbd/camera.hpp @@ -20,6 +20,14 @@ enum class Projection { EQUIRECTANGULAR = 2 }; +typedef unsigned int capability_t; + +static const capability_t kCapMovable = 0x0001; // A movable virtual cam +static const capability_t kCapVideo = 0x0002; // Is a video feed +static const capability_t kCapActive = 0x0004; // An active depth sensor +static const capability_t kCapStereo = 0x0008; // Has right RGB +static const capability_t kCapDepth = 0x0010; // Has depth capabilities + /** * All properties associated with cameras. This structure is designed to * operate on CPU and GPU. diff --git a/components/rgbd-sources/include/ftl/rgbd/source.hpp b/components/rgbd-sources/include/ftl/rgbd/source.hpp index b0bec3cf1e465933a66bc98c66272859ae8cac94..868e1a9a0447bf8e36ed069fa7b7f2bed301e371 100644 --- a/components/rgbd-sources/include/ftl/rgbd/source.hpp +++ b/components/rgbd-sources/include/ftl/rgbd/source.hpp @@ -7,8 +7,6 @@ #include <ftl/net/universe.hpp> #include <ftl/uri.hpp> #include <ftl/rgbd/camera.hpp> -#include <ftl/rgbd/detail/source.hpp> -#include <ftl/codecs/packet.hpp> #include <opencv2/core/mat.hpp> #include <Eigen/Eigen> #include <string> @@ -25,6 +23,9 @@ class Universe; namespace rgbd { +class BaseSourceImpl; +typedef std::function<void(int64_t,ftl::rgbd::Frame&)> FrameCallback; + static inline bool isValidDepth(float d) { return (d > 0.01f) && (d < 39.99f); } /** @@ -58,7 +59,7 @@ class Source : public ftl::Configurable { /** * Is this source valid and ready to grab?. */ - bool isReady() { return (impl_) ? impl_->isReady() : false; } + bool isReady(); /** * Change the second channel source. @@ -105,10 +106,7 @@ class Source : public ftl::Configurable { /** * Get the source's camera intrinsics. */ - const Camera ¶meters() const { - if (impl_) return impl_->params_; - else throw FTL_Error("Cannot get parameters for bad source"); - } + const Camera ¶meters() const; /** * Get camera intrinsics for another channel. For example the right camera @@ -141,7 +139,7 @@ class Source : public ftl::Configurable { std::string getURI() { return value("uri", std::string("")); } - ftl::rgbd::FrameState &state() { return impl_->state_; } + ftl::rgbd::FrameState &state(); SHARED_MUTEX &mutex() { return mutex_; } diff --git a/components/rgbd-sources/include/ftl/rgbd/detail/source.hpp b/components/rgbd-sources/src/basesource.hpp similarity index 73% rename from components/rgbd-sources/include/ftl/rgbd/detail/source.hpp rename to components/rgbd-sources/src/basesource.hpp index dc910068bc0c14b9153335cb7b6562a68baa7f2e..80cda5be64910e52e00c3a67c878bd2a278c190a 100644 --- a/components/rgbd-sources/include/ftl/rgbd/detail/source.hpp +++ b/components/rgbd-sources/src/basesource.hpp @@ -11,15 +11,6 @@ namespace ftl{ namespace rgbd { class Source; -typedef std::function<void(int64_t,ftl::rgbd::Frame&)> FrameCallback; - -typedef unsigned int capability_t; - -static const capability_t kCapMovable = 0x0001; // A movable virtual cam -static const capability_t kCapVideo = 0x0002; // Is a video feed -static const capability_t kCapActive = 0x0004; // An active depth sensor -static const capability_t kCapStereo = 0x0008; // Has right RGB -static const capability_t kCapDepth = 0x0010; // Has depth capabilities class BaseSourceImpl { public: diff --git a/components/rgbd-sources/src/source.cpp b/components/rgbd-sources/src/source.cpp index 77efb6b5df78fd52ed756de6c9e4240046c2922a..ed3b856c6d26967126119c2dfc7ed40c0d64a7a8 100644 --- a/components/rgbd-sources/src/source.cpp +++ b/components/rgbd-sources/src/source.cpp @@ -1,5 +1,6 @@ #include <loguru.hpp> #include <ftl/rgbd/source.hpp> +#include "basesource.hpp" #include <ftl/threads.hpp> //#include "sources/net/net.hpp" @@ -74,6 +75,15 @@ Source::~Source() { if (impl_) delete impl_; } +bool Source::isReady() { return (impl_) ? impl_->isReady() : false; } + +const Camera &Source::parameters() const { + if (impl_) return impl_->params_; + else throw FTL_Error("Cannot get parameters for bad source"); +} + +ftl::rgbd::FrameState &Source::state() { return impl_->state_; } + cv::Mat Source::cameraMatrix() const { cv::Mat m = (cv::Mat_<float>(3,3) << parameters().fx, 0.0, -parameters().cx, 0.0, parameters().fy, -parameters().cy, 0.0, 0.0, 1.0); return m; diff --git a/components/rgbd-sources/src/sources/image/image.hpp b/components/rgbd-sources/src/sources/image/image.hpp index 18212ce87b3905035fd02e0f609561b09c6b56e0..9bf4f4f69d070b59d204e772fed2a8f3c691f903 100644 --- a/components/rgbd-sources/src/sources/image/image.hpp +++ b/components/rgbd-sources/src/sources/image/image.hpp @@ -1,6 +1,8 @@ #ifndef _FTL_RGBD_IMAGE_HPP_ #define _FTL_RGBD_IMAGE_HPP_ +#include "../../basesource.hpp" + namespace ftl { namespace rgbd { namespace detail { diff --git a/components/rgbd-sources/src/sources/middlebury/middlebury_source.hpp b/components/rgbd-sources/src/sources/middlebury/middlebury_source.hpp index f89bfd6655fb719eb8125aa7f8d13568abb89736..d102dbeba672833e5aa6a1787648ba70b9aad7db 100644 --- a/components/rgbd-sources/src/sources/middlebury/middlebury_source.hpp +++ b/components/rgbd-sources/src/sources/middlebury/middlebury_source.hpp @@ -4,7 +4,7 @@ #include <loguru.hpp> -#include <ftl/rgbd/source.hpp> +#include "../../basesource.hpp" #include <ftl/cuda_common.hpp> namespace ftl { diff --git a/components/rgbd-sources/src/sources/pylon/pylon.hpp b/components/rgbd-sources/src/sources/pylon/pylon.hpp index fe6be490ce5a16010ae87933058ea5ddd0bac16b..df80e70a700c7651f2a786bd471c0371021cfa3b 100644 --- a/components/rgbd-sources/src/sources/pylon/pylon.hpp +++ b/components/rgbd-sources/src/sources/pylon/pylon.hpp @@ -2,7 +2,7 @@ #ifndef _FTL_RGBD_PYLON_HPP_ #define _FTL_RGBD_PYLON_HPP_ -#include <ftl/rgbd/detail/source.hpp> +#include "../../basesource.hpp" #include <string> namespace Pylon { diff --git a/components/rgbd-sources/src/sources/realsense/realsense_source.hpp b/components/rgbd-sources/src/sources/realsense/realsense_source.hpp index a0b730e8e58382522ab1a43df13ec3e04ede1e26..83274aecc1e559c59db3034ef70bd1def7aebdeb 100644 --- a/components/rgbd-sources/src/sources/realsense/realsense_source.hpp +++ b/components/rgbd-sources/src/sources/realsense/realsense_source.hpp @@ -2,7 +2,7 @@ #ifndef _FTL_RGBD_REALSENSE_HPP_ #define _FTL_RGBD_REALSENSE_HPP_ -#include <ftl/rgbd/detail/source.hpp> +#include "../../basesource.hpp" #include <librealsense2/rs.hpp> #include <string> diff --git a/components/rgbd-sources/src/sources/screencapture/screencapture.hpp b/components/rgbd-sources/src/sources/screencapture/screencapture.hpp index d753ada43ea0a9d76e085e98886c3ad78f514e24..163ab106c9c5fa19cf6b8e0a1f4d3752e7da74d0 100644 --- a/components/rgbd-sources/src/sources/screencapture/screencapture.hpp +++ b/components/rgbd-sources/src/sources/screencapture/screencapture.hpp @@ -1,7 +1,7 @@ #ifndef _FTL_RGBD_SCREENCAPTURE_HPP_ #define _FTL_RGBD_SCREENCAPTURE_HPP_ -#include <ftl/rgbd/detail/source.hpp> +#include "../../basesource.hpp" #include <ftl/config.h> namespace ftl { diff --git a/components/rgbd-sources/src/sources/stereovideo/stereovideo.hpp b/components/rgbd-sources/src/sources/stereovideo/stereovideo.hpp index 54f2d5e12ed6ba62d77af88430328a3a46e57d59..2b6fc3a83ffa1da52b3e62be6e7ba8c0cee0c255 100644 --- a/components/rgbd-sources/src/sources/stereovideo/stereovideo.hpp +++ b/components/rgbd-sources/src/sources/stereovideo/stereovideo.hpp @@ -2,7 +2,7 @@ #ifndef _FTL_RGBD_STEREOVIDEO_HPP_ #define _FTL_RGBD_STEREOVIDEO_HPP_ -#include <ftl/rgbd/source.hpp> +#include "../../basesource.hpp" #include <ftl/operators/operator.hpp> #include <string> diff --git a/components/rgbd-sources/test/source_unit.cpp b/components/rgbd-sources/test/source_unit.cpp index 365088c42318ac16f6cd9ffb0a83688b9eb38d78..bf45f5623b868d61fb7603008d79f4abcb99bce4 100644 --- a/components/rgbd-sources/test/source_unit.cpp +++ b/components/rgbd-sources/test/source_unit.cpp @@ -3,6 +3,7 @@ //---- Mocks ------------------------------------------------------------------- #include <ftl/rgbd/source.hpp> +#include "../src/basesource.hpp" #include <ftl/config.h> #include <nlohmann/json.hpp>