Skip to content

Commit 11d344d

Browse files
Merge pull request #545 from luxonis/ts_metadata
Add timestamp, sequence number metadata to Tracklets, TrackedFeatures, SpatialLocations, Apriltags
2 parents 361bca4 + 5e1be90 commit 11d344d

File tree

10 files changed

+268
-2
lines changed

10 files changed

+268
-2
lines changed

cmake/Depthai/DepthaiDeviceSideConfig.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
set(DEPTHAI_DEVICE_SIDE_MATURITY "snapshot")
33

44
# "full commit hash of device side binary"
5-
set(DEPTHAI_DEVICE_SIDE_COMMIT "89ec5d6cd261b354a09915267fb751a294d14ec4")
5+
set(DEPTHAI_DEVICE_SIDE_COMMIT "602822fe9eaca68a72c666497dc4979b29291b3e")
66

77
# "version if applicable"
88
set(DEPTHAI_DEVICE_SIDE_VERSION "")

include/depthai/pipeline/datatype/AprilTags.hpp

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,37 @@ class AprilTags : public Buffer {
2424
virtual ~AprilTags() = default;
2525

2626
std::vector<AprilTag>& aprilTags;
27+
28+
/**
29+
* Retrieves image timestamp related to dai::Clock::now()
30+
*/
31+
std::chrono::time_point<std::chrono::steady_clock, std::chrono::steady_clock::duration> getTimestamp() const;
32+
33+
/**
34+
* Retrieves image timestamp directly captured from device's monotonic clock,
35+
* not synchronized to host time. Used mostly for debugging
36+
*/
37+
std::chrono::time_point<std::chrono::steady_clock, std::chrono::steady_clock::duration> getTimestampDevice() const;
38+
39+
/**
40+
* Retrieves image sequence number
41+
*/
42+
int64_t getSequenceNum() const;
43+
44+
/**
45+
* Sets image timestamp related to dai::Clock::now()
46+
*/
47+
AprilTags& setTimestamp(std::chrono::time_point<std::chrono::steady_clock, std::chrono::steady_clock::duration> timestamp);
48+
49+
/**
50+
* Sets image timestamp related to dai::Clock::now()
51+
*/
52+
AprilTags& setTimestampDevice(std::chrono::time_point<std::chrono::steady_clock, std::chrono::steady_clock::duration> timestamp);
53+
54+
/**
55+
* Retrieves image sequence number
56+
*/
57+
AprilTags& setSequenceNum(int64_t sequenceNum);
2758
};
2859

2960
} // namespace dai

include/depthai/pipeline/datatype/SpatialLocationCalculatorData.hpp

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,37 @@ class SpatialLocationCalculatorData : public Buffer {
3030
std::vector<SpatialLocations>& getSpatialLocations() const;
3131

3232
std::vector<SpatialLocations>& spatialLocations;
33+
34+
/**
35+
* Retrieves image timestamp related to dai::Clock::now()
36+
*/
37+
std::chrono::time_point<std::chrono::steady_clock, std::chrono::steady_clock::duration> getTimestamp() const;
38+
39+
/**
40+
* Retrieves image timestamp directly captured from device's monotonic clock,
41+
* not synchronized to host time. Used mostly for debugging
42+
*/
43+
std::chrono::time_point<std::chrono::steady_clock, std::chrono::steady_clock::duration> getTimestampDevice() const;
44+
45+
/**
46+
* Retrieves image sequence number
47+
*/
48+
int64_t getSequenceNum() const;
49+
50+
/**
51+
* Sets image timestamp related to dai::Clock::now()
52+
*/
53+
SpatialLocationCalculatorData& setTimestamp(std::chrono::time_point<std::chrono::steady_clock, std::chrono::steady_clock::duration> timestamp);
54+
55+
/**
56+
* Sets image timestamp related to dai::Clock::now()
57+
*/
58+
SpatialLocationCalculatorData& setTimestampDevice(std::chrono::time_point<std::chrono::steady_clock, std::chrono::steady_clock::duration> timestamp);
59+
60+
/**
61+
* Retrieves image sequence number
62+
*/
63+
SpatialLocationCalculatorData& setSequenceNum(int64_t sequenceNum);
3364
};
3465

3566
} // namespace dai

include/depthai/pipeline/datatype/TrackedFeatures.hpp

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,37 @@ class TrackedFeatures : public Buffer {
2424
virtual ~TrackedFeatures() = default;
2525

2626
std::vector<TrackedFeature>& trackedFeatures;
27+
28+
/**
29+
* Retrieves image timestamp related to dai::Clock::now()
30+
*/
31+
std::chrono::time_point<std::chrono::steady_clock, std::chrono::steady_clock::duration> getTimestamp() const;
32+
33+
/**
34+
* Retrieves image timestamp directly captured from device's monotonic clock,
35+
* not synchronized to host time. Used mostly for debugging
36+
*/
37+
std::chrono::time_point<std::chrono::steady_clock, std::chrono::steady_clock::duration> getTimestampDevice() const;
38+
39+
/**
40+
* Retrieves image sequence number
41+
*/
42+
int64_t getSequenceNum() const;
43+
44+
/**
45+
* Sets image timestamp related to dai::Clock::now()
46+
*/
47+
TrackedFeatures& setTimestamp(std::chrono::time_point<std::chrono::steady_clock, std::chrono::steady_clock::duration> timestamp);
48+
49+
/**
50+
* Sets image timestamp related to dai::Clock::now()
51+
*/
52+
TrackedFeatures& setTimestampDevice(std::chrono::time_point<std::chrono::steady_clock, std::chrono::steady_clock::duration> timestamp);
53+
54+
/**
55+
* Retrieves image sequence number
56+
*/
57+
TrackedFeatures& setSequenceNum(int64_t sequenceNum);
2758
};
2859

2960
} // namespace dai

include/depthai/pipeline/datatype/Tracklets.hpp

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,37 @@ class Tracklets : public Buffer {
2929
* @returns Vector of object tracker data, carrying tracking information.
3030
*/
3131
std::vector<Tracklet>& tracklets;
32+
33+
/**
34+
* Retrieves image timestamp related to dai::Clock::now()
35+
*/
36+
std::chrono::time_point<std::chrono::steady_clock, std::chrono::steady_clock::duration> getTimestamp() const;
37+
38+
/**
39+
* Retrieves image timestamp directly captured from device's monotonic clock,
40+
* not synchronized to host time. Used mostly for debugging
41+
*/
42+
std::chrono::time_point<std::chrono::steady_clock, std::chrono::steady_clock::duration> getTimestampDevice() const;
43+
44+
/**
45+
* Retrieves image sequence number
46+
*/
47+
int64_t getSequenceNum() const;
48+
49+
/**
50+
* Sets image timestamp related to dai::Clock::now()
51+
*/
52+
Tracklets& setTimestamp(std::chrono::time_point<std::chrono::steady_clock, std::chrono::steady_clock::duration> timestamp);
53+
54+
/**
55+
* Sets image timestamp related to dai::Clock::now()
56+
*/
57+
Tracklets& setTimestampDevice(std::chrono::time_point<std::chrono::steady_clock, std::chrono::steady_clock::duration> timestamp);
58+
59+
/**
60+
* Retrieves image sequence number
61+
*/
62+
Tracklets& setSequenceNum(int64_t sequenceNum);
3263
};
3364

3465
} // namespace dai

src/pipeline/datatype/AprilTags.cpp

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,39 @@ AprilTags::AprilTags() : Buffer(std::make_shared<RawAprilTags>()), rawdata(*dyna
1010
AprilTags::AprilTags(std::shared_ptr<RawAprilTags> ptr)
1111
: Buffer(std::move(ptr)), rawdata(*dynamic_cast<RawAprilTags*>(raw.get())), aprilTags(rawdata.aprilTags) {}
1212

13+
// getters
14+
std::chrono::time_point<std::chrono::steady_clock, std::chrono::steady_clock::duration> AprilTags::getTimestamp() const {
15+
using namespace std::chrono;
16+
return time_point<steady_clock, steady_clock::duration>{seconds(rawdata.ts.sec) + nanoseconds(rawdata.ts.nsec)};
17+
}
18+
std::chrono::time_point<std::chrono::steady_clock, std::chrono::steady_clock::duration> AprilTags::getTimestampDevice() const {
19+
using namespace std::chrono;
20+
return time_point<steady_clock, steady_clock::duration>{seconds(rawdata.tsDevice.sec) + nanoseconds(rawdata.tsDevice.nsec)};
21+
}
22+
int64_t AprilTags::getSequenceNum() const {
23+
return rawdata.sequenceNum;
24+
}
25+
26+
// setters
27+
AprilTags& AprilTags::setTimestamp(std::chrono::time_point<std::chrono::steady_clock, std::chrono::steady_clock::duration> tp) {
28+
// Set timestamp from timepoint
29+
using namespace std::chrono;
30+
auto ts = tp.time_since_epoch();
31+
rawdata.ts.sec = duration_cast<seconds>(ts).count();
32+
rawdata.ts.nsec = duration_cast<nanoseconds>(ts).count() % 1000000000;
33+
return *this;
34+
}
35+
AprilTags& AprilTags::setTimestampDevice(std::chrono::time_point<std::chrono::steady_clock, std::chrono::steady_clock::duration> tp) {
36+
// Set timestamp from timepoint
37+
using namespace std::chrono;
38+
auto ts = tp.time_since_epoch();
39+
rawdata.tsDevice.sec = duration_cast<seconds>(ts).count();
40+
rawdata.ts.nsec = duration_cast<nanoseconds>(ts).count() % 1000000000;
41+
return *this;
42+
}
43+
AprilTags& AprilTags::setSequenceNum(int64_t sequenceNum) {
44+
rawdata.sequenceNum = sequenceNum;
45+
return *this;
46+
}
47+
1348
} // namespace dai

