0
点赞
收藏
分享

微信扫一扫

human_pose_estimation_demo的进一步研究(基于OpenPOSE)

一葉_code 2022-12-25 阅读 178

一、demo能力



OpenVINO提供了范例(human_pose_estimation_demo),能够在CPU上以较快速度识别出多人



 




human_pose_estimation_demo的进一步研究(基于OpenPOSE)_xml


-iE:/OpenVINO_modelZoo/head-pose-face-detection-female-and-male.mp4 -mE:/OpenVINO_modelZoo/human-pose-estimation-0001.xml -d CPU

基于这篇论文:

human_pose_estimation_demo的进一步研究(基于OpenPOSE)_xml_02


参考文档:


​​ https://docs.openvinotoolkit.org/latest/_demos_human_pose_estimation_demo_README.html ​​


二、抽取18个点,做简单的越界分析


既然以及能够从视频中抽取人体骨骼,并且对应18个数据点



human_pose_estimation_demo的进一步研究(基于OpenPOSE)_斜率_03


那么就能够做定量分析。



human_pose_estimation_demo的进一步研究(基于OpenPOSE)_斜率_04


对于这个视频,使用MarkMan能够测量出关键领域的位置,那么最简单的想法就是首先获得“人的中心”这个点,当这个点位于敏感区域的时候进行报警。



human_pose_estimation_demo的进一步研究(基于OpenPOSE)_斜率_05


但是这种方法很粗糙,我们希望得到的是这个敏感区域里面,没有人体的任何一个位置,因此首先对所有的点进行排序,而后判断


bool SortbyXaxis(    const cv    :    :Point2f     & a,     const cv    :    :Point2f     &b)    
{
return a.x > b.x;
}

//而后对所有的点进行这样处理
HumanPose firstHumanPose = poses[ 0];
std : :vector <cv :
:Point2f
> firstKeypoints
= firstHumanPose.keypoints;

sort( firstKeypoints .begin(), firstKeypoints .end(), SortbyYaxis );

if ( ! (firstKeypoints[ 0].x < 369
|| firstKeypoints[firstKeypoints.size()
-
1].x
>
544))

{
std : :stringstream inRanges;
inRanges << "inRanges! ";
cv : :putText(image, inRanges.str(), cv : :Point(
16,
64),

cv : :FONT_HERSHEY_COMPLEX, 1, cv :
:Scalar(
0,
0,
255));

}

这样就能够好许多。


三、更接近实际的情况


前面的情况还是过于简单,这个视频更接近实际情况



human_pose_estimation_demo的进一步研究(基于OpenPOSE)_html_06


比如地上有这条安全线,倾斜的,就是不能越过,应该如何来处理?


首先还是量出这条线(固定物镜关系),并且我们能够绘制出这条线;


下面,首先要做一个简单的数学复习



human_pose_estimation_demo的进一步研究(基于OpenPOSE)_xml_07


K = (y1-y2)/(x1-x2),当K1>K2的时候点在左边,而在左边灰色区域的时候,绝对在左边,在右边蓝色区域的时候,绝对在右边。


据此编写函数



bool PointIsLeftLine(cv    :    :Point2f point, cv    :    :Point2f PointLineLeft, cv    :    :Point2f PointLineRight)

{
//边界外直接返回
if (point.x < 0)
return false;
if (point.x < = PointLineLeft.x)
return true;
if (point.x > PointLineRight.x)
return false;
//在边界内的情况,通过计算斜率
if (PointLineRight.x == PointLineLeft.x)
assert( "error PointLineRight.x == PointLineLeft.x");

float kLine = (PointLineRight.y - PointLineLeft.y) / (PointLineRight.x - PointLineLeft.x);
float k = (point.y - PointLineLeft.y) / (point.x - PointLineLeft.x);
return (k > = kLine);
}

并且分别对两个脚进行处理


bRight 
= PointIsLeftLine(pointRightFoot, cv
:
:Point2f(
1017,
513), cv
:
:Point2f(
433, image.rows
-
1));

bLeft = PointIsLeftLine(pointLeftFoot, cv : :Point2f( 1017, 513), cv :
:Point2f(
433, image.rows
-
1));

 


加上一些图像绘制


 


if (bRight     || bLeft)     
{
line(image, cv : :Point( 1017, 513), cv : :Point(
433, image.rows
-
1), cv
:
:Scalar(
0,
0,
255),
8);

}
else

{
line(image, cv : :Point( 1017, 513), cv : :Point(
433, image.rows
-
1), cv
:
:Scalar(
0,
255,
0),
8);

}

能够得到这样的结果:



human_pose_estimation_demo的进一步研究(基于OpenPOSE)_xml_08

human_pose_estimation_demo的进一步研究(基于OpenPOSE)_斜率_09

human_pose_estimation_demo的进一步研究(基于OpenPOSE)_html_10


四、存在的问题


做到这一步,看起来问题得到了很好的解决,但是实际上还是出现了新的问题:


1、速度。目前只能做到8-9FPS,如何提高速度是不卡视频输入是新问题;


2、多人的识别;


3、区域的划定;


4、界面操作。


这些问题都解决好,应该能够商用,最主要的是速度问题。


感谢阅读至此,希望有所帮助。





举报

相关推荐

0 条评论