Commit e14d7ff7 authored by Ziqin Wang's avatar Ziqin Wang Committed by Jeeken
Browse files

halo center shift deleted; binarization parameters adjusted

parent df06ae49
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
@@ -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()
+4 −6
Original line number Diff line number Diff line
@@ -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])
@@ -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:
@@ -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
@@ -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)