src/pipeline/datatype/SpatialLocationCalculatorData.cpp

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,41 @@ std::vector<SpatialLocations>& SpatialLocationCalculatorData::getSpatialLocation
1515
return rawdata.spatialLocations;
1616
}
1717

18+
// getters
19+
std::chrono::time_point<std::chrono::steady_clock, std::chrono::steady_clock::duration> SpatialLocationCalculatorData::getTimestamp() const {
20+
using namespace std::chrono;
21+
return time_point<steady_clock, steady_clock::duration>{seconds(rawdata.ts.sec) + nanoseconds(rawdata.ts.nsec)};
22+
}
23+
std::chrono::time_point<std::chrono::steady_clock, std::chrono::steady_clock::duration> SpatialLocationCalculatorData::getTimestampDevice() const {
24+
using namespace std::chrono;
25+
return time_point<steady_clock, steady_clock::duration>{seconds(rawdata.tsDevice.sec) + nanoseconds(rawdata.tsDevice.nsec)};
26+
}
27+
int64_t SpatialLocationCalculatorData::getSequenceNum() const {
28+
return rawdata.sequenceNum;
29+
}
30+
31+
// setters
32+
SpatialLocationCalculatorData& SpatialLocationCalculatorData::setTimestamp(
33+
std::chrono::time_point<std::chrono::steady_clock, std::chrono::steady_clock::duration> tp) {
34+
// Set timestamp from timepoint
35+
using namespace std::chrono;
36+
auto ts = tp.time_since_epoch();
37+
rawdata.ts.sec = duration_cast<seconds>(ts).count();
38+
rawdata.ts.nsec = duration_cast<nanoseconds>(ts).count() % 1000000000;
39+
return *this;
40+
}
41+
SpatialLocationCalculatorData& SpatialLocationCalculatorData::setTimestampDevice(
42+
std::chrono::time_point<std::chrono::steady_clock, std::chrono::steady_clock::duration> tp) {
43+
// Set timestamp from timepoint
44+
using namespace std::chrono;
45+
auto ts = tp.time_since_epoch();
46+
rawdata.tsDevice.sec = duration_cast<seconds>(ts).count();
47+
rawdata.ts.nsec = duration_cast<nanoseconds>(ts).count() % 1000000000;
48+
return *this;
49+
}
50+
SpatialLocationCalculatorData& SpatialLocationCalculatorData::setSequenceNum(int64_t sequenceNum) {
51+
rawdata.sequenceNum = sequenceNum;
52+
return *this;
53+
}
54+
1855
} // namespace dai

src/pipeline/datatype/TrackedFeatures.cpp

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,39 @@ TrackedFeatures::TrackedFeatures()
1111
TrackedFeatures::TrackedFeatures(std::shared_ptr<RawTrackedFeatures> ptr)
1212
: Buffer(std::move(ptr)), rawdata(*dynamic_cast<RawTrackedFeatures*>(raw.get())), trackedFeatures(rawdata.trackedFeatures) {}
1313

