Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Tilman Marquart
Art Structures - LME Praktikum
Commits
9c8b40f5
Unverified
Commit
9c8b40f5
authored
Dec 09, 2019
by
tilman
Browse files
add updates
parent
702b15cd
Changes
2
Hide whitespace changes
Inline
Side-by-side
detect_structures.py
View file @
9c8b40f5
...
...
@@ -17,6 +17,7 @@ TRIANGLES = True
BISEC_VECTORS
=
True
BISEC_CONES
=
True
BISEC_CONE_ANGLE
=
40
OVERLAY_ALPHA
=
0.2
OUT_DIR
=
'images/out/images_imdahl/'
#IN_DIR = "images/first_email/" # images from first email
IN_DIR
=
"images/images_imdahl/"
# images from imdahl
...
...
@@ -26,7 +27,7 @@ IN_DIR = "images/images_imdahl/" # images from imdahl
def
overlay_two_image_v2
(
image
,
overlay
,
ignore_color
=
[
0
,
0
,
0
]):
ignore_color
=
np
.
asarray
(
ignore_color
)
mask
=
(
overlay
==
ignore_color
).
all
(
-
1
,
keepdims
=
True
)
out
=
np
.
where
(
mask
,
image
,(
image
*
0.5
+
overlay
*
0.5
).
astype
(
image
.
dtype
))
out
=
np
.
where
(
mask
,
image
,(
image
*
(
1
-
OVERLAY_ALPHA
)
+
overlay
*
OVERLAY_ALPHA
).
astype
(
image
.
dtype
))
return
out
## misc functions end
...
...
@@ -69,26 +70,14 @@ for img_name in images:
cv2
.
arrowedLine
(
overlay
,
trp
(
bisecVector
[
1
]),
trp
(
bisecVector
[
0
]),
(
0
,
0
,
255
),
2
)
if
BISEC_CONES
:
bisecCones
=
[
poseToBisectCone
(
pose
,
BISEC_CONE_ANGLE
)
for
pose
in
datum
.
poseKeypoints
]
print
([
polyToArr
(
bisecCone
)
for
bisecCone
in
bisecCones
])
# for bisecCone in bisecCones:
# if bisecCone is not None:
# cv2.drawContours(overlay, [polyToArr(bisecCone)], 0, (0,0,255), -1)
# mainCanvas = Polygon(((0,len(img)), (0,0), (len(img[0]),0), (len(img[0]),len(img))))
# for cone in bisecCones:
# if cone is not None:
# mainCanvas = mainCanvas.intersection(cone)
# if not mainCanvas.is_empty:
# cv2.drawContours(overlay, [polyToArr(mainCanvas)], 0, (255,255,0), -1)
bisecCones
=
[
v
for
v
in
bisecCones
if
v
]
#remove None values
#print([polyToArr(bisecCone) for bisecCone in bisecCones])
intersections
=
coneIntersections
(
bisecCones
)
for
combi
in
intersections
:
#overlay = orig.copy()
overlay
=
np
.
zeros
((
len
(
img
),
len
(
img
[
0
]),
3
),
np
.
uint8
)
color
=
min
(((
len
(
combi
)
-
2
)
*
150
,
255
))
color
=
min
(((
len
(
combi
)
-
1
)
*
150
,
255
))
cv2
.
drawContours
(
overlay
,
[
polyToArr
(
intersections
[
combi
])],
0
,
(
color
,
0
,
255
),
-
1
)
#cv2.addWeighted(overlay, 0.5, img, 1 - 0.5, 0, img)
img
=
overlay_two_image_v2
(
img
,
overlay
,
[
0
,
0
,
0
])
cv2
.
addWeighted
(
overlay
,
0.5
,
img
,
1
-
0.5
,
0
,
img
)
if
SAVE_FILE
:
cv2
.
imwrite
(
os
.
path
.
basename
(
img_name
),
img
)
if
SHOW_WINDOW
:
...
...
lib/bisection.py
View file @
9c8b40f5
...
...
@@ -63,7 +63,7 @@ def poseToBisectCone(pose, angle):
def
coneIntersections
(
bisecCones
):
out
=
{}
for
r
in
range
(
2
,
len
(
bisecCones
)):
for
r
in
range
(
1
,
len
(
bisecCones
)):
pc
=
list
(
itertools
.
combinations
(
range
(
0
,
len
(
bisecCones
)),
r
))
#print(pc)
for
combi
in
pc
:
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment