SLProject  4.3.020
A platform independent 3D computer graphics framework for desktop OS, Android, iOS and online in web browsers
SENSRecorder.h
Go to the documentation of this file.
1 #ifndef SENS_RECORDER_H
2 #define SENS_RECORDER_H
3 
4 #include <string>
5 #include <atomic>
6 
8 
9 //-----------------------------------------------------------------------------
10 /*! SENSRecorder
11  This class records implemented sensor classes to file. The output directory has to be transfered during instantiation.
12  Activate or deactivate a sensor by calling activate or deactivate methods. The functions return true on success, a
13  change is only possible if the recorder is not running (use isRunning method).
14  Call start() and stop() to start or stop recording of sensors.
15  The SENSRecorder listens to sensors and informs SENSRecorderDataHandler backends about new data.
16  The SENSRecorderDataHandler stores values to file.
17  */
20  , public SENSCameraListener
21 {
22 public:
23  SENSRecorder(const std::string& outputDir);
24  ~SENSRecorder();
25 
26  bool activateGps(SENSGps* sensor);
27  bool deactivateGps();
29  bool deactivateOrientation();
30  bool activateCamera(SENSCamera* sensor);
31  bool deactivateCamera();
32 
33  //!Start the recording of activated sensors (Registers listeners and starts SENSRecorderDataHandler backends).
34  //!Returns true on success. Possible reasons for fail are: Output directory does not exist or recorder is already running.
35  bool start();
36  //!Stops a running recording session.
37  void stop();
38 
39  bool getGpsHandlerError(std::string& errorMsg);
40  bool getOrientationHandlerError(std::string& errorMsg);
41  bool getCameraHandlerError(std::string& errorMsg);
42 
43  bool isRunning() const { return _running; }
44  const std::string& outputDir() const { return _outputDir; }
45 
46 private:
47  //!gps listener callback
48  void onGps(const SENSTimePt& timePt, const SENSGps::Location& loc) override;
49  //!orientation listener callback
50  void onOrientation(const SENSTimePt& timePt, const SENSOrientation::Quat& ori) override;
51  //!camera listener callback
52  void onFrame(const SENSTimePt& timePt, cv::Mat frame) override;
53  void onCameraConfigChanged(const SENSCameraConfig& config) override;
54 
55  std::string _outputDir;
56 
60 
61  SENSGps* _gps = nullptr;
63  SENSCamera* _camera = nullptr;
64 
65  std::atomic_bool _running{false};
66 };
67 
68 #endif
std::chrono::high_resolution_clock::time_point SENSTimePt
Definition: SENS.h:57
Pure abstract camera class.
Definition: SENSCamera.h:160
void onGps(const SENSTimePt &timePt, const SENSGps::Location &loc) override
gps listener callback
std::atomic_bool _running
Definition: SENSRecorder.h:65
bool activateGps(SENSGps *sensor)
bool getGpsHandlerError(std::string &errorMsg)
bool getOrientationHandlerError(std::string &errorMsg)
SENSOrientationRecorderDataHandler * _orientationDataHandler
Definition: SENSRecorder.h:58
bool activateCamera(SENSCamera *sensor)
void onCameraConfigChanged(const SENSCameraConfig &config) override
void onFrame(const SENSTimePt &timePt, cv::Mat frame) override
camera listener callback
bool activateOrientation(SENSOrientation *sensor)
SENSGps * _gps
Definition: SENSRecorder.h:61
const std::string & outputDir() const
Definition: SENSRecorder.h:44
bool isRunning() const
Definition: SENSRecorder.h:43
void onOrientation(const SENSTimePt &timePt, const SENSOrientation::Quat &ori) override
orientation listener callback
SENSRecorder(const std::string &outputDir)
Definition: SENSRecorder.cpp:4
std::string _outputDir
Definition: SENSRecorder.h:55
SENSCameraRecorderDataHandler * _cameraDataHandler
Definition: SENSRecorder.h:59
bool getCameraHandlerError(std::string &errorMsg)
bool deactivateOrientation()
bool deactivateCamera()
SENSCamera * _camera
Definition: SENSRecorder.h:63
SENSGpsRecorderDataHandler * _gpsDataHandler
Definition: SENSRecorder.h:57
void stop()
Stops a running recording session.
bool deactivateGps()
SENSOrientation * _orientation
Definition: SENSRecorder.h:62
Config config
The configuration set in App::run.
Definition: AppAndroid.cpp:34
void errorMsg(const char *tag, const char *msg, const int line, const char *file)
Platform independent error message output.
Definition: Utils.cpp:1165