diff --git a/tools/dataset/record2.cc b/tools/dataset/record2.cc index 48b8bfd..4f8c647 100644 --- a/tools/dataset/record2.cc +++ b/tools/dataset/record2.cc @@ -29,23 +29,6 @@ int main(int argc, char *argv[]) { auto &&device = device::select(); if (!device) return 1; - /* - { // auto-exposure - device->SetOptionValue(Option::EXPOSURE_MODE, 0); - device->SetOptionValue(Option::MAX_GAIN, 40); // [0.48] - device->SetOptionValue(Option::MAX_EXPOSURE_TIME, 120); // [0,240] - device->SetOptionValue(Option::DESIRED_BRIGHTNESS, 200); // [0,255] - } - { // manual-exposure - device->SetOptionValue(Option::EXPOSURE_MODE, 1); - device->SetOptionValue(Option::GAIN, 20); // [0.48] - device->SetOptionValue(Option::BRIGHTNESS, 20); // [0,240] - device->SetOptionValue(Option::CONTRAST, 20); // [0,255] - } - device->SetOptionValue(Option::IR_CONTROL, 80); - device->SetOptionValue(Option::FRAME_RATE, 25); - device->SetOptionValue(Option::IMU_FREQUENCY, 500); - */ device->InitResolution(Resolution::RES_1280x400); device->SetStreamRequest(Format::BGR888, FrameRate::RATE_30_FPS); device->LogOptionInfos(); @@ -79,17 +62,42 @@ 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()); - cv::Mat right_img( - right_frame->height(), right_frame->width(), CV_8UC1, - right_frame->data()); cv::Mat img; - cv::hconcat(left_img, right_img, img); - cv::imshow("frame", img); - { // save + if (left_frame->format() == Format::GREY) { + cv::Mat left_img( + left_frame->height(), left_frame->width(), CV_8UC1, + left_frame->data()); + cv::Mat right_img( + right_frame->height(), right_frame->width(), CV_8UC1, + right_frame->data()); + cv::hconcat(left_img, right_img, img); + } else if (left_frame->format() == Format::YUYV) { + cv::Mat left_img( + left_frame->height(), left_frame->width(), CV_8UC2, + left_frame->data()); + cv::Mat right_img( + right_frame->height(), right_frame->width(), CV_8UC2, + right_frame->data()); + 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); + } else if (left_frame->format() == Format::BGR888) { + cv::Mat left_img( + left_frame->height(), left_frame->width(), CV_8UC3, + left_frame->data()); + cv::Mat right_img( + right_frame->height(), right_frame->width(), CV_8UC3, + right_frame->data()); + cv::cvtColor(left_img, left_img, CV_BGR2RGB); + cv::cvtColor(right_img, right_img, CV_BGR2RGB); + cv::hconcat(left_img, right_img, img); + } else { + return -1; + } + cv::imshow("frame", img); + if (img_count > 10 && imu_count > 50) { // save for (auto &&left : left_datas) { dataset.SaveStreamData(Stream::LEFT, left); } @@ -125,4 +133,4 @@ int main(int argc, char *argv[]) { LOG(INFO) << "Imu count: " << imu_count << ", hz: " << (1000.f * imu_count / elapsed_ms); return 0; -} +} \ No newline at end of file