From 900c44179dae1bed99ccaf29bc873b74fcd9272c Mon Sep 17 00:00:00 2001 From: KalmanSLightech Date: Mon, 23 Jul 2018 20:28:15 +0800 Subject: [PATCH] fix the record's bug --- samples/device/camera.cc | 3 ++- tools/dataset/dataset.cc | 3 ++- tools/dataset/record.cc | 6 ++++-- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/samples/device/camera.cc b/samples/device/camera.cc index e225ccc..dd5afb8 100644 --- a/samples/device/camera.cc +++ b/samples/device/camera.cc @@ -120,8 +120,9 @@ int main(int argc, char *argv[]) { right_data.frame->data()); cv::Mat img; + cv::cvtColor(left_img, left_img, cv::COLOR_YUV2BGR_YUY2); + cv::cvtColor(right_img, right_img, cv::COLOR_YUV2BGR_YUY2); cv::hconcat(left_img, right_img, img); - cv::cvtColor(img, img, cv::COLOR_YUV2BGR_YUY2); cv::imshow("frame", img); char key = static_cast(cv::waitKey(1)); diff --git a/tools/dataset/dataset.cc b/tools/dataset/dataset.cc index 1fea9c9..95a92f6 100644 --- a/tools/dataset/dataset.cc +++ b/tools/dataset/dataset.cc @@ -70,7 +70,8 @@ void Dataset::SaveStreamData( ss << writer->outdir << OS_SEP << std::dec << std::setw(IMAGE_FILENAME_WIDTH) << std::setfill('0') << seq << ".png"; cv::Mat img( - data.frame->height(), data.frame->width(), CV_8UC1, data.frame->data()); + data.frame->height(), data.frame->width(), CV_8UC2, data.frame->data()); + cv::cvtColor(img, img, cv::COLOR_YUV2BGR_YUY2); cv::imwrite(ss.str(), img); } ++stream_counts_[stream]; diff --git a/tools/dataset/record.cc b/tools/dataset/record.cc index e3de362..5ecdc14 100644 --- a/tools/dataset/record.cc +++ b/tools/dataset/record.cc @@ -80,12 +80,14 @@ int main(int argc, char *argv[]) { auto &&left_frame = left_datas.back().frame; auto &&right_frame = right_datas.back().frame; cv::Mat left_img( - left_frame->height(), left_frame->width(), CV_8UC1, left_frame->data()); + left_frame->height(), left_frame->width(), CV_8UC2, left_frame->data()); cv::Mat right_img( - right_frame->height(), right_frame->width(), CV_8UC1, + right_frame->height(), right_frame->width(), CV_8UC2, right_frame->data()); cv::Mat img; + cv::cvtColor(left_img, left_img, cv::COLOR_YUV2BGR_YUY2); + cv::cvtColor(right_img, right_img, cv::COLOR_YUV2BGR_YUY2); cv::hconcat(left_img, right_img, img); cv::imshow("frame", img);