From 14db8f3384e72d10952da882cd0dc111c582cc45 Mon Sep 17 00:00:00 2001
From: AlexeyAB <alexeyab84@gmail.com>
Date: Mon, 12 Feb 2018 19:36:52 +0000
Subject: [PATCH] Added linear extrapolation of coordinates

---
 src/yolo_v2_class.hpp |   12 +++++++-----
 1 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/src/yolo_v2_class.hpp b/src/yolo_v2_class.hpp
index 1eaafb8..5aa3631 100644
--- a/src/yolo_v2_class.hpp
+++ b/src/yolo_v2_class.hpp
@@ -144,8 +144,8 @@
 };
 
 
-#ifdef OPENCV
-#ifdef TRACK_OPTFLOW
+
+#if defined(TRACK_OPTFLOW) && defined(OPENCV)
 
 #include <opencv2/cudaoptflow.hpp>
 #include <opencv2/cudaimgproc.hpp>
@@ -297,7 +297,8 @@
 				float moved_y = cur_key_pt.y - prev_key_pt.y;
 
 				if (abs(moved_x) < 100 && abs(moved_y) < 100 && good_bbox_vec_flags[i])
-					if (err_cpu.at<float>(0, i) < flow_error && status_cpu.at<unsigned char>(0, i) != 0)
+					if (err_cpu.at<float>(0, i) < flow_error && status_cpu.at<unsigned char>(0, i) != 0 &&
+						((float)cur_bbox_vec[i].x + moved_x) > 0 && ((float)cur_bbox_vec[i].y + moved_y) > 0)
 					{
 						cur_bbox_vec[i].x += moved_x + 0.5;
 						cur_bbox_vec[i].y += moved_y + 0.5;
@@ -324,9 +325,11 @@
 
 class Tracker_optflow {};
 
-#endif	// TRACK_OPTFLOW
+#endif	// defined(TRACK_OPTFLOW) && defined(OPENCV)
 
 
+#ifdef OPENCV
+
 cv::Scalar obj_id_to_color(int obj_id) {
 	int const colors[6][3] = { { 1,0,1 },{ 0,0,1 },{ 0,1,1 },{ 0,1,0 },{ 1,1,0 },{ 1,0,0 } };
 	int const offset = obj_id * 123457 % 6;
@@ -469,4 +472,3 @@
 	}
 };
 #endif	// OPENCV
-

--
Gitblit v1.10.0