Newer
Older
#ifndef _FTL_GUI_CAMERA_HPP_
#define _FTL_GUI_CAMERA_HPP_
#include <ftl/streams/filestream.hpp>
#include <ftl/streams/sender.hpp>
#ifdef HAVE_OPENVR
#include <openvr/openvr.h>
#endif
class StatisticsImage;
namespace ftl {
namespace gui {
class Screen;
class PoseWindow;
class Camera {
public:
Camera(ftl::gui::Screen *screen, int fsmask, int fid, ftl::codecs::Channel chan=ftl::codecs::Channel::Colour);
int width() const { return width_; }
int height() const { return height_; }
int getFramesetMask() const { return fsmask_; }
bool usesFrameset(int id) const { return fsmask_ & (1 << id); }
void setPose(const Eigen::Matrix4d &p);
void mouseMovement(int rx, int ry, int button);
void keyMovement(int key, int modifiers);
void showPoseWindow();
void showSettings();
void setChannel(ftl::codecs::Channel c);
const ftl::codecs::Channel getChannel() { return channel_; }
inline bool isVirtual() const { return fid_ == 255; }
const ftl::codecs::Channels<0> &availableChannels() { return channels_; }
inline bool isStereo() const { return stereo_; }
void setStereo(bool v);
/**
* Main function to obtain latest frames.
*/
void update(std::vector<ftl::rgbd::FrameSet *> &fss);
/**
* Update the available channels.
*/
void update(int fsid, const ftl::codecs::Channels<0> &c);
void draw(std::vector<ftl::rgbd::FrameSet*> &fss);
/**
* @internal. Used to inform the camera if it is the active camera or not.
*/
void active(bool);
const GLTexture &getLeft() const { return texture1_; }
const GLTexture &getRight() const { return texture2_; }
void startVideoRecording(const std::string &filename);
void stopVideoRecording();
//nlohmann::json getMetaData();
const std::string &name() const { return name_; }
StatisticsImage *stats_ = nullptr;
#ifdef HAVE_OPENVR
bool isVR() { return vr_mode_; }
bool setVR(bool on);
#else
bool isVR() { return false; }
#endif
int fid_;
int width_;
int height_;
GLTexture texture1_; // first channel (always left at the moment)
GLTexture texture2_; // second channel ("right")
Eigen::Vector4d neye_;
Eigen::Vector3d eye_;
//Eigen::Vector3f orientation_;
Eigen::Matrix4d rotmat_;
float ftime_;
float delta_;
float lerpSpeed_;
ftl::codecs::Channel channel_;
cv::Mat im1_; // first channel (left)
cv::Mat im2_; // second channel ("right")
std::atomic_flag new_frame_;
int rx_;
int ry_;
std::vector<ftl::rgbd::FrameSet*> *framesets_;
ftl::render::CUDARender *renderer2_;
ftl::render::Colouriser *colouriser_;
ftl::rgbd::Frame frame_;
ftl::rgbd::FrameState state_;
ftl::stream::File *record_stream_;
ftl::stream::Sender *record_sender_;
std::string name_;
int transform_ix_;
std::array<Eigen::Matrix4d,ftl::stream::kMaxStreams> transforms_; // Frameset transforms for virtual cam
#ifdef HAVE_OPENVR
vr::TrackedDevicePose_t rTrackedDevicePose_[ vr::k_unMaxTrackedDeviceCount ];
void _downloadFrames(ftl::cuda::TextureObject<uchar4> &, ftl::cuda::TextureObject<uchar4> &);
void _downloadFrame(ftl::cuda::TextureObject<uchar4> &);
void _draw(std::vector<ftl::rgbd::FrameSet*> &fss);
};
}
}
#endif // _FTL_GUI_CAMERA_HPP_