fix: change fps show to right target

This commit is contained in:
TinyOh 2019-04-10 11:40:14 +08:00
parent 7e588d5e24
commit 089c1b1b0c
3 changed files with 15 additions and 16 deletions

View File

@ -31,7 +31,7 @@ int main(int argc, char *argv[]) {
double fps; double fps;
double t = 0.01; double t = 0.01;
std::cout << "fps:" << std::endl; std::cout << "depth fps:" << std::endl;
api->EnableStreamData(Stream::DEPTH); api->EnableStreamData(Stream::DEPTH);
api->EnableStreamData(Stream::DISPARITY_NORMALIZED); api->EnableStreamData(Stream::DISPARITY_NORMALIZED);
@ -48,10 +48,6 @@ int main(int argc, char *argv[]) {
auto &&right_data = api->GetStreamData(Stream::RIGHT); auto &&right_data = api->GetStreamData(Stream::RIGHT);
if (!left_data.frame.empty() && !right_data.frame.empty()) { 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::Mat img;
cv::hconcat(left_data.frame, right_data.frame, img); cv::hconcat(left_data.frame, right_data.frame, img);
cv::imshow("frame", img); cv::imshow("frame", img);
@ -60,6 +56,10 @@ int main(int argc, char *argv[]) {
// this code is for real depth data // this code is for real depth data
auto &&depth_data = api->GetStreamData(Stream::DEPTH); auto &&depth_data = api->GetStreamData(Stream::DEPTH);
if (!depth_data.frame.empty()) { 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 cv::imshow("depth_real", depth_data.frame); // CV_16UC1
} }

View File

@ -54,7 +54,7 @@ int main(int argc, char *argv[]) {
double fps; double fps;
double t = 0.01; double t = 0.01;
std::cout << "fps:" << std::endl; std::cout << "disparity fps:" << std::endl;
while (true) { while (true) {
api->WaitForStreams(); api->WaitForStreams();
@ -63,10 +63,6 @@ int main(int argc, char *argv[]) {
auto &&right_data = api->GetStreamData(Stream::RIGHT); auto &&right_data = api->GetStreamData(Stream::RIGHT);
if (!left_data.frame.empty() && !right_data.frame.empty()) { 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::Mat img;
cv::hconcat(left_data.frame, right_data.frame, img); cv::hconcat(left_data.frame, right_data.frame, img);
cv::imshow("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); auto &&disp_norm_data = api->GetStreamData(Stream::DISPARITY_NORMALIZED);
if (!disp_norm_data.frame.empty()) { 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 cv::imshow("disparity_normalized", disp_norm_data.frame); // CV_8UC1
} }

View File

@ -35,7 +35,7 @@ int main(int argc, char *argv[]) {
double fps; double fps;
double t = 0.01; double t = 0.01;
std::cout << "fps:" << std::endl; std::cout << "points cloud fps:" << std::endl;
cv::namedWindow("frame"); cv::namedWindow("frame");
PCViewer pcviewer; PCViewer pcviewer;
@ -46,11 +46,6 @@ int main(int argc, char *argv[]) {
auto &&left_data = api->GetStreamData(Stream::LEFT); auto &&left_data = api->GetStreamData(Stream::LEFT);
auto &&right_data = api->GetStreamData(Stream::RIGHT); auto &&right_data = api->GetStreamData(Stream::RIGHT);
if (!left_data.frame.empty() && !right_data.frame.empty()) { 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::Mat img;
cv::hconcat(left_data.frame, right_data.frame, img); cv::hconcat(left_data.frame, right_data.frame, img);
cv::imshow("frame", img); cv::imshow("frame", img);
@ -58,6 +53,10 @@ int main(int argc, char *argv[]) {
auto &&points_data = api->GetStreamData(Stream::POINTS); auto &&points_data = api->GetStreamData(Stream::POINTS);
if (!points_data.frame.empty()) { 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); pcviewer.Update(points_data.frame);
} }