mirror of
https://github.com/NohamR/Stage-2023.git
synced 2026-01-10 16:18:14 +00:00
changes
This commit is contained in:
|
Before Width: | Height: | Size: 324 KiB After Width: | Height: | Size: 324 KiB |
|
Before Width: | Height: | Size: 324 KiB After Width: | Height: | Size: 324 KiB |
40
detec/deformation.py
Normal file
40
detec/deformation.py
Normal file
@@ -0,0 +1,40 @@
|
||||
import cv2
|
||||
import numpy as np
|
||||
|
||||
|
||||
frame_width = 1280
|
||||
frame_height = 720
|
||||
|
||||
size = (frame_width, frame_height)
|
||||
|
||||
result = cv2.VideoWriter('deformed.avi', cv2.VideoWriter_fourcc(*'XVID'), 30, size)
|
||||
|
||||
video_path = 'cams/new/cut2.mp4'
|
||||
cap = cv2.VideoCapture(video_path)
|
||||
|
||||
source_points = np.float32([[129, 379], [658, 332], [251, 551], [916, 445]])
|
||||
|
||||
destination_points = np.float32([[200, 350], [800, 350], [200, 600], [800, 600]])
|
||||
|
||||
M = cv2.getPerspectiveTransform(source_points, destination_points)
|
||||
|
||||
while cap.isOpened():
|
||||
ret, frame = cap.read()
|
||||
if not ret:
|
||||
break
|
||||
|
||||
transformed_frame = cv2.warpPerspective(frame, M, (frame.shape[1], frame.shape[0]))
|
||||
|
||||
# cv2.imshow('Vue de destination', cv2.resize(frame, (1280, 720)))
|
||||
|
||||
result.write(cv2.resize(transformed_frame, (1280, 720)))
|
||||
cv2.imshow('Vue de destination', cv2.resize(transformed_frame, (1280, 720)))
|
||||
|
||||
if cv2.waitKey(1) & 0xFF == ord('q'):
|
||||
break
|
||||
|
||||
|
||||
cap.release()
|
||||
result.release()
|
||||
cv2.destroyAllWindows()
|
||||
print("The video was successfully saved")
|
||||
@@ -4,7 +4,7 @@ import numpy as np
|
||||
import cv2
|
||||
import time
|
||||
|
||||
cap = cv2.VideoCapture('cams/10s.mp4')
|
||||
cap = cv2.VideoCapture('cams/2/10s.mp4')
|
||||
folder_path = "track/exp2/labels/"
|
||||
name = '10s'
|
||||
fps = 141
|
||||
@@ -41,6 +41,11 @@ while(cap.isOpened()):
|
||||
bottom_right_y = int(center_y + bbox_height / 2)
|
||||
|
||||
cv2.rectangle(frame, (top_left_x, top_left_y), (bottom_right_x, bottom_right_y), (255, 0, 0), 2)
|
||||
|
||||
# print('bottom_right_y: ', bottom_right_y)
|
||||
# print('bottom_right_x: ', bottom_right_x)
|
||||
# print('top_left_y: ', top_left_y)
|
||||
# print('top_left_x: ', top_left_x)
|
||||
|
||||
label = f'Class: {int(class_id)}, Object ID: {int(object_id)}'
|
||||
cv2.putText(frame, label, (top_left_x, top_left_y - 5), cv2.FONT_HERSHEY_SIMPLEX, 0.5, (255, 0, 0), 1)
|
||||
|
||||
@@ -4,7 +4,7 @@ import numpy as np
|
||||
import cv2
|
||||
import time
|
||||
|
||||
cap = cv2.VideoCapture('cams/new/cut1.mp4')
|
||||
cap = cv2.VideoCapture('cams/new/ByED80IKdIU_06.mp4')
|
||||
folder_path = "cams/new/frames"
|
||||
|
||||
frame_nb = 0
|
||||
|
||||
Reference in New Issue
Block a user