cgv
Loading...
Searching...
No Matches
vr_camera.h
Go to the documentation of this file.
1#pragma once
2
3#include <cstdint>
4#include <string>
5#include <vector>
6
7#include "lib_begin.h"
8
11
16namespace vr {
17
20 CS_UNINITIALIZED,
21 CS_INITIALIZED,
22 CS_STARTED
23};
24
27 CFF_RGBA = 0
28};
29
32 CFS_NONE = 0, // no split indicates mono camera
33 CFS_VERTICAL, // left right split
34 CFS_HORIZONTAL // top bottom split
35};
36
38class CGV_API vr_camera
39{
40protected:
42 friend class vr_kit;
44 vr_camera();
46 friend class vr_driver;
48 bool initialize();
50 virtual ~vr_camera() = default;
52 mutable std::string last_error;
53public:
57 uint8_t get_nr_cameras() const;
59 virtual bool put_camera_to_head_matrix(int camera_index, float* pose_matrix) const = 0;
61 virtual bool put_projection_matrix(int camera_index, bool undistorted, float z_near, float z_far, float* projection_matrix) const = 0;
63 virtual bool put_camera_intrinsics(int camera_index, bool undistorted, float* focal_length_2d_ptr, float* center_2d_ptr) const = 0;
65 bool start();
67 bool stop();
69 CameraState get_state() const;
71 bool has_error() const { return !last_error.empty(); }
73 const std::string& get_last_error() const;
75
79 CameraFrameFormat get_frame_format() const;
81 CameraFrameSplit get_frame_split() const;
83 bool is_frame_flipped() const;
85 bool get_frame(std::vector<uint8_t>& frame_data, uint32_t& width, uint32_t& height, bool undistorted, bool maximum_valid_rectangle);
87 bool get_gl_texture_id(uint32_t& tex_id, uint32_t& width, uint32_t& height, bool undistorted, float max_valid_texcoord_range[4]);
89protected:
90 uint8_t num_cameras;
91 CameraFrameFormat frame_format;
92 CameraFrameSplit frame_split;
93 bool frame_flipped;
94 CameraState state;
95private:
96 virtual bool initialize_impl() = 0;
97 virtual bool start_impl() = 0;
98 virtual bool stop_impl() = 0;
99 virtual bool get_frame_impl(std::vector<uint8_t>& frame_data, uint32_t& width, uint32_t& height, bool undistorted, bool maximum_valid_rectangle) = 0;
100 virtual bool get_gl_texture_id_impl(uint32_t& tex_id, uint32_t& width, uint32_t& height, bool undistorted, float max_valid_texcoord_range[4]) = 0;
101};
102
103} // namespace vr
105
106#include <cgv/config/lib_end.h>
interface for mono or stereo cameras in VR headsets
Definition vr_camera.h:39
virtual bool put_projection_matrix(int camera_index, bool undistorted, float z_near, float z_far, float *projection_matrix) const =0
access to 4x4 matrix in column major format for perspective transformation of camera (0....
virtual bool put_camera_intrinsics(int camera_index, bool undistorted, float *focal_length_2d_ptr, float *center_2d_ptr) const =0
write the focal lengths in x- and y-direction to access to focal_length_2d_ptr[0|1] and the texture c...
virtual ~vr_camera()=default
destruct camera
bool has_error() const
check for error
Definition vr_camera.h:71
std::string last_error
store last error as a string to be as flexible as possible
Definition vr_camera.h:52
virtual bool put_camera_to_head_matrix(int camera_index, float *pose_matrix) const =0
access to 3x4 matrix in column major format for transformation from camera (0 .. left,...
interface class for vr drivers.
Definition vr_driver.h:57
a vr kit is composed of headset, two controllers, and two trackers, where all devices can be attached...
Definition vr_kit.h:69
the vr namespace for virtual reality support
CameraFrameSplit
in case of stereo cameras a frame contains images of both eyes either split vertically (left right) o...
Definition vr_camera.h:31
CameraState
different status values for a vr camera
Definition vr_camera.h:19
CameraFrameFormat
currently only a single frame format supported
Definition vr_camera.h:26