Skip to content

Commit 520b55d

Browse files
committed
Output less warnings in depth stream parser
Assembly errors and lost packets should not flood the log output.
1 parent 704ed41 commit 520b55d

File tree

2 files changed

+18
-5
lines changed

2 files changed

+18
-5
lines changed

examples/protonect/include/libfreenect2/depth_packet_stream_parser.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ class LIBFREENECT2_API DepthPacketStreamParser : public DataCallback
6868

6969
uint32_t current_sequence_;
7070
uint32_t current_subsequence_;
71+
uint32_t processed_packets_;
7172
};
7273

7374
} /* namespace libfreenect2 */

examples/protonect/src/depth_packet_stream_parser.cpp

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ namespace libfreenect2
3333

3434
DepthPacketStreamParser::DepthPacketStreamParser() :
3535
processor_(noopProcessor<DepthPacket>()),
36+
processed_packets_(-1),
3637
current_sequence_(0),
3738
current_subsequence_(0)
3839
{
@@ -79,7 +80,7 @@ void DepthPacketStreamParser::onDataReceived(unsigned char* buffer, size_t in_le
7980

8081
if(wb.length + in_length > wb.capacity)
8182
{
82-
LOG_ERROR << "subpacket too large";
83+
LOG_DEBUG << "subpacket too large";
8384
wb.length = 0;
8485
return;
8586
}
@@ -91,7 +92,7 @@ void DepthPacketStreamParser::onDataReceived(unsigned char* buffer, size_t in_le
9192
{
9293
if(footer->length != wb.length)
9394
{
94-
LOG_ERROR << "image data too short!";
95+
LOG_DEBUG << "image data too short!";
9596
}
9697
else
9798
{
@@ -110,15 +111,26 @@ void DepthPacketStreamParser::onDataReceived(unsigned char* buffer, size_t in_le
110111
packet.buffer_length = buffer_.back().length;
111112

112113
processor_->process(packet);
114+
115+
processed_packets_++;
116+
if (processed_packets_ == 0)
117+
processed_packets_ = current_sequence_;
118+
int diff = current_sequence_ - processed_packets_;
119+
const int interval = 30;
120+
if (current_sequence_ % interval == 0 && diff != 0)
121+
{
122+
LOG_INFO << diff << " of " << interval << " packets were lost";
123+
processed_packets_ = current_sequence_;
124+
}
113125
}
114126
else
115127
{
116-
LOG_WARNING << "skipping depth packet";
128+
LOG_DEBUG << "skipping depth packet";
117129
}
118130
}
119131
else
120132
{
121-
LOG_ERROR << "not all subsequences received " << current_subsequence_;
133+
LOG_DEBUG << "not all subsequences received " << current_subsequence_;
122134
}
123135

124136
current_sequence_ = footer->sequence;
@@ -132,7 +144,7 @@ void DepthPacketStreamParser::onDataReceived(unsigned char* buffer, size_t in_le
132144

133145
if(footer->subsequence * footer->length > fb.length)
134146
{
135-
LOG_ERROR << "front buffer too short! subsequence number is " << footer->subsequence;
147+
LOG_DEBUG << "front buffer too short! subsequence number is " << footer->subsequence;
136148
}
137149
else
138150
{

0 commit comments

Comments
 (0)