Showing
4 changed files
with
42 additions
and
5 deletions
codes/Project/output3/bicycle, motorbike.png
0 → 100644
599 KB
codes/Project/output3/person, bicycle.png
0 → 100644
617 KB
codes/Project/output3/person, person.png
0 → 100644
941 KB
... | @@ -151,17 +151,54 @@ if __name__ == '__main__': | ... | @@ -151,17 +151,54 @@ if __name__ == '__main__': |
151 | coordiList[minCordi] = 99999 | 151 | coordiList[minCordi] = 99999 |
152 | minCordi = coordiList.index(min(coordiList)) | 152 | minCordi = coordiList.index(min(coordiList)) |
153 | second = indexList[minCordi] | 153 | second = indexList[minCordi] |
154 | - print(first, second) | ||
155 | bestList[key] = [detectionInfo[first][1:], detectionInfo[second][1:]] | 154 | bestList[key] = [detectionInfo[first][1:], detectionInfo[second][1:]] |
156 | 155 | ||
157 | # beOverlap 에서 선정된 두 객체의 top, left, right, bottom 값 비교하여 두 객체의 합산 size 계산, 이를 overlapped에 저장 | 156 | # beOverlap 에서 선정된 두 객체의 top, left, right, bottom 값 비교하여 두 객체의 합산 size 계산, 이를 overlapped에 저장 |
158 | # 이 때, value는 항상 두 가지 값만을 가짐 | 157 | # 이 때, value는 항상 두 가지 값만을 가짐 |
159 | - #for key, value in bestList.items(): | 158 | + deleteList = [] |
160 | - # a_top, a_left, a_right, a_bottom = value[0][4:] | 159 | + for key, value in bestList.items(): |
161 | - # b_top, b_left, b_right, b_bottom = value[1][4:] | 160 | + a_top, a_left, a_right, a_bottom = value[0][3:] |
161 | + b_top, b_left, b_right, b_bottom = value[1][3:] | ||
162 | + o_top, o_left, o_right, o_bottom = 0, 0, 0, 0 | ||
163 | + isOverlapped = False | ||
164 | + 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: | ||
165 | + isOverlapped = True | ||
166 | + o_top = max(a_top, b_top) | ||
167 | + o_bottom = min(a_bottom, b_bottom) | ||
168 | + o_left = max(a_left, b_left) | ||
169 | + o_right = min(a_right, b_right) | ||
170 | + | ||
171 | + o_size = (o_bottom-o_top)*(o_right-o_left) | ||
172 | + if isOverlapped == True: | ||
173 | + a_object = Point2D(width= (a_top + a_bottom)//2, height=(a_left + a_right)//2) | ||
174 | + b_object = Point2D(width= (b_top + b_bottom)//2, height=(b_left + b_right)//2) | ||
175 | + o_object = Point2D(width=(a_object.width+b_object.width)//2 , height = (a_object.height + b_object.height)//2) | ||
176 | + toTheOrigin_w = image.shape[1] / 2 - o_object.width | ||
177 | + toTheOrigin_h = image.shape[0] / 2 - o_object.height | ||
178 | + coordiValue_object = int(math.sqrt((toTheOrigin_w ** 2) + (toTheOrigin_h ** 2))) | ||
179 | + bestList[key] = [value[0][0] + ", "+ value[1][0], value[0][1]+value[1][1]-o_size, coordiValue_object] | ||
180 | + else: | ||
181 | + deleteList.append(key) | ||
182 | + for i in range(len(deleteList)): | ||
183 | + del bestList[deleteList[i]] | ||
162 | 184 | ||
185 | + namelist.clear() | ||
163 | 186 | ||
164 | - # 정리된 검출 리스트 output3 에 출력 | 187 | + # 검출된 리스트 중 limitSize를 넘으며, 가장 중앙에 가까운 객체 선출 |
188 | + limitSize = 100000 | ||
189 | + for key, value in bestList.items(): | ||
190 | + if value[1] > limitSize: | ||
191 | + if value[0] in namelist: | ||
192 | + if value[2] < namelist[value[0]][2]: | ||
193 | + namelist[value[0]] = [key] + value[1:] | ||
194 | + else: | ||
195 | + namelist[value[0]] = [key] + value[1:] | ||
196 | + | ||
197 | + # output3에 출력 | ||
198 | + for objectname, framelist in namelist.items(): | ||
199 | + image = cv2.imread("mid/frame%d.png" % framelist[0]) | ||
200 | + output3 = cv2.GaussianBlur(image, (5, 5), 0) | ||
201 | + cv2.imwrite("output3/%s.png" % (objectname), output3) | ||
165 | 202 | ||
166 | 203 | ||
167 | 204 | ... | ... |
-
Please register or login to post a comment