-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
49 lines (36 loc) · 1.43 KB
/
main.cpp
File metadata and controls
49 lines (36 loc) · 1.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#include <sensor/OutputSensor.hpp>
int main() {
constexpr auto fps = 40.0;
constexpr auto width = 640;
constexpr auto height = 480;
constexpr size_t imgSize = width * height;
using Resolution = hub::MatrixXD<hub::format::BGR8, width, height>;
hub::MetaData metaData;
metaData["manufactor"] = "Your company";
hub::sensor::SensorSpec sensorSpec( "sensorName", Resolution(), metaData );
hub::sensor::OutputSensorT<Resolution> outputSensor( sensorSpec, "streamName" );
auto acq = outputSensor.acqMsg();
auto& start = acq.start();
auto& end = acq.end();
auto* imgData = acq.get<hub::format::BGR8*>();
size_t dec = 0;
while ( true ) {
const auto startClock = std::chrono::high_resolution_clock::now();
start = hub::sensor::getClock();
for ( int i = 0; i < height; ++i ) {
for ( int j = 0; j < width; ++j ) {
const auto idx = i * width + j;
assert( idx < imgSize );
imgData[idx].b = ( i + j + dec ) % 256;
imgData[idx].g = ( i + j + dec ) % 256;
imgData[idx].r = ( i + j + dec ) % 256;
}
}
end = hub::sensor::getClock();
outputSensor << acq;
++dec;
const auto endClock = startClock + std::chrono::microseconds( (int)( 1'000'000 / fps ) );
std::this_thread::sleep_until( endClock );
}
return 0;
}