From c2bf1a40317199b0aa07b21945b78961cfa08953 Mon Sep 17 00:00:00 2001 From: Ouhouuhu <40174296+Ouhouuhu@users.noreply.github.com> Date: Tue, 28 Feb 2023 16:33:34 +0100 Subject: [PATCH] rotate image --- .../TensorFlow-2.x-YOLOv3-master/detection_custom.py | 4 ++-- .../Yolo V3/TensorFlow-2.x-YOLOv3-master/yolov3/utils.py | 9 +++++---- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/PAR 152/Yolo V3/TensorFlow-2.x-YOLOv3-master/detection_custom.py b/PAR 152/Yolo V3/TensorFlow-2.x-YOLOv3-master/detection_custom.py index d0b0931..85cb50e 100644 --- a/PAR 152/Yolo V3/TensorFlow-2.x-YOLOv3-master/detection_custom.py +++ b/PAR 152/Yolo V3/TensorFlow-2.x-YOLOv3-master/detection_custom.py @@ -20,9 +20,9 @@ image_path = "./Calibration_cam/2m.jpg" video_path = "./IMAGES/test.mp4" yolo = Load_Yolo_model() -_, boxes = detect_image(yolo, image_path, "./Calibration_cam/0.5_detect.jpg", input_size=YOLO_INPUT_SIZE, show=True, CLASSES=TRAIN_CLASSES, rectangle_colors=(255,0,0)) +#_, boxes = detect_image(yolo, image_path, "./Calibration_cam/0.5_detect.jpg", input_size=YOLO_INPUT_SIZE, show=True, CLASSES=TRAIN_CLASSES, rectangle_colors=(255,0,0)) #detect_video(yolo, video_path, './IMAGES/detected.mp4', input_size=YOLO_INPUT_SIZE, show=False, CLASSES=TRAIN_CLASSES, rectangle_colors=(255,0,0)) -#detect_realtime(yolo, '', input_size=YOLO_INPUT_SIZE, show=True, CLASSES=TRAIN_CLASSES, rectangle_colors=(255, 0, 0)) +detect_realtime(yolo, '', input_size=YOLO_INPUT_SIZE, show=True, CLASSES=TRAIN_CLASSES, rectangle_colors=(255, 0, 0)) #detect_video_realtime_mp(video_path, "Output.mp4", input_size=YOLO_INPUT_SIZE, show=True, CLASSES=TRAIN_CLASSES, rectangle_colors=(255,0,0), realtime=False) diff --git a/PAR 152/Yolo V3/TensorFlow-2.x-YOLOv3-master/yolov3/utils.py b/PAR 152/Yolo V3/TensorFlow-2.x-YOLOv3-master/yolov3/utils.py index afdd82e..aa5ab48 100644 --- a/PAR 152/Yolo V3/TensorFlow-2.x-YOLOv3-master/yolov3/utils.py +++ b/PAR 152/Yolo V3/TensorFlow-2.x-YOLOv3-master/yolov3/utils.py @@ -210,7 +210,7 @@ def draw_bbox(image, bboxes,liste_pos_car=liste_pos((0,0,0),1), CLASSES=YOLO_COC """x_car, y_car""" x_car, y_car = pos_car[0], pos_car[1] print(f"x: {x_car}, y: {y_car}") - x_car, y_car = (x_car-1.23855)/2.4+1, (y_car-0.889)/2.4+0.5 + x_car, y_car = (x_car-278/225)/2.4+1, (y_car-200/225)/2.4+0.5 print(f"recalé x: {x_car}, y: {y_car}") """loading trajectory"""#TODO: load it only once @@ -219,7 +219,7 @@ def draw_bbox(image, bboxes,liste_pos_car=liste_pos((0,0,0),1), CLASSES=YOLO_COC plt.plot(x_car, y_car,'+') for x,y in zip(cone_x, cone_y): - x, y= (x-1.23855)/2.4+1, (y-0.889)/2.4+0.5 + x, y= (x--278/225)/2.4+1, (y-200/225)/2.4+0.5 plt.plot(x,y,'*') plt.plot([i for i,j in track_points], [j for i,j in track_points]) plt.show() @@ -589,7 +589,7 @@ def detect_realtime(Yolo, output_path, input_size=416, show=False, CLASSES=YOLO_ codec = cv2.VideoWriter_fourcc(*'XVID') out = cv2.VideoWriter(output_path, codec, fps, (width, height)) # output_path must be .mp4 - liste_pos_car = liste_pos((1, 0.5,3.1415/2), 50) + liste_pos_car = liste_pos((278/225, 200/225,3.1415/2), 50) ser = get_ser() start_ser(ser) @@ -598,7 +598,8 @@ def detect_realtime(Yolo, output_path, input_size=416, show=False, CLASSES=YOLO_ while True: ret, frame = vid.read() - + frame = np.rot90(frame, k=3, axes=(0, 1)) + try: original_frame = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB) original_frame = cv2.cvtColor(original_frame, cv2.COLOR_BGR2RGB) -- GitLab