Toggle navigation
Toggle navigation
This project
Loading...
Sign in
2021-1-capstone-design2
/
2016104095
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
강세희
2021-05-03 23:57:59 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
f153fdc7d45ac89a2e5c964558473fda0a35e800
f153fdc7
1 parent
7c014e27
[UPDATE] 한 프레임에서 하나의 객체만 탐색하는 오류 수정
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
11 deletions
codes/Project/project.py
codes/Project/project.py
View file @
f153fdc
import
time
import
math
import
cv2
...
...
@@ -57,47 +56,56 @@ if __name__ == '__main__':
x
,
y
,
w
,
h
=
box
name
=
all_classes
[
cl
]
size
=
w
*
h
# 얼마나 가운데인지 확인하는 알고리즘
object
=
Point2D
(
width
=
x
+
0.5
*
w
,
height
=
y
-
h
*
0.5
)
# 얼마나 가운데인지 확인하는 알고리즘
object
=
Point2D
(
width
=
x
+
h
/
2
,
height
=
y
+
w
/
2
)
a
=
image
.
shape
[
1
]
/
2
-
object
.
width
b
=
image
.
shape
[
0
]
/
2
-
object
.
height
coordinatevalue
=
math
.
sqrt
((
a
*
a
)
+
(
b
*
b
))
detectionInfo
.
append
([
i
,
name
,
size
,
coordinatevalue
])
for
i
in
range
(
len
(
detectionInfo
)):
print
(
detectionInfo
[
i
])
# name 별로 크기가 가장 크거나 물체가 프레임의 가운데 있는 프레임 번호 목록 얻어오기
indexlist
=
[]
# 검출된 물체 리스트(중복 없이)
namelist
=
set
()
for
i
in
range
(
count
):
for
i
in
range
(
len
(
detectionInfo
)
):
namelist
.
add
(
detectionInfo
[
i
][
1
])
namelist
=
list
(
namelist
)
print
(
"namelist"
,
namelist
)
# 계획1 : 뒤 두 알고리즘 일정 비율로 합치기
# 검출된 물체 중 가장 크기가 큰 것을 불러옴
for
i
in
range
(
len
(
namelist
)):
maxindex
=
0
maxvalue
=
0
for
j
in
range
(
count
):
for
j
in
range
(
len
(
detectionInfo
)
):
if
detectionInfo
[
j
][
1
]
==
namelist
[
i
]:
# 물체 리스트 중에서
if
detectionInfo
[
j
][
2
]
>
maxvalue
:
# 가장 큰 값을 갱신한다면
maxvalue
=
detectionInfo
[
j
][
2
]
maxindex
=
j
maxindex
=
detectionInfo
[
j
][
0
]
indexlist
.
append
(
maxindex
)
# 검출된 물체 중 가장 가운데 있는 것을 불러
for
i
in
range
(
len
(
namelist
)):
minindex
=
0
minvalue
=
2000
for
j
in
range
(
count
):
minvalue
=
999999
for
j
in
range
(
len
(
detectionInfo
)
):
if
detectionInfo
[
j
][
1
]
==
namelist
[
i
]:
# 물체 리스트 중에서
if
detectionInfo
[
j
][
3
]
<
minvalue
:
# 가장 큰 값을 갱신한다면
minvalue
=
detectionInfo
[
j
][
3
]
minindex
=
j
minindex
=
detectionInfo
[
j
][
0
]
indexlist
.
append
(
minindex
)
print
(
indexlist
)
# 계획2 : 프레임별로 나온 객체 겹치는 부분 제외하고 넓이 구해 큰거 Indexlist에 넣기
# 계획3 : 객체가 특정 위치에 있는 프레임 뽑기
#얻어온 프레임 목록 결과값으로 저장, 선명도 높이는 작업 수행
for
i
in
range
(
len
(
indexlist
)):
...
...
@@ -106,5 +114,4 @@ if __name__ == '__main__':
#kernel_sharpen_1 = np.array([[-1,-1,-1],[-1,9,-1],[-1,-1,-1]])
#output2 = cv2.filter2D(output1,-1,kernel_sharpen_1)
cv2
.
imwrite
(
"output/
%
d.
%
s.png"
%
(
i
+
1
,
detectionInfo
[
indexlist
[
i
]][
1
]),
output1
);
cv2
.
imwrite
(
"output/
%
d.
%
s.png"
%
(
i
+
1
,
namelist
[
i
]),
output1
);
...
...
Please
register
or
login
to post a comment