www.pudn.com > 人体步态跟踪识别bate版.rar > StickHuman.cpp


// StickHuman.cpp: implementation of the CStickHuman class. 
// 
////////////////////////////////////////////////////////////////////// 
 
#include "stdafx.h" 
#include "humantrack.h" 
#include "StickHuman.h" 
 
#ifdef _DEBUG 
#undef THIS_FILE 
static char THIS_FILE[]=__FILE__; 
#define new DEBUG_NEW 
#endif 
 
////////////////////////////////////////////////////////////////////// 
// Construction/Destruction 
////////////////////////////////////////////////////////////////////// 
 
CStickHuman::CStickHuman() 
{ 
 //InitialStickHuman(); 
} 
 
CStickHuman::~CStickHuman() 
{ 
 
} 
 
void CStickHuman::InitialStickHuman() 
{ 
	//初始化头部点 
	m_head.Angle=0; 
	m_head.Point.x=154; 
	m_head.Point.y=22; 
	m_head.Length=24; 
    //初始化颈部点 
	m_neck.Angle=30; 
	m_neck.Point.x=154; 
	m_neck.Point.y=44; 
	m_neck.Length=10; 
    //初始化肩部点 
	m_shoulder.Angle=35; 
	m_shoulder.Point.x=150; 
	m_shoulder.Point.y=52; 
	m_shoulder.Length=0; 
	//初始化躯干点 
    m_trunk.Angle=35; 
	m_trunk.Point.x=146; 
	m_trunk.Point.y=120; 
	m_trunk.Length=68; 
    //初始化左大腿点 
	m_left_thigh.Angle=30; 
	m_left_thigh.Length=36; 
	m_left_thigh.Point.x=165; 
	m_left_thigh.Point.y=156; 
    //初始化右大腿点 
	m_right_thigh.Angle=30; 
	m_right_thigh.Length=36; 
	m_right_thigh.Point.x=130; 
	m_right_thigh.Point.y=156; 
    //初始化左小腿点 
    m_left_crus.Angle=10; 
	m_left_crus.Length=46; 
	m_left_crus.Point.x=184; 
	m_left_crus.Point.y=198; 
    //初始化右小腿点 
    m_right_crus.Angle=10; 
	m_right_crus.Length=46; 
	m_right_crus.Point.x=110; 
	m_right_crus.Point.y=200; 
    //初始化左脚点 
    m_left_foot.Angle=60; 
	m_left_foot.Length=30; 
	m_left_foot.Point.x=208; 
	m_left_foot.Point.y=190; 
    //初始化右脚点 
	m_right_foot.Angle=80; 
	m_right_foot.Length=30; 
	m_right_foot.Point.x=140; 
	m_right_foot.Point.y=200; 
} 
 
void CStickHuman::SetHead(Stick head) 
{ 
	m_head.Angle=head.Angle; 
	m_head.Point=head.Point; 
	m_head.Length=head.Length; 
} 
void CStickHuman::SetNeck(Stick neck) 
{ 
	m_neck.Angle=neck.Angle; 
	m_neck.Point=neck.Point; 
	m_neck.Length=neck.Length; 
} 
void CStickHuman::SetShoulder(Stick shoulder) 
{ 
	m_shoulder.Angle=shoulder.Angle; 
	m_shoulder.Point=shoulder.Point; 
	m_shoulder.Length=shoulder.Length;	 
} 
void CStickHuman::SetTrunk(Stick trunk) 
{ 
	m_trunk.Angle=trunk.Angle; 
	m_trunk.Point=trunk.Point; 
	m_trunk.Length=trunk.Length;	 
} 
void CStickHuman::SetLeftThigh(Stick leftthigh) 
{ 
	m_left_thigh.Angle=leftthigh.Angle; 
	m_left_thigh.Length=leftthigh.Length; 
	m_left_thigh.Point=leftthigh.Point; 
} 
void CStickHuman::SetRightThigh(Stick rightthigh) 
{ 
	m_right_thigh.Angle=rightthigh.Angle; 
	m_right_thigh.Length=rightthigh.Length; 
	m_right_thigh.Point=rightthigh.Point; 
	 
} 
void CStickHuman::SetLeftCrus(Stick leftcrus) 
{ 
	m_left_crus.Angle=leftcrus.Angle; 
	m_left_crus.Length=leftcrus.Length; 
	m_left_crus.Point=leftcrus.Point; 
} 
void CStickHuman::SetRightCrus(Stick rightcrus) 
{ 
	m_right_crus.Angle=rightcrus.Angle; 
	m_right_crus.Length=rightcrus.Length; 
	m_right_crus.Point=rightcrus.Point; 
} 
void CStickHuman::SetLeftFoot(Stick leftfoot) 
{ 
	m_left_foot.Angle=leftfoot.Angle; 
	m_left_foot.Length=leftfoot.Length; 
	m_left_foot.Point=leftfoot.Point; 
} 
void CStickHuman::SetRightFoot(Stick rightfoot) 
{ 
	m_right_foot.Angle=rightfoot.Angle; 
	m_right_foot.Length=rightfoot.Length; 
	m_right_foot.Point=rightfoot.Point; 
} 
 