14+
// getters
15+
std::chrono::time_point<std::chrono::steady_clock, std::chrono::steady_clock::duration> TrackedFeatures::getTimestamp() const {
16+
using namespace std::chrono;
17+
return time_point<steady_clock, steady_clock::duration>{seconds(rawdata.ts.sec) + nanoseconds(rawdata.ts.nsec)};
18+
}
19+
std::chrono::time_point<std::chrono::steady_clock, std::chrono::steady_clock::duration> TrackedFeatures::getTimestampDevice() const {
20+
using namespace std::chrono;
21+
return time_point<steady_clock, steady_clock::duration>{seconds(rawdata.tsDevice.sec) + nanoseconds(rawdata.tsDevice.nsec)};
22+
}
23+
int64_t TrackedFeatures::getSequenceNum() const {
24+
return rawdata.sequenceNum;
25+
}
26+
27+
// setters
28+
TrackedFeatures& TrackedFeatures::setTimestamp(std::chrono::time_point<std::chrono::steady_clock, std::chrono::steady_clock::duration> tp) {
29+
// Set timestamp from timepoint
30+
using namespace std::chrono;
31+
auto ts = tp.time_since_epoch();
32+
rawdata.ts.sec = duration_cast<seconds>(ts).count();
33+
rawdata.ts.nsec = duration_cast<nanoseconds>(ts).count() % 1000000000;
34+
return *this;
35+
}
36+
TrackedFeatures& TrackedFeatures::setTimestampDevice(std::chrono::time_point<std::chrono::steady_clock, std::chrono::steady_clock::duration> tp) {
37+
// Set timestamp from timepoint
38+
using namespace std::chrono;
39+
auto ts = tp.time_since_epoch();
40+
rawdata.tsDevice.sec = duration_cast<seconds>(ts).count();
41+
rawdata.ts.nsec = duration_cast<nanoseconds>(ts).count() % 1000000000;
42+
return *this;
43+
}
44+
TrackedFeatures& TrackedFeatures::setSequenceNum(int64_t sequenceNum) {
45+
rawdata.sequenceNum = sequenceNum;
46+
return *this;
47+
}
48+
1449
} // namespace dai

src/pipeline/datatype/Tracklets.cpp

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,39 @@ Tracklets::Tracklets() : Buffer(std::make_shared<RawTracklets>()), rawdata(*dyna
1010
Tracklets::Tracklets(std::shared_ptr<RawTracklets> ptr)
1111
: Buffer(std::move(ptr)), rawdata(*dynamic_cast<RawTracklets*>(raw.get())), tracklets(rawdata.tracklets) {}
1212

13+
// getters
14+
std::chrono::time_point<std::chrono::steady_clock, std::chrono::steady_clock::duration> Tracklets::getTimestamp() const {
15+
using namespace std::chrono;
16+
return time_point<steady_clock, steady_clock::duration>{seconds(rawdata.ts.sec) + nanoseconds(rawdata.ts.nsec)};
17+
}
18+
std::chrono::time_point<std::chrono::steady_clock, std::chrono::steady_clock::duration> Tracklets::getTimestampDevice() const {
19+
using namespace std::chrono;
20+
return time_point<steady_clock, steady_clock::duration>{seconds(rawdata.tsDevice.sec) + nanoseconds(rawdata.tsDevice.nsec)};
21+
}
22+
int64_t Tracklets::getSequenceNum() const {
23+
return rawdata.sequenceNum;
24+
}
25+
26+
// setters
27+
Tracklets& Tracklets::setTimestamp(std::chrono::time_point<std::chrono::steady_clock, std::chrono::steady_clock::duration> tp) {
28+
// Set timestamp from timepoint
29+
using namespace std::chrono;
30+
auto ts = tp.time_since_epoch();
31+
rawdata.ts.sec = duration_cast<seconds>(ts).count();
32+
rawdata.ts.nsec = duration_cast<nanoseconds>(ts).count() % 1000000000;
33+
return *this;
34+
}
35+
Tracklets& Tracklets::setTimestampDevice(std::chrono::time_point<std::chrono::steady_clock, std::chrono::steady_clock::duration> tp) {
36+
// Set timestamp from timepoint
37+
using namespace std::chrono;
38+
auto ts = tp.time_since_epoch();
39+
rawdata.tsDevice.sec = duration_cast<seconds>(ts).count();
40+
rawdata.ts.nsec = duration_cast<nanoseconds>(ts).count() % 1000000000;
41+
return *this;
42+
}
43+
Tracklets& Tracklets::setSequenceNum(int64_t sequenceNum) {
44+
rawdata.sequenceNum = sequenceNum;
45+
return *this;
46+
}
47+
1348
} // namespace dai

0 commit comments

Comments
 (0)