From 551c73068f43da1dece0feae8d8a795f0f3726b7 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Fri, 19 Jun 2015 10:02:23 +0200 Subject: pt: remove hysteresis No one used it, and we have a better solution for stable extraction, pending commit. --- ftnoir_tracker_pt/FTNoIR_PT_Controls.ui | 96 ++++++++------------------ ftnoir_tracker_pt/ftnoir_tracker_pt_dialog.cpp | 1 - ftnoir_tracker_pt/ftnoir_tracker_pt_settings.h | 2 - ftnoir_tracker_pt/point_extractor.cpp | 40 +---------- ftnoir_tracker_pt/point_extractor.h | 1 - 5 files changed, 31 insertions(+), 109 deletions(-) (limited to 'ftnoir_tracker_pt') diff --git a/ftnoir_tracker_pt/FTNoIR_PT_Controls.ui b/ftnoir_tracker_pt/FTNoIR_PT_Controls.ui index 0e6048c3..39fb0686 100644 --- a/ftnoir_tracker_pt/FTNoIR_PT_Controls.ui +++ b/ftnoir_tracker_pt/FTNoIR_PT_Controls.ui @@ -259,19 +259,6 @@ Point extraction - - - - Minimum point diameter - - - px - - - 1024 - - - @@ -297,81 +284,59 @@ - - - - Maximum point diameter - - - px + + + + Min size - - 1024 + + mindiam_spin - - + + - Max size + Threshold - maxdiam_spin + threshold_slider - - + + - Per pixel hysteresis width (leave left if there is little difference between dot and non-dot, move right for increased stability against pixel noise) - - - 255 - - - 1 - - - 100 - - - Qt::Horizontal + Minimum point diameter - - QSlider::TicksBothSides + + px - - 25 + + 1024 - - + + - Threshold + Max size - threshold_slider + maxdiam_spin - - - - Hysteresis - - - threshold_secondary_slider + + + + Maximum point diameter - - - - - - Min size + + px - - mindiam_spin + + 1024 @@ -1150,9 +1115,6 @@ fps_spin fov threshold_slider - mindiam_spin - threshold_secondary_slider - maxdiam_spin model_tabs clip_tlength_spin clip_theight_spin diff --git a/ftnoir_tracker_pt/ftnoir_tracker_pt_dialog.cpp b/ftnoir_tracker_pt/ftnoir_tracker_pt_dialog.cpp index 86178cb3..e7f1384d 100644 --- a/ftnoir_tracker_pt/ftnoir_tracker_pt_dialog.cpp +++ b/ftnoir_tracker_pt/ftnoir_tracker_pt_dialog.cpp @@ -44,7 +44,6 @@ TrackerDialog_PT::TrackerDialog_PT() tie_setting(s.cam_res_y, ui.res_y_spin); tie_setting(s.cam_fps, ui.fps_spin); - tie_setting(s.threshold_secondary, ui.threshold_secondary_slider); tie_setting(s.threshold, ui.threshold_slider); tie_setting(s.min_point_size, ui.mindiam_spin); diff --git a/ftnoir_tracker_pt/ftnoir_tracker_pt_settings.h b/ftnoir_tracker_pt/ftnoir_tracker_pt_settings.h index 14786013..4e241bc3 100644 --- a/ftnoir_tracker_pt/ftnoir_tracker_pt_settings.h +++ b/ftnoir_tracker_pt/ftnoir_tracker_pt_settings.h @@ -18,7 +18,6 @@ struct settings_pt : opts cam_res_y, cam_fps, threshold, - threshold_secondary, min_point_size, max_point_size; @@ -41,7 +40,6 @@ struct settings_pt : opts cam_res_y(b, "camera-res-height", 480), cam_fps(b, "camera-fps", 30), threshold(b, "threshold-primary", 128), - threshold_secondary(b, "threshold-secondary", 128), min_point_size(b, "min-point-size", 10), max_point_size(b, "max-point-size", 50), m01_x(b, "m_01-x", 0), diff --git a/ftnoir_tracker_pt/point_extractor.cpp b/ftnoir_tracker_pt/point_extractor.cpp index 5f7f6829..dab1d967 100644 --- a/ftnoir_tracker_pt/point_extractor.cpp +++ b/ftnoir_tracker_pt/point_extractor.cpp @@ -25,51 +25,15 @@ std::vector PointExtractor::extract_points(Mat& frame) const int W = frame.cols; const int H = frame.rows; - if (frame_last.cols != W || frame_last.rows != H) - { - frame_last = cv::Mat(); - } - // convert to grayscale Mat frame_gray; cvtColor(frame, frame_gray, cv::COLOR_RGB2GRAY); - int secondary = s.threshold_secondary; - int primary = s.threshold; - // mask for everything that passes the threshold (or: the upper threshold of the hysteresis) Mat frame_bin; - // only used if draw_output - Mat frame_bin_copy; - // mask for everything that passes - Mat frame_bin_low; - // mask for lower-threshold && combined result of last, needs to remain in scope until drawing, but is only used if secondary != 0 - Mat frame_last_and_low; - - if(secondary==0){ - threshold(frame_gray, frame_bin, primary, 255, THRESH_BINARY); - }else{ - // we recombine a number of buffers, this might be slower than a single loop of per-pixel logic - // but it might as well be faster if openCV makes good use of SIMD - float t = primary; - //float hyst = float(threshold_secondary_val)/512.; - //threshold(frame_gray, frame_bin, (t + ((255.-t)*hyst)), 255, THRESH_BINARY); - float hyst = float(primary)/(256.*8.); - threshold(frame_gray, frame_bin, t, 255, THRESH_BINARY); - threshold(frame_gray, frame_bin_low,std::max(float(1), t - (t*hyst)), 255, THRESH_BINARY); - frame_bin.copyTo(frame_bin_copy); - if(frame_last.empty()){ - frame_bin.copyTo(frame_last); - }else{ - // keep pixels from last if they are above lower threshold - bitwise_and(frame_last, frame_bin_low, frame_last_and_low); - // union of pixels >= higher threshold and pixels >= lower threshold - bitwise_or(frame_bin, frame_last_and_low, frame_last); - frame_last.copyTo(frame_bin); - } - } - + threshold(frame_gray, frame_bin, s.threshold, 255, THRESH_BINARY); + int min_size = s.min_point_size; int max_size = s.max_point_size; diff --git a/ftnoir_tracker_pt/point_extractor.h b/ftnoir_tracker_pt/point_extractor.h index 3f6cfb72..b9368ab6 100644 --- a/ftnoir_tracker_pt/point_extractor.h +++ b/ftnoir_tracker_pt/point_extractor.h @@ -28,7 +28,6 @@ public: settings_pt s; private: std::vector points; - cv::Mat frame_last; }; #endif //POINTEXTRACTOR_H -- cgit v1.2.3