From 5f3126dd862c93e3a514dcf0910d24b840f7e90c Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sat, 14 Dec 2013 15:24:29 +0100 Subject: pt: don't crash since hysteresis support Reported-by: runningman84 GitHub: issue #15 --- FTNoIR_Tracker_PT/point_extractor.cpp | 10 +++++----- FTNoIR_Tracker_PT/point_extractor.h | 3 --- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/FTNoIR_Tracker_PT/point_extractor.cpp b/FTNoIR_Tracker_PT/point_extractor.cpp index 27a14713..d9ff0a5b 100644 --- a/FTNoIR_Tracker_PT/point_extractor.cpp +++ b/FTNoIR_Tracker_PT/point_extractor.cpp @@ -14,9 +14,6 @@ using namespace std; PointExtractor::PointExtractor(){ - first = true; - - //if (!AllocConsole()){} //else SetConsoleTitle("debug"); //freopen("CON", "w", stdout); @@ -28,6 +25,10 @@ const vector& PointExtractor::extract_points(Mat frame, float dt, bool dr const int W = frame.cols; const int H = frame.rows; + if (frame_last.cols != W || frame_last.rows != H) + { + frame_last = cv::Mat(); + } // clear old points points.clear(); @@ -60,9 +61,8 @@ const vector& PointExtractor::extract_points(Mat frame, float dt, bool dr threshold(frame_gray, frame_bin_low,std::max(float(1), t - (t*hyst)), 255, THRESH_BINARY); if(draw_output) frame_bin.copyTo(frame_bin_copy); - if(first){ + if(frame_last.empty()){ frame_bin.copyTo(frame_last); - first = false; }else{ // keep pixels from last if they are above lower threshold bitwise_and(frame_last, frame_bin_low, frame_last_and_low); diff --git a/FTNoIR_Tracker_PT/point_extractor.h b/FTNoIR_Tracker_PT/point_extractor.h index b9f46666..ff36f3ce 100644 --- a/FTNoIR_Tracker_PT/point_extractor.h +++ b/FTNoIR_Tracker_PT/point_extractor.h @@ -30,9 +30,6 @@ public: protected: std::vector points; cv::Mat frame_last; - - - bool first; }; #endif //POINTEXTRACTOR_H -- cgit v1.2.3