강세희

[UPDATE] 기존 코드 수정

1 1
2 import time 2 import time
3 +import math
3 import cv2 4 import cv2
4 import numpy as np 5 import numpy as np
5 from model.yolo_model import YOLO 6 from model.yolo_model import YOLO
6 7
8 +class Point2D:
9 + def __init__(self, width, height):
10 + self.width = width
11 + self.height = height
7 12
8 def process_image(img): 13 def process_image(img):
9 image = cv2.resize(img, (416, 416), 14 image = cv2.resize(img, (416, 416),
...@@ -53,7 +58,11 @@ if __name__ == '__main__': ...@@ -53,7 +58,11 @@ if __name__ == '__main__':
53 name = all_classes[cl] 58 name = all_classes[cl]
54 size = w*h 59 size = w*h
55 # 얼마나 가운데인지 확인하는 알고리즘 60 # 얼마나 가운데인지 확인하는 알고리즘
56 - coordinatevalue = abs((x+0.5*w)-image.shape[1]/2) + abs((y-h*0.5)-image.shape[0]/2)/(image.shape[0]/image.shape[1]) 61 +
62 + object = Point2D(width= x + 0.5 * w , height= y - h * 0.5)
63 + a = image.shape[1]/2 - object.width
64 + b = image.shape[0]/2 - object.height
65 + coordinatevalue = math.sqrt((a*a)+(b*b))
57 detectionInfo.append([i, name, size, coordinatevalue]) 66 detectionInfo.append([i, name, size, coordinatevalue])
58 67
59 # name 별로 크기가 가장 크거나 물체가 프레임의 가운데 있는 프레임 번호 목록 얻어오기 68 # name 별로 크기가 가장 크거나 물체가 프레임의 가운데 있는 프레임 번호 목록 얻어오기
......