步态能量图 matlab,【计算机视觉】步态能量图GEI

GEI简介

步态能量图(Gait Engery Image, GEI)是步态检测中最非常常用的特征,提取方法简单,也能很好的表现步态的速度,形态等特征。其定义如下:

其中,

表示在第q个步态序列中,时刻t的步态剪影图中坐标为(x,y)的像素值。

步态周期的判断使用步态剪影的宽、高之比即可,这个值比较容易而且随步态状态呈现周期性变化。

步态剪影

单张步态剪影图需调节成宽为W,高为H的大小。调节时保持剪影的比例不变,即如果剪影本身w’/h'

得到rescaled的步态剪影的代码:

// get resized gait imageif(!walk_img.empty()){vector > contours;vector hierarchy;Mat walk_img_tmp;threshold(walk_img,walk_img_tmp,128,255,THRESH_BINARY);findContours( walk_img_tmp, contours, hierarchy, CV_RETR_TREE, CV_CHAIN_APPROX_SIMPLE, Point(0, 0) );vector > contours_poly( contours.size() );vector boundRect( contours.size() );int maxRectHeight=0;int maxRectId=0;if(contours.size()>0){for( int i = 0; i< contours.size(); i++ ){//drawContours( walk_img, contours, i, Scalar(255,255,255), 2, 8, hierarchy, 0, Point() );//Approximates a polygonal curve(s) with the specified precision.approxPolyDP( Mat(contours[i]), contours_poly[i], 3, true );//Calculates the up-right bounding rectangle of a point set.boundRect[i] = boundingRect( Mat(contours_poly[i]) );if(boundRect[i].height>maxRectHeight){maxRectHeight = boundRect[i].height;maxRectId = i;}}//rectangle( walk_img, boundRect[maxRectId].tl(), boundRect[maxRectId].br(), Scalar(255,255,255), 2, 8, 0 );double aspect_ratio=(double)boundRect[maxRectId].height/boundRect[maxRectId].width;double base_aspect_ratio=(double)gei_height/gei_width;aspect_ratios.push_back(aspect_ratio);if(aspect_ratio>=base_aspect_ratio){Mat gait_roi=walk_img(boundRect[maxRectId]);Mat gait_roi_tmp;double resize_scale=double(gei_height)/gait_roi.rows;resize(gait_roi,gait_roi_tmp,Size(),resize_scale,resize_scale);Mat gait_img=Mat::zeros(gei_height,gei_width,CV_8UC1);for(int i=0;i(i);uchar* p=gait_img.ptr(i);for(int j=(gei_width-gait_roi_tmp.cols)/2,k=0;k(k);uchar* p=gait_img.ptr(i);for(int j=0;j

步态能量图GEI

得到GEI即把上一步每个周期得到的所有图加权平均即可。

if(aspect_ratios.size()<4)break;// get gait feature: gait energy imagevector max_ids;for(int i=2;iaspect_ratios[i-1])&&(aspect_ratios[i]>aspect_ratios[i-2])&&(aspect_ratios[i]>aspect_ratios[i+1])&&(aspect_ratios[i]>aspect_ratios[i+2]))max_ids.push_back(i);}// for all gait cyclesfor(int cycle_id=1;cycle_id=6 && gait_end_id-gait_start_id<30){for(int g=gait_start_id;g<=gait_end_id;g++){Mat gait=gait_imgs[g];Mat gait_tmp;gait.convertTo(gait_tmp,CV_32F);gait_energy_img = gait_energy_img+gait_tmp;#ifdef GAIT_DEBUGchar tmp[50];itoa(g,tmp,10);imshow(tmp,gait);#endif}//waitKey(10000);gait_energy_img = gait_energy_img/(float)(gait_end_id-gait_start_id+1);for(int r=0;r(r);for(int c=0;c

在CASIA Dataset B 数据集上得到每个角度GEI图:

本文转载自:小魏的修行路

欢迎加入我爱机器学习QQ14群:336582044

微信扫一扫,关注我爱机器学习公众号

你可能感兴趣的:(步态能量图,matlab)