#include <SENSSimulated.h>
|
| using | StartSimCB = std::function< void(void)> |
| |
| using | SensorSimStoppedCB = std::function< void(void)> |
| |
| void | updateFrame (cv::Mat bgrImg, cv::Mat intrinsics, int width, int height, bool intrinsicsChanged) |
| |
| void | processStart () |
| | call from start function to do startup preprocessing More...
|
| |
| | SENSSimulated (const std::string name, StartSimCB startSimCB, SensorSimStoppedCB sensorSimStoppedCB, std::vector< std::pair< SENSTimePt, int >> &&data, const SENSSimClock &clock) |
| |
| void | startSim () |
| | start the sensor simulation thread More...
|
| |
| void | stopSim () |
| | stop the sensor simulation thread More...
|
| |
| bool | getErrorMsg (std::string &msg) override |
| | get error msg (valid if function returns true) More...
|
| |
| bool | isThreadRunning () const override |
| | indicates if simulation thread is running More...
|
| |
| SENSCaptureProps | _captureProperties |
| |
| std::atomic< bool > | _started {false} |
| | flags if camera was started More...
|
| |
| SENSCameraConfig | _config |
| | indicates what is currently running More...
|
| |
| std::atomic< bool > | _permissionGranted {false} |
| |
| std::vector< SENSCameraListener * > | _listeners |
| |
| std::mutex | _listenerMutex |
| |
| SENSFrameBasePtr | _frame |
| | current frame More...
|
| |
| std::mutex | _frameMutex |
| |
| std::vector< std::pair< SENSTimePt, int > > | _data |
| |
| SensorSimStoppedCB | _sensorSimStoppedCB |
| |
| StartSimCB | _startSimCB |
| |
| std::thread | _thread |
| |
| std::condition_variable | _condVar |
| |
| std::mutex | _mutex |
| |
| bool | _stop |
| |
| SENSTimePt | _commonSimStartTimePt |
| |
| bool | _threadIsRunning |
| |
| const SENSSimClock & | _clock |
| |
| std::string | _name |
| |
| std::mutex | _msgMutex |
| |
| std::string | _errorMsg |
| |
SENSSimulatedCamera SENSSimulated implementation for Camera sensor simulation. Implements the SENSBaseCamera interface to make it a full camera sensor and the SENSSimulated interface for the sensor simulation backend.
Definition at line 158 of file SENSSimulated.h.
◆ ~SENSSimulatedCamera()
| SENSSimulatedCamera::~SENSSimulatedCamera |
( |
| ) |
|
◆ SENSSimulatedCamera()
Definition at line 292 of file SENSSimulated.cpp.
298 :
SENSSimulated(
"camera", startSimCB, sensorSimStoppedCB, std::move(data), clock),
SENSCameraConfig _config
indicates what is currently running
std::atomic< bool > _permissionGranted
std::string _videoFileName
SENSSimulated(const std::string name, StartSimCB startSimCB, SensorSimStoppedCB sensorSimStoppedCB, std::vector< std::pair< SENSTimePt, int >> &&data, const SENSSimClock &clock)
◆ captureProperties()
Get SENSCaptureProps which contains necessary information about all available camera devices and their capabilities.
Implements SENSCamera.
Definition at line 280 of file SENSSimulated.cpp.
SENSCaptureProps _captureProperties
SENSCameraFacing facing
camera facing
SENSCameraStreamConfig streamConfig
currently selected stream config index (use it to look up original capture size)
◆ feedSensorData()
| void SENSSimulatedCamera::feedSensorData |
( |
const int |
counter | ) |
|
|
overrideprivatevirtual |
feed new sensor data to sensor
Implements SENSSimulated< int >.
Definition at line 305 of file SENSSimulated.cpp.
High Resolution Timer class using C++11.
int64_t elapsedTimeInMicroSec()
void updateFrame(cv::Mat bgrImg, cv::Mat intrinsics, int width, int height, bool intrinsicsChanged)
void prepareSensorData(const int counter) override
std::vector< std::pair< SENSTimePt, int > > _data
◆ onLatencyProblem()
| void SENSSimulatedCamera::onLatencyProblem |
( |
int & |
counter | ) |
|
|
overrideprivatevirtual |
when feeding camera frames from cv::videocapture updating the frame pos may take ages. So we skip one more frame and update the next frame counter
Reimplemented from SENSSimulated< int >.
Definition at line 351 of file SENSSimulated.cpp.
360 SENSMicroseconds neededTime = std::chrono::duration_cast<SENSMicroseconds>(t1 - t0);
365 while (counter <
_data.size() - 1 &&
_data[counter].first < now)
369 SENSMicroseconds availableTime = std::chrono::duration_cast<SENSMicroseconds>(
_data[counter + 1].first -
_data[counter].first);
370 auto factor = neededTime.count() / availableTime.count();
372 SENS_DEBUG(
"factor %lld neededTime %lld available time %lld", factor, neededTime.count(), availableTime.count());
375 if (counter <
_data.size())
377 t0 = SENSClock::now();
379 t1 = SENSClock::now();
380 neededTime = std::chrono::duration_cast<SENSMicroseconds>(t1 - t0);
std::chrono::microseconds SENSMicroseconds
std::chrono::high_resolution_clock::time_point SENSTimePt
SENSTimePt now() const
get current simulation time (const function which should be thread save)
const SENSSimClock & _clock
◆ prepareSensorData()
| void SENSSimulatedCamera::prepareSensorData |
( |
const int |
counter | ) |
|
|
overrideprivatevirtual |
prepare things that may take some time for the next writing of sensor data (e.g. for video reading we can already read the frame and do decoding and maybe it also blocks for some reasons..)
Reimplemented from SENSSimulated< int >.
Definition at line 320 of file SENSSimulated.cpp.
322 if (counter >=
_data.size())
325 int frameIndex =
_data[counter].second;
331 int nextFramePos =
_cap.get(cv::CAP_PROP_POS_FRAMES);
332 if (nextFramePos != frameIndex)
335 _cap.set(cv::CAP_PROP_POS_FRAMES, frameIndex);
◆ start()
Call this function to configure the camera if you exactly know, what device you want to open and with which stream configuration. You can find out these properties by using SENSCaptureProps object (see getCaptureProperties())
- Parameters
-
| deviceId | camera device id to start |
| streamConfig | SENSCameraStreamConfig from camera device. This defines the size of the image. The image is converted to BGR and assigned to SENSFrame::imgBGR. |
| provideIntrinsics | specifies if intrinsics estimation should be enabled. The estimated intrinsics are transferred with every SENSFrame as they may be different for every frame (e.g. on iOS). This value has different effects on different architectures. |
- Returns
- the found configuration that is adjusted and used when SENSCamera::start() is called.
Implements SENSCamera.
Definition at line 239 of file SENSSimulated.cpp.
245 Utils::warnMsg(
"SENSWebCamera",
"Call to start was ignored. Camera is currently running!", __LINE__, __FILE__);
249 if (!
_cap.isOpened())
std::atomic< bool > _started
flags if camera was started
void processStart()
call from start function to do startup preprocessing
const SENSCaptureProps & captureProperties() override
Get SENSCaptureProps which contains necessary information about all available camera devices and thei...
void startSim()
start the sensor simulation thread
void warnMsg(const char *tag, const char *msg, const int line, const char *file)
Platform independent warn message output.
◆ stop()
| void SENSSimulatedCamera::stop |
( |
| ) |
|
|
overridevirtual |
Stop a started camera device.
Implements SENSCamera.
Definition at line 271 of file SENSSimulated.cpp.
void stopSim()
stop the sensor simulation thread
◆ SENSSimulator
◆ _cap
| cv::VideoCapture SENSSimulatedCamera::_cap |
|
private |
◆ _frame
| cv::Mat SENSSimulatedCamera::_frame |
|
private |
◆ _frameMutex
| std::mutex SENSSimulatedCamera::_frameMutex |
|
private |
◆ _preparedFrame
| cv::Mat SENSSimulatedCamera::_preparedFrame |
|
private |
◆ _preparedFrameIndex
| int SENSSimulatedCamera::_preparedFrameIndex = -1 |
|
private |
◆ _videoFileName
| std::string SENSSimulatedCamera::_videoFileName |
|
private |
The documentation for this class was generated from the following files: