Loading src/car_target.py +4 −2 Changes for src/car_target.py: 4 added lines, 2 removed lines. Original line number Diff line number Diff line Loading @@ -219,11 +219,13 @@ if __name__ == "__main__": # app = ImgCarTargetApp(color=BarColor.BLUE, folder="/home/jeeken/Pictures/blue", # frame_size=(640, 480), ext_name="jpg", debug=True) app = ImgCarTargetApp(color=BarColor.BLUE, folder="/home/jeeken/Pictures/blue_dark", frame_size=(640, 480), ext_name="jpg", debug=True) # app = ImgCarTargetApp(color=BarColor.RED, folder="/home/jeeken/Pictures/red_dark", # frame_size=(640, 480), ext_name="jpg", debug=True) app = VideoCarTargetApp(file="/home/jeeken/Videos/live_blue.avi", color=BarColor.BLUE, frame_size=(640, 480), debug=False) # app = VideoCarTargetApp(file="/home/jeeken/Videos/live_blue.avi", # color=BarColor.BLUE, frame_size=(640, 480), debug=False) # app = VideoCarTargetApp(file="/home/jeeken/Videos/red.avi", # color=BarColor.RED, frame_size=(640, 480), debug=False) app.run() src/detector.py +4 −6 Changes for src/detector.py: 4 added lines, 6 removed lines. Original line number Diff line number Diff line Loading @@ -76,10 +76,9 @@ class Detector: self.add_debug_img("Red to Blue", cv2.cvtColor(hsv_frame, cv2.COLOR_HSV2BGR)) # TODO: decide the range of lightness based on histogram # lower_light = np.array([90, 0, 180]) lower_light = np.array([90, 0, 200]) upper_light = np.array([120, 130, 255]) lower_halo = np.array([90, 100, 185]) upper_light = np.array([120, 200, 255]) lower_halo = np.array([90, 120, 185]) upper_halo = np.array([120, 255, 255]) # lower_light = np.array([90, 0, 185]) # upper_light = np.array([120, 230, 255]) Loading Loading @@ -116,8 +115,7 @@ class Detector: if len(selected_contours) > 0: combined_halo_points = np.concatenate(selected_contours) original_center, original_radius = cv2.minEnclosingCircle(combined_halo_points) x, y = original_center center = round(x), round(y - original_radius * 0.6) # shift up center = round_point(original_center) # zoom if original_radius > width / 4: Loading Loading @@ -220,6 +218,7 @@ class Detector: judge_results = [(pair, judge(pair)) for pair in pairs] (i1, i2), winner_score = min(judge_results, key=lambda x: x[1]) self.debug_print("score:", winner_score) if winner_score > 7: return None Loading @@ -234,7 +233,6 @@ class Detector: # self.debug_print("shape_similarity:", 5 * size_similarity(l1, l2)) # self.debug_print("square_ratio:", 5 * square_ratio(l1, l2)) # self.debug_print("y_dis:", 20 * y_dis(l1, l2)) self.debug_print("score:", winner_score) c1, s1, a1 = l1 c2, s2, a2 = l2 cv2.drawMarker(selected_pair_show, position=round_point(c1), color=BGR_GREEN, markerSize=15, thickness=2) Loading Loading
src/car_target.py +4 −2 Changes for src/car_target.py: 4 added lines, 2 removed lines. Original line number Diff line number Diff line Loading @@ -219,11 +219,13 @@ if __name__ == "__main__": # app = ImgCarTargetApp(color=BarColor.BLUE, folder="/home/jeeken/Pictures/blue", # frame_size=(640, 480), ext_name="jpg", debug=True) app = ImgCarTargetApp(color=BarColor.BLUE, folder="/home/jeeken/Pictures/blue_dark", frame_size=(640, 480), ext_name="jpg", debug=True) # app = ImgCarTargetApp(color=BarColor.RED, folder="/home/jeeken/Pictures/red_dark", # frame_size=(640, 480), ext_name="jpg", debug=True) app = VideoCarTargetApp(file="/home/jeeken/Videos/live_blue.avi", color=BarColor.BLUE, frame_size=(640, 480), debug=False) # app = VideoCarTargetApp(file="/home/jeeken/Videos/live_blue.avi", # color=BarColor.BLUE, frame_size=(640, 480), debug=False) # app = VideoCarTargetApp(file="/home/jeeken/Videos/red.avi", # color=BarColor.RED, frame_size=(640, 480), debug=False) app.run()
src/detector.py +4 −6 Changes for src/detector.py: 4 added lines, 6 removed lines. Original line number Diff line number Diff line Loading @@ -76,10 +76,9 @@ class Detector: self.add_debug_img("Red to Blue", cv2.cvtColor(hsv_frame, cv2.COLOR_HSV2BGR)) # TODO: decide the range of lightness based on histogram # lower_light = np.array([90, 0, 180]) lower_light = np.array([90, 0, 200]) upper_light = np.array([120, 130, 255]) lower_halo = np.array([90, 100, 185]) upper_light = np.array([120, 200, 255]) lower_halo = np.array([90, 120, 185]) upper_halo = np.array([120, 255, 255]) # lower_light = np.array([90, 0, 185]) # upper_light = np.array([120, 230, 255]) Loading Loading @@ -116,8 +115,7 @@ class Detector: if len(selected_contours) > 0: combined_halo_points = np.concatenate(selected_contours) original_center, original_radius = cv2.minEnclosingCircle(combined_halo_points) x, y = original_center center = round(x), round(y - original_radius * 0.6) # shift up center = round_point(original_center) # zoom if original_radius > width / 4: Loading Loading @@ -220,6 +218,7 @@ class Detector: judge_results = [(pair, judge(pair)) for pair in pairs] (i1, i2), winner_score = min(judge_results, key=lambda x: x[1]) self.debug_print("score:", winner_score) if winner_score > 7: return None Loading @@ -234,7 +233,6 @@ class Detector: # self.debug_print("shape_similarity:", 5 * size_similarity(l1, l2)) # self.debug_print("square_ratio:", 5 * square_ratio(l1, l2)) # self.debug_print("y_dis:", 20 * y_dis(l1, l2)) self.debug_print("score:", winner_score) c1, s1, a1 = l1 c2, s2, a2 = l2 cv2.drawMarker(selected_pair_show, position=round_point(c1), color=BGR_GREEN, markerSize=15, thickness=2) Loading