void CStickHuman::DrawStickHuman(CDC *pDC) 
{ 
	CPoint Pos; 
	CPen pen(PS_SOLID,1,RGB(255,0,0)); 
	pDC->SelectObject(&pen); 
	 
	pDC->MoveTo(m_head.Point); 
	pDC->LineTo(m_neck.Point); 
	pDC->LineTo(m_shoulder.Point); 
	pDC->LineTo(m_trunk.Point); 
	 
	pDC->LineTo(m_left_thigh.Point); 
	pDC->LineTo(m_left_crus.Point); 
	pDC->LineTo(m_left_foot.Point); 
	 
	 
	pDC->MoveTo(m_trunk.Point); 
	pDC->LineTo(m_right_thigh.Point); 
	pDC->LineTo(m_right_crus.Point); 
	pDC->LineTo(m_right_foot.Point); 
	 
	CPen pen1(PS_SOLID,4,RGB(0,255,0)); 
	pDC->SelectObject(&pen1); 
	//绘制头部点 
	CRect rc; 
/*	rc.top=m_head.Point.y-1; 
	rc.bottom=m_head.Point.y+1; 
    rc.left=m_head.Point.x-1; 
    rc.right=m_head.Point.x+1; 
    pDC->Ellipse(&rc);*/ 
	//绘制颈部点 
	rc.top=m_neck.Point.y-1; 
	rc.bottom=m_neck.Point.y+1; 
    rc.left=m_neck.Point.x-1; 
    rc.right=m_neck.Point.x+1; 
	pDC->Ellipse(&rc); 
    //绘制肩部点 
	rc.top=m_shoulder.Point.y-1; 
	rc.bottom=m_shoulder.Point.y+1; 
    rc.left=m_shoulder.Point.x-1; 
    rc.right=m_shoulder.Point.x+1; 
	pDC->Ellipse(&rc); 
    //绘制躯干点 
	rc.top=m_trunk.Point.y-1; 
	rc.bottom=m_trunk.Point.y+1; 
    rc.left=m_trunk.Point.x-1; 
    rc.right=m_trunk.Point.x+1; 
	pDC->Ellipse(&rc); 
    //绘制左大腿点 
	rc.top=m_left_thigh.Point.y-1; 
	rc.bottom=m_left_thigh.Point.y+1; 
    rc.left=m_left_thigh.Point.x-1; 
    rc.right=m_left_thigh.Point.x+1; 
	pDC->Ellipse(&rc); 
    //绘制右大腿点 
	rc.top=m_right_thigh.Point.y-1; 
	rc.bottom=m_right_thigh.Point.y+1; 
    rc.left=m_right_thigh.Point.x-1; 
    rc.right=m_right_thigh.Point.x+1; 
	pDC->Ellipse(&rc); 
    //绘制左小腿点 
	rc.top=m_left_crus.Point.y-1; 
	rc.bottom=m_left_crus.Point.y+1; 
    rc.left=m_left_crus.Point.x-1; 
    rc.right=m_left_crus.Point.x+1; 
	pDC->Ellipse(&rc); 
    //绘制右小腿点 
	rc.top=m_right_crus.Point.y-1; 
	rc.bottom=m_right_crus.Point.y+1; 
    rc.left=m_right_crus.Point.x-1; 
    rc.right=m_right_crus.Point.x+1; 
	pDC->Ellipse(&rc); 
    //绘制左脚点 
	rc.top=m_left_foot.Point.y-1; 
	rc.bottom=m_left_foot.Point.y+1; 
    rc.left=m_left_foot.Point.x-1; 
    rc.right=m_left_foot.Point.x+1; 
	pDC->Ellipse(&rc); 
    //绘制右脚点 
	rc.top=m_right_foot.Point.y-1; 
	rc.bottom=m_right_foot.Point.y+1; 
    rc.left=m_right_foot.Point.x-1; 
    rc.right=m_right_foot.Point.x+1; 
	pDC->Ellipse(&rc); 
}