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
089641fd
Unverified
Commit
089641fd
authored
Dec 25, 2019
by
tilman
Browse files
fixed all angle bugs and added CORRECTION_ANGLE to define a offset for gaze angle
parent
38b17f7b
Changes
3
Hide whitespace changes
Inline
Side-by-side
bisectVectorTest.py
View file @
089641fd
...
...
@@ -4,17 +4,26 @@ import cv2
import
numpy
as
np
import
os
from
sys
import
platform
from
openpose
import
pyopenpose
as
op
from
lib.triangles
import
*
from
lib.bisection
import
*
from
lib.misc
import
*
BISEC_VECTORS
=
True
CORRECTION_ANGLE
=
0
CORRECTION_ANGLE
=
1
0
img_name
=
"/Users/Tilman/Documents/Programme/Python/forschungspraktikum/art-structures-env/src/images/images_imdahl/Judas_und_Christus.jpg"
# pose = np.array([[4.7613028e+02,3.3695804e+02,9.0203685e-01],[5.3667474e+02,3.8633786e+02,6.6615295e-01],[5.1645105e+02,3.8405157e+02,5.1514143e-01],[0.0000000e+00,0.0000000e+00,0.0000000e+00],[0.0000000e+00,0.0000000e+00,0.0000000e+00],[5.5459924e+02,3.8859457e+02,6.4240879e-01],[5.6353766e+02,4.7384988e+02,1.8810490e-01],[5.3886292e+02,5.2543573e+02,9.0144195e-02],[5.4566248e+02,5.3215259e+02,3.6083767e-01],[5.2768524e+02,5.3213129e+02,3.1196830e-01],[5.4556714e+02,6.3534674e+02,1.8182488e-01],[5.8149310e+02,7.2958716e+02,1.3625422e-01],[5.6579541e+02,5.3216382e+02,3.6866242e-01],[5.8822272e+02,6.2862476e+02,1.7708556e-01],[6.0843213e+02,7.2955762e+02,2.2736737e-01],[4.7597812e+02,3.2798129e+02,5.7176876e-01],[4.8729745e+02,3.3027243e+02,9.1296065e-01],[0.0000000e+00,0.0000000e+00,0.0000000e+00],[5.2090784e+02,3.3472034e+02,7.7942842e-01],[5.7928674e+02,7.5646222e+02,2.0351715e-01],[5.9049512e+02,7.5648248e+02,2.0819387e-01],[6.2183606e+02,7.3853394e+02,1.7312977e-01],[5.8145673e+02,7.5420642e+02,1.2660497e-01],[5.7701074e+02,7.5417773e+02,1.2881383e-01],[5.8374255e+02,7.3627380e+02,9.4869599e-02]])
pose
=
np
.
array
([[
5.9406028e+02
,
3.3695804e+02
,
9.0203685e-01
],[
5.3667474e+02
,
3.8633786e+02
,
6.6615295e-01
],[
5.1645105e+02
,
3.8405157e+02
,
5.1514143e-01
],[
0.0000000e+00
,
0.0000000e+00
,
0.0000000e+00
],[
0.0000000e+00
,
0.0000000e+00
,
0.0000000e+00
],[
5.5459924e+02
,
3.8859457e+02
,
6.4240879e-01
],[
5.6353766e+02
,
4.7384988e+02
,
1.8810490e-01
],[
5.3886292e+02
,
5.2543573e+02
,
9.0144195e-02
],[
5.4566248e+02
,
5.3215259e+02
,
3.6083767e-01
],[
5.2768524e+02
,
5.3213129e+02
,
3.1196830e-01
],[
5.4556714e+02
,
6.3534674e+02
,
1.8182488e-01
],[
5.8149310e+02
,
7.2958716e+02
,
1.3625422e-01
],[
5.6579541e+02
,
5.3216382e+02
,
3.6866242e-01
],[
5.8822272e+02
,
6.2862476e+02
,
1.7708556e-01
],[
6.0843213e+02
,
7.2955762e+02
,
2.2736737e-01
],[
4.7597812e+02
,
3.2798129e+02
,
5.7176876e-01
],[
4.8729745e+02
,
3.3027243e+02
,
9.1296065e-01
],[
0.0000000e+00
,
0.0000000e+00
,
0.0000000e+00
],[
5.2090784e+02
,
3.3472034e+02
,
7.7942842e-01
],[
5.7928674e+02
,
7.5646222e+02
,
2.0351715e-01
],[
5.9049512e+02
,
7.5648248e+02
,
2.0819387e-01
],[
6.2183606e+02
,
7.3853394e+02
,
1.7312977e-01
],[
5.8145673e+02
,
7.5420642e+02
,
1.2660497e-01
],[
5.7701074e+02
,
7.5417773e+02
,
1.2881383e-01
],[
5.8374255e+02
,
7.3627380e+02
,
9.4869599e-02
]])
pose
=
np
.
array
([
[
5.9406028e+02
,
3.3695804e+02
,
9.0203685e-01
],
#a
[
5.3667474e+02
,
3.8633786e+02
,
6.6615295e-01
],
#b
[
1.1645105e+02
,
4.8405157e+02
,
5.1514143e-01
],
[
0.0000000e+00
,
0.0000000e+00
,
0.0000000e+00
],
[
0.0000000e+00
,
0.0000000e+00
,
0.0000000e+00
],
[
5.5459924e+02
,
3.8859457e+02
,
6.4240879e-01
],
[
5.6353766e+02
,
4.7384988e+02
,
1.8810490e-01
],
[
3.3886292e+02
,
5.2543573e+02
,
9.0144195e-02
],
[
5.4566248e+02
,
7.3215259e+02
,
3.6083767e-01
],
#c
[
5.2768524e+02
,
5.3213129e+02
,
3.1196830e-01
],[
5.4556714e+02
,
6.3534674e+02
,
1.8182488e-01
],[
5.8149310e+02
,
7.2958716e+02
,
1.3625422e-01
],[
5.6579541e+02
,
5.3216382e+02
,
3.6866242e-01
],[
5.8822272e+02
,
6.2862476e+02
,
1.7708556e-01
],[
6.0843213e+02
,
7.2955762e+02
,
2.2736737e-01
],[
4.7597812e+02
,
3.2798129e+02
,
5.7176876e-01
],[
4.8729745e+02
,
3.3027243e+02
,
9.1296065e-01
],[
0.0000000e+00
,
0.0000000e+00
,
0.0000000e+00
],[
5.2090784e+02
,
3.3472034e+02
,
7.7942842e-01
],[
5.7928674e+02
,
7.5646222e+02
,
2.0351715e-01
],[
5.9049512e+02
,
7.5648248e+02
,
2.0819387e-01
],[
6.2183606e+02
,
7.3853394e+02
,
1.7312977e-01
],[
5.8145673e+02
,
7.5420642e+02
,
1.2660497e-01
],[
5.7701074e+02
,
7.5417773e+02
,
1.2881383e-01
],[
5.8374255e+02
,
7.3627380e+02
,
9.4869599e-02
]])
img
=
cv2
.
imread
(
img_name
)
bisecVector
=
poseToBisectVector
(
pose
,
CORRECTION_ANGLE
)
...
...
detect_structures.py
View file @
089641fd
...
...
@@ -89,6 +89,7 @@ for img_name in images:
xy
=
(
int
(
intersections
[
combi
].
centroid
.
x
),
int
(
intersections
[
combi
].
centroid
.
y
))
cv2
.
circle
(
overlay
,
xy
,
10
,
(
0
,
255
,
0
),
-
1
)
global_angle
=
getGlobalLineAngle
(
datum
.
poseKeypoints
,
CORRECTION_ANGLE
)
print
(
"global_angle"
,
global_angle
)
dist
=
1000
d
=
(
int
(
dist
*
np
.
cos
(
global_angle
)),
int
(
dist
*
np
.
sin
(
global_angle
)))
#with origin zero
cv2
.
line
(
overlay
,
xy
,
(
xy
[
0
]
+
d
[
0
],
xy
[
1
]
+
d
[
1
]),
(
0
,
0
,
255
),
2
)
...
...
lib/bisection.py
View file @
089641fd
...
...
@@ -27,9 +27,9 @@ def getAngleGroundNormed(a,b,c, CORRECTION_ANGLE):
# print("angles",np.rad2deg(vector_angle),np.rad2deg(ground_angle),np.rad2deg(normed_angle))
if
(
a
[
0
]
-
b
[
0
]
<
0
):
return
(
normed_angle
+
np
.
deg2rad
(
180
))
return
(
normed_angle
+
np
.
deg2rad
(
180
-
CORRECTION_ANGLE
))
else
:
return
(
np
.
deg2rad
(
360
)
-
normed_angle
)
return
(
np
.
deg2rad
(
360
+
CORRECTION_ANGLE
)
-
normed_angle
)
def
getGlobalLineAngle
(
poses
,
CORRECTION_ANGLE
):
return
np
.
mean
([
getAngleGroundNormed
(
*
pose
[[
0
,
1
,
8
]][:,:
2
],
CORRECTION_ANGLE
)
for
pose
in
poses
if
not
0.0
in
pose
[[
0
,
1
,
8
]][:,
2
:]])
...
...
@@ -43,13 +43,10 @@ def getBisecPoint(a,b,c, CORRECTION_ANGLE):
def
getBisecCone
(
a
,
b
,
c
,
width
,
CORRECTION_ANGLE
):
angle
=
getAngleGroundNormed
(
a
,
b
,
c
,
CORRECTION_ANGLE
)
angle
=
angle
/
2
#dist = la.norm(a-b)
dist
=
1500
# dist = 100
conePoint1
=
(
int
(
dist
*
np
.
cos
(
angle
-
(
width
/
2
))),
int
(
dist
*
np
.
sin
(
angle
-
(
width
/
2
))))
#with origin zero
conePoint2
=
(
int
(
dist
*
np
.
cos
(
angle
+
(
width
/
2
))),
int
(
dist
*
np
.
sin
(
angle
+
(
width
/
2
))))
#with origin zero
return
((
conePoint1
[
0
]
+
b
[
0
],
conePoint1
[
1
]
+
b
[
1
]
),(
conePoint2
[
0
]
+
b
[
0
],
conePoint2
[
1
]
+
b
[
1
]
))
return
((
b
[
0
]
+
conePoint1
[
0
]
,
b
[
1
]
-
conePoint1
[
1
]),(
b
[
0
]
+
conePoint2
[
0
]
,
b
[
1
]
-
conePoint2
[
1
]))
def
poseToBisectVector
(
pose
,
CORRECTION_ANGLE
):
points
=
pose
[[
0
,
1
,
8
]]
...
...
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