-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added camera information including framerate, processing and network …
…latency. Improved reassignment of ImageSubscriber to other video surface. Fixed race condition where throttled camera would receive no images.
- Loading branch information
1 parent
a0ab0d7
commit 7da46ce
Showing
5 changed files
with
196 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
// | ||
// Created by stefan on 21.07.21. | ||
// | ||
|
||
#ifndef QML_ROS_PLUGIN_ROLLING_AVERAGE_H | ||
#define QML_ROS_PLUGIN_ROLLING_AVERAGE_H | ||
|
||
#include <array> | ||
|
||
namespace qml_ros_plugin | ||
{ | ||
|
||
template<typename T, int COUNT> | ||
class RollingAverage | ||
{ | ||
public: | ||
RollingAverage() | ||
{ | ||
values_.fill( 0 ); | ||
} | ||
|
||
void add( const T &value ) | ||
{ | ||
if (count_values_ == COUNT) sum_ -= values_[index_]; | ||
values_[index_] = value; | ||
sum_ += value; | ||
if ( ++index_ == COUNT ) index_ = 0; | ||
if (count_values_ != COUNT) ++count_values_; | ||
} | ||
|
||
T value() const { return count_values_ == 0 ? 0 : sum_ / count_values_; } | ||
|
||
operator T() const { return value(); } | ||
|
||
private: | ||
std::array<T, COUNT> values_; | ||
T sum_ = 0; | ||
size_t count_values_ = 0; | ||
size_t index_ = 0; | ||
}; | ||
} | ||
|
||
#endif //QML_ROS_PLUGIN_ROLLING_AVERAGE_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters