您的位置:首页 > 其它

3D手势识别(二)左右、上下滑动判断

2018-08-31 16:38 141 查看

场景:前装摄像头。

检测目标:检测手左右滑动状态,手沿x方向滑动,z轴为深度方向,y、z方向相对稳定。

                    手上下滑动类似。

步骤:

一、图像识别检测手,左右滑取最上点/上下滑取得手的最前点;

二、数据处理:中值滤波、平滑处理和卡尔曼滤波;

三、判断x方向角速度/速度是否超过阈值范围,检测移动方向;

四、判断y方向移动速度是否超过阈值。

部分算法如下:

检测某方向速度是否超过阈值范围,判断移动方向

[code]/************************************
Description: 用时间1的位置1与时间0的位置0得到速度与阈值比较
Method:    CheckLeftRight
FullName:  CheckLeftRight
Access:    private
Parameter: 时间1:const TimeStamp &t1
Parameter: 位置1:float f1
Parameter: 时间0:const TimeStamp &t0
Parameter: 位置0:float f0
Parameter: 速度阈值:thresh
Parameter: 标签名:输出日志用 const std::string &label_name
Returns:   int 0表示小于阈值,1/-1表示方向
Author:
Date:      2018/08/30
History:
************************************/
int CheckLeftRight(const TimeStamp &t1, float f1, const TimeStamp &t0,
float f0, float thresh, const std::string &label_name) {
float vt = ComputeVelocity(t1, f1, t0, f0);
int sliding_state = CheckVelocity(vt, -thresh, thresh);
return sliding_state;
}
//计算速度
float ComputeVelocity(const TimeStamp &t1, float f1, const TimeStamp &t0, float f0) {
double dt = (t1 - t0).toSec();
double delta_f = f1 - f0;
double v = delta_f / dt;
return static_cast<float>(v);
}
//判断
int CheckVelocity(double v, float thresh_low, float thresh_high) {
if (v > thresh_high) {
return 1;
}
if (v < thresh_low) {
return -1;
}
return 0;
}
阅读更多
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: