diff options
author | Stanislaw Halik <sthalik@misaki.pl> | 2023-01-27 10:29:03 +0100 |
---|---|---|
committer | Stanislaw Halik <sthalik@misaki.pl> | 2023-01-27 10:29:03 +0100 |
commit | a1973c5604cb1d8e2b58ec1dbcd26ac9b3bfa75e (patch) | |
tree | 2de992f9e9b7cde7fed37ee27e51bec58a56da3a | |
parent | 5fec54ce3a506f14f64224c3935c0b13b7512ab1 (diff) |
tracker/nn: set exposure while tracking
-rw-r--r-- | tracker-neuralnet/ftnoir_tracker_neuralnet.cpp | 2 | ||||
-rw-r--r-- | video-opencv/impl-camera.cpp | 22 | ||||
-rw-r--r-- | video-opencv/impl.hpp | 2 |
3 files changed, 20 insertions, 6 deletions
diff --git a/tracker-neuralnet/ftnoir_tracker_neuralnet.cpp b/tracker-neuralnet/ftnoir_tracker_neuralnet.cpp index cbfb3496..864431b9 100644 --- a/tracker-neuralnet/ftnoir_tracker_neuralnet.cpp +++ b/tracker-neuralnet/ftnoir_tracker_neuralnet.cpp @@ -786,11 +786,13 @@ NeuralNetDialog::NeuralNetDialog() : void NeuralNetDialog::save() { settings_.b->save(); + cs_.b->save(); } void NeuralNetDialog::reload() { settings_.b->reload(); + cs_.b->reload(); } void NeuralNetDialog::doOK() diff --git a/video-opencv/impl-camera.cpp b/video-opencv/impl-camera.cpp index 9e749d75..60a713d1 100644 --- a/video-opencv/impl-camera.cpp +++ b/video-opencv/impl-camera.cpp @@ -31,6 +31,19 @@ bool cam::is_open() return !!cap; } +void cam::set_exposure() +{ + auto e = *s.exposure_preset; + if (e != exposure) + switch (e) + { + case exposure_preset::near: cap->set(cv::CAP_PROP_EXPOSURE, -5); qDebug() << "near"; break; + case exposure_preset::far: cap->set(cv::CAP_PROP_EXPOSURE, -4); qDebug() << "far"; break; + default: break; + } + exposure = e; +} + bool cam::start(info& args) { stop(); @@ -51,13 +64,8 @@ bool cam::start(info& args) { cap->set(cv::CAP_PROP_AUTO_EXPOSURE, 0); //cap->set(cv::CAP_PROP_SHARPNESS, 0); - switch (s.exposure_preset) - { - case exposure_preset::near: cap->set(cv::CAP_PROP_EXPOSURE, -5); break; - case exposure_preset::far: cap->set(cv::CAP_PROP_EXPOSURE, -4); break; - default: break; - } } + set_exposure(); if (!cap->isOpened()) goto fail; @@ -77,6 +85,8 @@ bool cam::get_frame_() if (!is_open()) return false; + set_exposure(); + for (unsigned i = 0; i < 10; i++) { if (cap->read(mat)) diff --git a/video-opencv/impl.hpp b/video-opencv/impl.hpp index 88ae069d..c142e2a5 100644 --- a/video-opencv/impl.hpp +++ b/video-opencv/impl.hpp @@ -44,6 +44,7 @@ static constexpr int video_capture_backend = bool is_open() override; std::tuple<const frame&, bool> get_frame() override; bool show_dialog() override; + void set_exposure(); bool get_frame_(); @@ -53,6 +54,7 @@ static constexpr int video_capture_backend = cv::Mat mat; frame frame_; int idx = -1; + exposure_preset exposure = exposure_preset::ignored; }; } // ns opencv_camera_impl |