human_pose_estimation_demo的進一步研究

1、demo能力html

OpenVINO提供了範例(human_pose_estimation_demo),可以在CPU上以較快速度識別出多人

 

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

基於這篇論文:函數

參考文檔:
https://docs.openvinotoolkit.org/latest/_demos_human_pose_estimation_demo_README.html
2、抽取18個點,作簡單的越界分析
既然以及可以從視頻中抽取人體骨骼,而且對應18個數據點
那麼就可以作定量分析。
對於這個視頻,使用MarkMan可以測量出關鍵領域的位置,那麼最簡單的想法就是首先得到「人的中心」這個點,當這個點位於敏感區域的時候進行報警。
可是這種方法很粗糙,咱們但願獲得的是這個敏感區域裏面,沒有人體的任何一個位置,所以首先對全部的點進行排序,然後判斷

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));
}
這樣就可以好許多。
3、更接近實際的狀況
前面的狀況仍是過於簡單,這個視頻更接近實際狀況
好比地上有這條安全線,傾斜的,就是不能越過,應該如何來處理?
首先仍是量出這條線(固定物鏡關係),而且咱們可以繪製出這條線;
下面,首先要作一個簡單的數學複習
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( 1017513), cv : :Point2f( 433, image.rows  -  1));
     bLeft   = PointIsLeftLine(pointLeftFoot, cv : :Point2f( 1017513), cv : :Point2f( 433, image.rows  -  1));
 
加上一些圖像繪製
 
     if (bRight || bLeft)
            {
                line(image, cv : :Point( 1017513), cv : :Point( 433, image.rows  -  1), cv : :Scalar( 00255),  8);
            }
             else
            {
                line(image, cv : :Point( 1017513), cv : :Point( 433, image.rows  -  1), cv : :Scalar( 02550),  8);
            }
可以獲得這樣的結果:
4、存在的問題
作到這一步,看起來問題獲得了很好的解決,可是實際上仍是出現了新的問題:
一、速度。目前只能作到8-9FPS,如何提升速度是不卡視頻輸入是新問題;
二、多人的識別;
三、區域的劃定;
四、界面操做。
這些問題都解決好,應該可以商用,最主要的是速度問題。
感謝閱讀至此,但願有所幫助。
相關文章
相關標籤/搜索