Skip to content
Snippets Groups Projects

Implements #196 stream capturing

Merged Nicolas Pope requested to merge bug/196/snapshotcapture into master
Files
3
@@ -42,9 +42,10 @@ int main(int argc, char **argv) {
LOG(INFO) << "Playing...";
int current_stream = 0;
int current_channel = 0;
bool res = r.read(90000000000000, [&current_stream,&r](const ftl::codecs::StreamPacket &spkt, const ftl::codecs::Packet &pkt) {
if (spkt.channel & 0x1 > 0) return;
bool res = r.read(90000000000000, [&current_stream,&current_channel,&r](const ftl::codecs::StreamPacket &spkt, const ftl::codecs::Packet &pkt) {
if (spkt.channel != current_channel) return;
if (spkt.streamID == current_stream) {
if (pkt.codec == codec_t::POSE) {
@@ -61,7 +62,7 @@ int main(int argc, char **argv) {
LOG(INFO) << "Reading packet: (" << (int)spkt.streamID << "," << (int)spkt.channel << ") " << (int)pkt.codec << ", " << (int)pkt.definition;
cv::Mat frame(cv::Size(ftl::codecs::getWidth(pkt.definition),ftl::codecs::getHeight(pkt.definition)), CV_8UC3);
cv::Mat frame(cv::Size(ftl::codecs::getWidth(pkt.definition),ftl::codecs::getHeight(pkt.definition)), (spkt.channel == 1) ? CV_32F : CV_8UC3);
createDecoder(pkt);
try {
@@ -71,11 +72,15 @@ int main(int argc, char **argv) {
}
if (!frame.empty()) {
double time = (double)(spkt.timestamp - r.getStartTime()) / 1000.0;
cv::putText(frame, std::string("Time: ") + std::to_string(time) + std::string("s"), cv::Point(10,20), cv::FONT_HERSHEY_PLAIN, 1, cv::Scalar(0,0,255));
cv::imshow("Player", frame);
}
int key = cv::waitKey(20);
if (key >= 48 && key <= 57) {
current_stream = key - 48;
} else if (key == 'd') {
current_channel = (current_channel == 0) ? 1 : 0;
} else if (key == 27) {
r.end();
}
Loading