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 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'FTNoIR_Tracker_PT/point_extractor.cpp') 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); -- cgit v1.2.3