8 vr_camera::vr_camera() : num_cameras(0u), state(CS_UNINITIALIZED), frame_format(CFF_RGBA), frame_split(CFS_NONE), frame_flipped(false)
8 vr_camera::vr_camera() : num_cameras(0u), state(CS_UNINITIALIZED), frame_format(CFF_RGBA), frame_split(CFS_NONE), frame_flipped(false) {
…}
20 if (state != CS_UNINITIALIZED) {
21 last_error =
"attempt to initialize already initialized vr camera";
24 if (!initialize_impl())
26 state = CS_INITIALIZED;
32 if (state == CS_UNINITIALIZED) {
33 last_error =
"attempt to start not initialized vr camera, please initialize first";
36 if (state == CS_STARTED) {
37 last_error =
"attempt to start already started vr camera";
48 if (state != CS_STARTED) {
49 last_error =
"attempt to stop camera that was not started, please start camera first";
54 state = CS_INITIALIZED;
60 bool vr_camera::get_frame(std::vector<uint8_t>& frame_data, uint32_t& width, uint32_t& height,
bool undistorted,
bool maximum_valid_rectangle)
62 if (state != CS_STARTED) {
63 last_error =
"attempt to get frame from vr camera that was not started, please start camera first";
66 if (!get_frame_impl(frame_data, width, height, undistorted, maximum_valid_rectangle))
60 bool vr_camera::get_frame(std::vector<uint8_t>& frame_data, uint32_t& width, uint32_t& height,
bool undistorted,
bool maximum_valid_rectangle) {
…}
74 if (state != CS_STARTED) {
75 last_error =
"attempt to get gl texture id from vr camera that was not started, please start camera first";
78 if (!get_gl_texture_id_impl(tex_id, width, height, undistorted, max_valid_texcoord_range))
106 return frame_flipped;
bool start()
start streaming of frames
const std::string & get_last_error() const
return last error, if no error has occured, the function returns an empty string
CameraFrameFormat get_frame_format() const
query pixel format
CameraState get_state() const
return the camera state
bool is_frame_flipped() const
query whether frame row order is from top to bottom
vr_camera()
construct camera object
bool stop()
stop streaming of frames
bool initialize()
initialization is typically called the c
std::string last_error
store last error as a string to be as flexible as possible
bool get_gl_texture_id(uint32_t &tex_id, uint32_t &width, uint32_t &height, bool undistorted, float max_valid_texcoord_range[4])
query id of shared opengl texture id
CameraFrameSplit get_frame_split() const
query stereo frame layout
uint8_t get_nr_cameras() const
return number of cameras in the headset (1 for mono and 2 for stereo)
bool get_frame(std::vector< uint8_t > &frame_data, uint32_t &width, uint32_t &height, bool undistorted, bool maximum_valid_rectangle)
check for a new frame, return false if not available. Otherwise copy frame to provided buffer that is...
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...
CameraState
different status values for a vr camera
CameraFrameFormat
currently only a single frame format supported
defines camera class for camera provided by vr_kit