From 76d12ccec7c64c1ad68e68bebf48938468b53e82 Mon Sep 17 00:00:00 2001 From: John Zhao Date: Fri, 11 May 2018 13:23:04 +0800 Subject: [PATCH] Show depth if new in get_from_callbacks --- samples/tutorials/data/get_from_callbacks.cc | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/samples/tutorials/data/get_from_callbacks.cc b/samples/tutorials/data/get_from_callbacks.cc index 811e3b7..2842182 100644 --- a/samples/tutorials/data/get_from_callbacks.cc +++ b/samples/tutorials/data/get_from_callbacks.cc @@ -91,6 +91,7 @@ int main(int argc, char *argv[]) { cv::namedWindow("frame"); cv::namedWindow("depth"); + unsigned int depth_num = 0; while (true) { api->WaitForStreams(); @@ -121,12 +122,17 @@ int main(int argc, char *argv[]) { // Show depth if (!depth.empty()) { - std::lock_guard _(depth_mtx); - ss.str(""); - ss.clear(); - ss << "depth: " << depth_count; - painter.DrawText(depth, ss.str()); - cv::imshow("depth", depth); // CV_16UC1 + // Is the depth a new one? + if (depth_num != depth_count || depth_num == 0) { + std::lock_guard _(depth_mtx); + depth_num = depth_count; + // LOG(INFO) << "depth_num: " << depth_num; + ss.str(""); + ss.clear(); + ss << "depth: " << depth_count; + painter.DrawText(depth, ss.str()); + cv::imshow("depth", depth); // CV_16UC1 + } } char key = static_cast(cv::waitKey(1));