Simulated Reality SDK 7500c78d v1.30.2.51085 2024-04-26T11:23:03Z
Stable
camera.h
Go to the documentation of this file.
1
10#pragma once
11
12#include "sr/sense/core/sense.h"
13
14#include "videostream.h"
15#include "cameradescriptor.h"
18
19#ifdef WIN32
20# ifdef COMPILING_DLL_SimulatedRealityCameras
21# define DIMENCOSR_API __declspec(dllexport)
22# else
23# define DIMENCOSR_API __declspec(dllimport)
24# endif
25#else
26# define DIMENCOSR_API
27#endif
28
29namespace SR {
30
39typedef std::vector<SR_cameraDescriptor>(CameraListFunction)();
40
45
53DIMENCOSR_API std::vector<CameraListFunction*>& cameraListImplementationFunctions();
54
62DIMENCOSR_API std::map<std::string, CameraCreateImplementationFunction*>& cameraCreateImplementationFunctions();
63
71class DIMENCOSR_API Camera : public Sense {
72
73public:
78 public:
80
86 Descriptor(SR_cameraDescriptor info) : info{ info.serialNumber, info.cameraTypeLength, info.cameraType } {
87 }
88
93 return info;
94 }
95
99 operator std::string() {
100 return std::string(info.cameraType, info.cameraTypeLength) + std::to_string(info.serialNumber);
101 }
102 };
103
111 static void addImplementation(CameraListFunction* listFunction, CameraCreateImplementationFunction* createFunction, std::string cameraType);
112
118 static std::vector<SR_cameraDescriptor> listDescriptors();
119
127 static Camera* create(SRContext &context, Camera::Descriptor cameraDescriptor);
128
135 static Camera* create(SRContext &context);
136
137 //Destruct streams
138 virtual ~Camera();
139
146
155 virtual const unsigned int getStreamCount() = 0;
156
163 virtual std::shared_ptr<VideoStream> openVideoStream(VideoListener* listener) = 0;
164
170 virtual void streamClosed(VideoStream* stream) = 0;
171};
172
173}
174
175#undef DIMENCOSR_API
#define DIMENCOSR_API
Definition: camera.h:26
Class describing a physical camera.
Definition: camera.h:77
SR_cameraDescriptor info
Definition: camera.h:79
Descriptor(SR_cameraDescriptor info)
Construct a Camera::Descriptor with a struct combining a camera type and serial number.
Definition: camera.h:86
Class of Sense dealing with video data.
Definition: camera.h:71
virtual std::shared_ptr< VideoStream > openVideoStream(VideoListener *listener)=0
Creates a VideoStream for listener to be connected to.
static Camera * create(SRContext &context)
Create a camera.
static std::vector< SR_cameraDescriptor > listDescriptors()
List camera identifiers.
static Camera * create(SRContext &context, Camera::Descriptor cameraDescriptor)
Create a camera with a given identifier.
virtual ~Camera()
virtual const unsigned int getStreamCount()=0
Get the number of available streams.
static void addImplementation(CameraListFunction *listFunction, CameraCreateImplementationFunction *createFunction, std::string cameraType)
Static function to make a Camera implementation available through the Camera::listDescriptors and Cam...
virtual void streamClosed(VideoStream *stream)=0
Closes a specific VideoStream.
virtual Camera::Descriptor getDescriptor()=0
Get descriptor to identify physical Camera.
Maintains WorldObject and Sense objects during the application lifetime.
Definition: srcontext.h:80
Class of objects dealing with Streams of data.
Definition: sense.h:42
Interface for listening to SR_videoFrame updates.
Definition: videolistener.h:31
Stream of SR_videoFrame objects.
Definition: videostream.h:36
Namespace containing all C++ Simulated Reality classes.
Definition: srconfiguration.h:25
Camera *() CameraCreateImplementationFunction(SRContext &, SR_cameraDescriptor)
Definition: camera.h:44
DIMENCOSR_API std::vector< CameraListFunction * > & cameraListImplementationFunctions()
Vector of functions to list camera descriptors of a specific type.
DIMENCOSR_API std::map< std::string, CameraCreateImplementationFunction * > & cameraCreateImplementationFunctions()
Map of camera type to functions to create cameras of that type.
C-compatible descriptor of SR camera component.
Definition: cameradescriptor.h:15
uint64_t serialNumber
Definition: cameradescriptor.h:17
uint64_t cameraTypeLength
Definition: cameradescriptor.h:20
const char * cameraType
Definition: cameradescriptor.h:21