강세희

[UPDATE] 선정된 객체 좌표값 이용해 겹친 부분 구하고 여러 객체를 담은 프레임 output3로 출력

......@@ -151,17 +151,54 @@ if __name__ == '__main__':
coordiList[minCordi] = 99999
minCordi = coordiList.index(min(coordiList))
second = indexList[minCordi]
print(first, second)
bestList[key] = [detectionInfo[first][1:], detectionInfo[second][1:]]
# beOverlap 에서 선정된 두 객체의 top, left, right, bottom 값 비교하여 두 객체의 합산 size 계산, 이를 overlapped에 저장
# 이 때, value는 항상 두 가지 값만을 가짐
#for key, value in bestList.items():
# a_top, a_left, a_right, a_bottom = value[0][4:]
# b_top, b_left, b_right, b_bottom = value[1][4:]
deleteList = []
for key, value in bestList.items():
a_top, a_left, a_right, a_bottom = value[0][3:]
b_top, b_left, b_right, b_bottom = value[1][3:]
o_top, o_left, o_right, o_bottom = 0, 0, 0, 0
isOverlapped = False
if a_top < b_top < a_bottom or b_top < a_top < b_bottom or a_left < b_left < a_right or b_left < a_left < b_right:
isOverlapped = True
o_top = max(a_top, b_top)
o_bottom = min(a_bottom, b_bottom)
o_left = max(a_left, b_left)
o_right = min(a_right, b_right)
o_size = (o_bottom-o_top)*(o_right-o_left)
if isOverlapped == True:
a_object = Point2D(width= (a_top + a_bottom)//2, height=(a_left + a_right)//2)
b_object = Point2D(width= (b_top + b_bottom)//2, height=(b_left + b_right)//2)
o_object = Point2D(width=(a_object.width+b_object.width)//2 , height = (a_object.height + b_object.height)//2)
toTheOrigin_w = image.shape[1] / 2 - o_object.width
toTheOrigin_h = image.shape[0] / 2 - o_object.height
coordiValue_object = int(math.sqrt((toTheOrigin_w ** 2) + (toTheOrigin_h ** 2)))
bestList[key] = [value[0][0] + ", "+ value[1][0], value[0][1]+value[1][1]-o_size, coordiValue_object]
else:
deleteList.append(key)
for i in range(len(deleteList)):
del bestList[deleteList[i]]
namelist.clear()
# 정리된 검출 리스트 output3 에 출력
# 검출된 리스트 중 limitSize를 넘으며, 가장 중앙에 가까운 객체 선출
limitSize = 100000
for key, value in bestList.items():
if value[1] > limitSize:
if value[0] in namelist:
if value[2] < namelist[value[0]][2]:
namelist[value[0]] = [key] + value[1:]
else:
namelist[value[0]] = [key] + value[1:]
# output3에 출력
for objectname, framelist in namelist.items():
image = cv2.imread("mid/frame%d.png" % framelist[0])
output3 = cv2.GaussianBlur(image, (5, 5), 0)
cv2.imwrite("output3/%s.png" % (objectname), output3)
......