Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
sq975
openpose
提交
cc4082b4
O
openpose
项目概览
sq975
/
openpose
与 Fork 源项目一致
从无法访问的项目Fork
通知
7
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
O
openpose
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
cc4082b4
编写于
5月 31, 2017
作者:
G
gineshidalgo99
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Last frame flag & googly eyes fixed, COCO & MPI render similar
上级
550be9a7
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
91 addition
and
110 deletion
+91
-110
include/openpose/pose/poseParameters.hpp
include/openpose/pose/poseParameters.hpp
+4
-4
include/openpose/producer/datumProducer.hpp
include/openpose/producer/datumProducer.hpp
+3
-0
include/openpose/utilities/render.hu
include/openpose/utilities/render.hu
+52
-25
src/openpose/pose/poseRenderGpu.cu
src/openpose/pose/poseRenderGpu.cu
+32
-81
未找到文件。
include/openpose/pose/poseParameters.hpp
浏览文件 @
cc4082b4
...
...
@@ -33,8 +33,8 @@ namespace op
};
const
unsigned
int
POSE_COCO_NUMBER_PARTS
=
18u
;
// Equivalent to size of std::map POSE_COCO_BODY_PARTS - 1 (removing background)
const
std
::
vector
<
unsigned
int
>
POSE_COCO_MAP_IDX
{
31
,
32
,
39
,
40
,
33
,
34
,
35
,
36
,
41
,
42
,
43
,
44
,
19
,
20
,
21
,
22
,
23
,
24
,
25
,
26
,
27
,
28
,
29
,
30
,
47
,
48
,
49
,
50
,
53
,
54
,
51
,
52
,
55
,
56
,
37
,
38
,
45
,
46
};
const
std
::
vector
<
unsigned
int
>
POSE_COCO_PAIRS
{
1
,
2
,
1
,
5
,
2
,
3
,
3
,
4
,
5
,
6
,
6
,
7
,
1
,
8
,
8
,
9
,
9
,
10
,
1
,
11
,
11
,
12
,
12
,
13
,
1
,
0
,
0
,
14
,
14
,
16
,
0
,
15
,
15
,
17
,
2
,
16
,
5
,
17
};
#define POSE_COCO_PAIRS_TO_RENDER {1,2, 1,5, 2,3, 3,4, 5,6, 6,7, 1,8, 8,9, 9,10, 1,11, 11,12, 12,13, 1,0, 0,14, 14,16, 0,15, 15,17}
const
std
::
vector
<
unsigned
int
>
POSE_COCO_PAIRS
{
1
,
2
,
1
,
5
,
2
,
3
,
3
,
4
,
5
,
6
,
6
,
7
,
1
,
8
,
8
,
9
,
9
,
10
,
1
,
11
,
11
,
12
,
12
,
13
,
1
,
0
,
0
,
14
,
14
,
16
,
0
,
15
,
15
,
17
,
2
,
16
,
5
,
17
};
const
std
::
map
<
unsigned
int
,
std
::
string
>
POSE_MPI_BODY_PARTS
{
{
0
,
"Head"
},
...
...
@@ -55,9 +55,9 @@ namespace op
{
15
,
"Background"
}
};
const
unsigned
int
POSE_MPI_NUMBER_PARTS
=
15
;
// Equivalent to size of std::map POSE_MPI_NUMBER_PARTS - 1 (removing background)
const
std
::
vector
<
unsigned
int
>
POSE_MPI_MAP_IDX
{
16
,
17
,
18
,
19
,
20
,
21
,
22
,
23
,
24
,
25
,
26
,
27
,
28
,
29
,
30
,
31
,
3
8
,
39
,
40
,
41
,
42
,
43
,
32
,
33
,
34
,
35
,
36
,
37
};
const
std
::
vector
<
unsigned
int
>
POSE_MPI_PAIRS
{
0
,
1
,
1
,
2
,
2
,
3
,
3
,
4
,
1
,
5
,
5
,
6
,
6
,
7
,
1
,
14
,
14
,
11
,
11
,
12
,
12
,
13
,
14
,
8
,
8
,
9
,
9
,
10
};
#define POSE_MPI_PAIRS_TO_RENDER {0,1, 2,3, 3,4, 5,6, 6,7, 11,12, 12,13, 8,9, 9,10}
const
std
::
vector
<
unsigned
int
>
POSE_MPI_MAP_IDX
{
16
,
17
,
18
,
19
,
20
,
21
,
22
,
23
,
24
,
25
,
26
,
27
,
28
,
29
,
30
,
31
,
3
2
,
33
,
34
,
35
,
36
,
37
,
38
,
39
,
40
,
41
,
42
,
43
};
#define POSE_MPI_PAIRS_TO_RENDER { 0,1, 1,2, 2,3, 3,4, 1,5, 5,6, 6,7, 1,14, 14,8, 8,9, 9,10, 14,11, 11,12, 12,13}
const
std
::
vector
<
unsigned
int
>
POSE_MPI_PAIRS
POSE_MPI_PAIRS_TO_RENDER
;
// Constant Global Parameters
const
unsigned
int
POSE_MAX_PEOPLE
=
96u
;
...
...
include/openpose/producer/datumProducer.hpp
浏览文件 @
cc4082b4
...
...
@@ -100,6 +100,9 @@ namespace op
// Check producer is running
if
(
!
datumProducerRunning
)
datums
=
nullptr
;
// Increase counter if successful image
if
(
datums
!=
nullptr
)
mGlobalCounter
++
;
// Return result
return
std
::
make_pair
(
datumProducerRunning
,
datums
);
}
...
...
include/openpose/utilities/render.hu
浏览文件 @
cc4082b4
...
...
@@ -5,14 +5,14 @@ namespace op
{
inline __device__ void renderKeyPoints(float* targetPtr, float2* sharedMaxs, float2* sharedMins, float* sharedScaleF,
const int globalIdx, const int x, const int y, const int targetWidth, const int targetHeight,
const float* const
face
Ptr, const unsigned char* const partPairsPtr,
const int number
Faces
, const int numberParts, const int numberPartPairs,
const float* const
keypoints
Ptr, const unsigned char* const partPairsPtr,
const int number
People
, const int numberParts, const int numberPartPairs,
const float* const rgbColorsPtr, const int numberColors,
const float radius, const float stickwidth, const float threshold, const float alphaColorToAdd,
const bool blendOriginalFrame = true)
const bool blendOriginalFrame = true
, const int googlyEye1 = -1, const int googlyEye2 = -1
)
{
// Fill shared parameters
if (globalIdx < number
Faces
)
if (globalIdx < number
People
)
{
sharedMins[globalIdx].x = targetWidth;
sharedMins[globalIdx].y = targetHeight;
...
...
@@ -21,9 +21,9 @@ namespace op
for (auto part = 0 ; part < numberParts ; part++)
{
const auto index = 3 * (globalIdx*numberParts + part);
const auto x =
face
Ptr[index];
const auto y =
face
Ptr[index+1];
const auto score =
face
Ptr[index+2];
const auto x =
keypoints
Ptr[index];
const auto y =
keypoints
Ptr[index+1];
const auto score =
keypoints
Ptr[index+2];
if (score > threshold)
{
if (x < sharedMins[globalIdx].x)
...
...
@@ -62,24 +62,24 @@ namespace op
r = 0.f;
}
for (auto person = 0; person < number
Faces
; person++)
for (auto person = 0; person < number
People
; person++)
{
if (x <= sharedMaxs[person].x && x >= sharedMins[person].x && y <= sharedMaxs[person].y && y >= sharedMins[person].y)
{
// Hand part connections
for (auto
facePart = 0; facePart < numberPartPairs; facePart
++)
for (auto
partPair = 0; partPair < numberPartPairs; partPair
++)
{
const auto bSqrt = sharedScaleF[person] * sharedScaleF[person] * stickwidth * stickwidth;
const auto partA = partPairsPtr[2*
facePart
];
const auto partB = partPairsPtr[2*
facePart
+1];
const auto partA = partPairsPtr[2*
partPair
];
const auto partB = partPairsPtr[2*
partPair
+1];
const auto indexA = person*numberParts*3 + partA*3;
const auto xA =
face
Ptr[indexA];
const auto yA =
face
Ptr[indexA + 1];
const auto scoreA =
face
Ptr[indexA + 2];
const auto xA =
keypoints
Ptr[indexA];
const auto yA =
keypoints
Ptr[indexA + 1];
const auto scoreA =
keypoints
Ptr[indexA + 2];
const auto indexB = person*numberParts*3 + partB*3;
const auto xB =
face
Ptr[indexB];
const auto yB =
face
Ptr[indexB + 1];
const auto scoreB =
face
Ptr[indexB + 2];
const auto xB =
keypoints
Ptr[indexB];
const auto yB =
keypoints
Ptr[indexB + 1];
const auto scoreB =
keypoints
Ptr[indexB + 2];
if (scoreA > threshold && scoreB > threshold)
{
...
...
@@ -97,7 +97,7 @@ namespace op
const auto minV = 0.f;
const auto maxV = 1.f;
if (minV <= judge && judge <= maxV)
addColorWeighted(r, g, b, &rgbColorsPtr[(
facePart
%numberColors)*3], alphaColorToAdd);
addColorWeighted(r, g, b, &rgbColorsPtr[(
partPair
%numberColors)*3], alphaColorToAdd);
}
}
...
...
@@ -105,17 +105,44 @@ namespace op
for (unsigned char i = 0; i < numberParts; i++)
{
const auto index = 3 * (person*numberParts + i);
const auto localX =
face
Ptr[index];
const auto localY =
face
Ptr[index + 1];
const auto score =
face
Ptr[index + 2];
const auto localX =
keypoints
Ptr[index];
const auto localY =
keypoints
Ptr[index + 1];
const auto score =
keypoints
Ptr[index + 2];
if (score > threshold)
{
const auto dist2 = (x - localX) * (x - localX) + (y - localY) * (y - localY);
const auto minr2 = 0.f;
const auto maxr2 = sharedScaleF[person]*sharedScaleF[person]*radius * radius;
if (minr2 <= dist2 && dist2 <= maxr2)
addColorWeighted(r, g, b, &rgbColorsPtr[(i%numberColors)*3], alphaColorToAdd);
// Googly eyes
if (googlyEye1 == i || googlyEye2 == i)
{
const auto ratio = 2.5f * radius;
const auto minr2 = sharedScaleF[person]*sharedScaleF[person] * (ratio - 2) * (ratio - 2);
const auto maxr2 = sharedScaleF[person]*sharedScaleF[person] * ratio * ratio;
if (dist2 <= maxr2)
{
float colorToAdd [3] = {0., 0., 0.};
if (dist2 <= minr2)
for (auto& color : colorToAdd)
color = {255.f};
if (dist2 <= minr2*0.6f)
{
const auto dist3 = (x-4 - localX) * (x-4 - localX) + (y - localY+4) * (y - localY+4);
if (dist3 > 3.75f*3.75f)
for (auto& color : colorToAdd)
color = {0.f};
}
const auto alphaColorToAdd = 0.9f;
addColorWeighted(r, g, b, colorToAdd, alphaColorToAdd);
}
}
// Other limbs
else
{
const auto minr2 = 0.f;
const auto maxr2 = sharedScaleF[person]*sharedScaleF[person]*radius * radius;
if (minr2 <= dist2 && dist2 <= maxr2)
addColorWeighted(r, g, b, &rgbColorsPtr[(i%numberColors)*3], alphaColorToAdd);
}
}
}
}
...
...
src/openpose/pose/poseRenderGpu.cu
浏览文件 @
cc4082b4
...
...
@@ -32,16 +32,22 @@ namespace op
255.
f
,
0.
f
,
170.
f
,
255.
f
,
0.
f
,
85.
f
,
};
__constant__
const
float
MPI_RGB_COLORS
[]
=
{
255.
f
,
0.
f
,
0.
f
,
255.
f
,
170.
f
,
0.
f
,
170.
f
,
255.
f
,
0.
f
,
0.
f
,
255.
f
,
0.
f
,
0.
f
,
255.
f
,
170.
f
,
170.
f
,
0.
f
,
255.
f
,
255.
f
,
0.
f
,
170.
f
,
0.
f
,
170.
f
,
255.
f
,
0.
f
,
0.
f
,
255.
f
,
__constant__
const
float
MPI_RGB_COLORS
[]
=
{
// MPI colors chosen such that they are closed to COCO colors
255.
f
,
0.
f
,
85.
f
,
255.
f
,
0.
f
,
0.
f
,
255.
f
,
85.
f
,
0.
f
,
255.
f
,
170.
f
,
0.
f
,
255.
f
,
255.
f
,
0.
f
,
170.
f
,
255.
f
,
0.
f
,
85.
f
,
255.
f
,
0.
f
,
43.
f
,
255.
f
,
0.
f
,
0.
f
,
255.
f
,
0.
f
,
0.
f
,
255.
f
,
85.
f
,
0.
f
,
255.
f
,
170.
f
,
0.
f
,
255.
f
,
255.
f
,
0.
f
,
170.
f
,
255.
f
,
0.
f
,
85.
f
,
255.
f
,
0.
f
,
0.
f
,
255.
f
,
};
__constant__
const
float
RGB_COLORS_BACKGROUND
[]
=
{
255.
f
,
0.
f
,
0.
f
,
...
...
@@ -165,87 +171,32 @@ namespace op
renderKeyPoints
(
targetPtr
,
sharedMaxs
,
sharedMins
,
sharedScaleF
,
globalIdx
,
x
,
y
,
targetWidth
,
targetHeight
,
posePtr
,
COCO_PAIRS_GPU
,
numberPeople
,
POSE_COCO_NUMBER_PARTS
,
numberPartPairs
,
COCO_RGB_COLORS
,
numberColors
,
radius
,
stickwidth
,
threshold
,
alphaColorToAdd
,
blendOriginalFrame
);
radius
,
stickwidth
,
threshold
,
alphaColorToAdd
,
blendOriginalFrame
,
(
googlyEyes
?
14
:
-
1
),
(
googlyEyes
?
15
:
-
1
)
);
}
__global__
void
renderPoseMpi29Parts
(
float
*
targetPtr
,
const
int
targetWidth
,
const
int
targetHeight
,
const
float
*
const
posePtr
,
const
int
numberPeople
,
const
float
threshold
,
const
bool
blendOriginalFrame
,
const
float
alphaColorToAdd
)
{
//posePtr has length 3 * 15 * numberPeople
const
auto
x
=
(
blockIdx
.
x
*
blockDim
.
x
)
+
threadIdx
.
x
;
const
auto
y
=
(
blockIdx
.
y
*
blockDim
.
y
)
+
threadIdx
.
y
;
const
auto
globalIdx
=
threadIdx
.
y
*
blockDim
.
x
+
threadIdx
.
x
;
if
(
x
<
targetWidth
&&
y
<
targetHeight
)
{
const
auto
numberBodyParts
=
sizeof
(
MPI_PAIRS_GPU
)
/
(
2
*
sizeof
(
MPI_PAIRS_GPU
[
0
]));
const
auto
radius
=
3.
f
*
targetHeight
/
200.0
f
;
const
auto
stickwidth
=
targetHeight
/
60.0
f
;
const
auto
blueIndex
=
y
*
targetWidth
+
x
;
auto
&
b
=
targetPtr
[
blueIndex
];
auto
&
g
=
targetPtr
[
targetWidth
*
targetHeight
+
blueIndex
];
auto
&
r
=
targetPtr
[
2
*
targetWidth
*
targetHeight
+
blueIndex
];
if
(
!
blendOriginalFrame
)
{
b
=
0.
f
;
g
=
0.
f
;
r
=
0.
f
;
}
// Shared parameters
__shared__
float2
sharedMins
[
POSE_MAX_PEOPLE
];
__shared__
float2
sharedMaxs
[
POSE_MAX_PEOPLE
];
__shared__
float
sharedScaleF
[
POSE_MAX_PEOPLE
];
for
(
auto
person
=
0
;
person
<
numberPeople
;
person
++
)
{
// Body part body part connections
for
(
auto
bodyPart
=
0
;
bodyPart
<
numberBodyParts
;
bodyPart
++
)
{
auto
bSqrt
=
stickwidth
*
stickwidth
;
//fixed
const
auto
partA
=
MPI_PAIRS_GPU
[
2
*
bodyPart
];
const
auto
partB
=
MPI_PAIRS_GPU
[
2
*
bodyPart
+
1
];
const
auto
xA
=
posePtr
[
person
*
POSE_MPI_NUMBER_PARTS
*
3
+
partA
*
3
];
const
auto
yA
=
posePtr
[
person
*
POSE_MPI_NUMBER_PARTS
*
3
+
partA
*
3
+
1
];
const
auto
valueA
=
posePtr
[
person
*
POSE_MPI_NUMBER_PARTS
*
3
+
partA
*
3
+
2
];
const
auto
xB
=
posePtr
[
person
*
POSE_MPI_NUMBER_PARTS
*
3
+
partB
*
3
];
const
auto
yB
=
posePtr
[
person
*
POSE_MPI_NUMBER_PARTS
*
3
+
partB
*
3
+
1
];
const
auto
valueB
=
posePtr
[
person
*
POSE_MPI_NUMBER_PARTS
*
3
+
partB
*
3
+
2
];
if
(
valueA
>
threshold
&&
valueB
>
threshold
)
{
const
auto
xP
=
(
xA
+
xB
)
/
2.
f
;
const
auto
yP
=
(
yA
+
yB
)
/
2.
f
;
const
auto
angle
=
atan2f
(
yB
-
yA
,
xB
-
xA
);
const
auto
sine
=
sinf
(
angle
);
const
auto
cosine
=
cosf
(
angle
);
auto
aSqrt
=
(
xA
-
xP
)
*
(
xA
-
xP
)
+
(
yA
-
yP
)
*
(
yA
-
yP
);
if
(
bodyPart
==
0
)
{
aSqrt
*=
1.2
f
;
bSqrt
=
aSqrt
;
}
const
auto
A
=
cosine
*
(
x
-
xP
)
+
sine
*
(
y
-
yP
);
const
auto
B
=
sine
*
(
x
-
xP
)
-
cosine
*
(
y
-
yP
);
const
auto
judge
=
A
*
A
/
aSqrt
+
B
*
B
/
bSqrt
;
auto
minV
=
0.
f
;
if
(
bodyPart
==
0
)
minV
=
0.8
f
;
if
(
judge
>=
minV
&&
judge
<=
1
)
addColorWeighted
(
r
,
g
,
b
,
&
MPI_RGB_COLORS
[
3
*
bodyPart
],
alphaColorToAdd
);
}
}
// Other parameters
const
auto
numberPartPairs
=
sizeof
(
MPI_PAIRS_GPU
)
/
(
2
*
sizeof
(
MPI_PAIRS_GPU
[
0
]));
const
auto
numberColors
=
sizeof
(
MPI_RGB_COLORS
)
/
(
3
*
sizeof
(
MPI_RGB_COLORS
[
0
]));
const
auto
radius
=
fastMin
(
targetWidth
,
targetHeight
)
/
100.
f
;
const
auto
stickwidth
=
fastMin
(
targetWidth
,
targetHeight
)
/
120.
f
;
// Body part circles
for
(
unsigned
char
i
=
0
;
i
<
POSE_MPI_NUMBER_PARTS
;
i
++
)
//for every point
{
const
auto
index
=
3
*
(
person
*
POSE_MPI_NUMBER_PARTS
+
i
);
const
auto
localX
=
posePtr
[
index
];
const
auto
localY
=
posePtr
[
index
+
1
];
const
auto
value
=
posePtr
[
index
+
2
];
if
(
value
>
threshold
)
if
((
x
-
localX
)
*
(
x
-
localX
)
+
(
y
-
localY
)
*
(
y
-
localY
)
<=
radius
*
radius
)
addColorWeighted
(
r
,
g
,
b
,
&
MPI_RGB_COLORS
[(
i
%
9
)
*
3
],
alphaColorToAdd
);
}
}
}
// Render key points
renderKeyPoints
(
targetPtr
,
sharedMaxs
,
sharedMins
,
sharedScaleF
,
globalIdx
,
x
,
y
,
targetWidth
,
targetHeight
,
posePtr
,
MPI_PAIRS_GPU
,
numberPeople
,
POSE_MPI_NUMBER_PARTS
,
numberPartPairs
,
MPI_RGB_COLORS
,
numberColors
,
radius
,
stickwidth
,
threshold
,
alphaColorToAdd
,
blendOriginalFrame
);
}
__global__
void
renderBodyPartHeatMaps
(
float
*
targetPtr
,
const
int
targetWidth
,
const
int
targetHeight
,
const
float
*
const
heatMapPtr
,
const
int
widthHeatMap
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录