diff --git a/samples/tutorials/data/get_depth.cc b/samples/tutorials/data/get_depth.cc index 2e928a3..5461cdc 100644 --- a/samples/tutorials/data/get_depth.cc +++ b/samples/tutorials/data/get_depth.cc @@ -31,7 +31,7 @@ int main(int argc, char *argv[]) { double fps; double t = 0.01; - std::cout << "fps:" << std::endl; + std::cout << "depth fps:" << std::endl; api->EnableStreamData(Stream::DEPTH); api->EnableStreamData(Stream::DISPARITY_NORMALIZED); @@ -48,10 +48,6 @@ int main(int argc, char *argv[]) { auto &&right_data = api->GetStreamData(Stream::RIGHT); if (!left_data.frame.empty() && !right_data.frame.empty()) { - double t_c = cv::getTickCount() / cv::getTickFrequency(); - fps = 1.0/(t_c - t); - printf("\b\b\b\b\b\b\b\b\b%.2f", fps); - t = t_c; cv::Mat img; cv::hconcat(left_data.frame, right_data.frame, img); cv::imshow("frame", img); @@ -60,6 +56,10 @@ int main(int argc, char *argv[]) { // this code is for real depth data auto &&depth_data = api->GetStreamData(Stream::DEPTH); if (!depth_data.frame.empty()) { + double t_c = cv::getTickCount() / cv::getTickFrequency(); + fps = 1.0/(t_c - t); + printf("\b\b\b\b\b\b\b\b\b%.2f", fps); + t = t_c; cv::imshow("depth_real", depth_data.frame); // CV_16UC1 } diff --git a/samples/tutorials/data/get_disparity.cc b/samples/tutorials/data/get_disparity.cc index 65fe138..28dacb8 100644 --- a/samples/tutorials/data/get_disparity.cc +++ b/samples/tutorials/data/get_disparity.cc @@ -54,7 +54,7 @@ int main(int argc, char *argv[]) { double fps; double t = 0.01; - std::cout << "fps:" << std::endl; + std::cout << "disparity fps:" << std::endl; while (true) { api->WaitForStreams(); @@ -63,10 +63,6 @@ int main(int argc, char *argv[]) { auto &&right_data = api->GetStreamData(Stream::RIGHT); if (!left_data.frame.empty() && !right_data.frame.empty()) { - double t_c = cv::getTickCount() / cv::getTickFrequency(); - fps = 1.0/(t_c - t); - printf("\b\b\b\b\b\b\b\b\b%.2f", fps); - t = t_c; cv::Mat img; cv::hconcat(left_data.frame, right_data.frame, img); cv::imshow("frame", img); @@ -79,6 +75,10 @@ int main(int argc, char *argv[]) { auto &&disp_norm_data = api->GetStreamData(Stream::DISPARITY_NORMALIZED); if (!disp_norm_data.frame.empty()) { + double t_c = cv::getTickCount() / cv::getTickFrequency(); + fps = 1.0/(t_c - t); + printf("\b\b\b\b\b\b\b\b\b%.2f", fps); + t = t_c; cv::imshow("disparity_normalized", disp_norm_data.frame); // CV_8UC1 } diff --git a/samples/tutorials/data/get_points.cc b/samples/tutorials/data/get_points.cc index b2a8b5e..aa2558a 100644 --- a/samples/tutorials/data/get_points.cc +++ b/samples/tutorials/data/get_points.cc @@ -35,7 +35,7 @@ int main(int argc, char *argv[]) { double fps; double t = 0.01; - std::cout << "fps:" << std::endl; + std::cout << "points cloud fps:" << std::endl; cv::namedWindow("frame"); PCViewer pcviewer; @@ -46,11 +46,6 @@ int main(int argc, char *argv[]) { auto &&left_data = api->GetStreamData(Stream::LEFT); auto &&right_data = api->GetStreamData(Stream::RIGHT); if (!left_data.frame.empty() && !right_data.frame.empty()) { - double t_c = cv::getTickCount() / cv::getTickFrequency(); - fps = 1.0/(t_c - t); - printf("\b\b\b\b\b\b\b\b\b%.2f", fps); - t = t_c; - cv::Mat img; cv::hconcat(left_data.frame, right_data.frame, img); cv::imshow("frame", img); @@ -58,6 +53,10 @@ int main(int argc, char *argv[]) { auto &&points_data = api->GetStreamData(Stream::POINTS); if (!points_data.frame.empty()) { + double t_c = cv::getTickCount() / cv::getTickFrequency(); + fps = 1.0/(t_c - t); + printf("\b\b\b\b\b\b\b\b\b%.2f", fps); + t = t_c; pcviewer.Update(points_data.frame); }