(SKU:SEN0315) Gravity:PAJ7620U2 Gesture Sensor 手势识别传感器

来自DFRobot Product Wiki
跳转至: 导航搜索
产品名称(300px)

目录

简介

PAJ7620U2手势识别传感器是一款以IIC通信的3D手势识别交互式传感器。工作电流仅3.5mA, 手势识别距离达20mm。在最远20cm范围内,可以识别的手势多达13种。该手势传感器具备良好的手势识别稳定性,反应快,准确率高,可识别多种手势。支持两种手势识别模式,高速模式(可识别9种)和低速模式(可识别13种)。支持用户自定义识别手势。

PAJ7620U2手势识别传感器在高速模式下可识别上,下,左,右,前,后,顺时针,逆时针,快速挥手。而低速模式除了支持高速基础包含的所有手势外,还支持慢速上下,慢速左右,慢速前后,乱序。此外,低速模式可以自定义单位采样时间,还可根据自己需要轻松定义识别手势。

市面上主流的手势传感器可识别手势通常仅为六种,而对于非接触式遥控器,手势游戏机等应用,仅有的基础性6种识别模式完全不够。而PAJ7620U2手势识别传感器的出现,解决了手势识别模式欠缺的问题。PAJ7620U2手势识别传感器广泛适用于非接触式遥控器,机器人交互,手势操作游戏机,手势控制酷炫灯光等应用。设想一下,挥挥手控制电视空调;挥挥手调整灯光和音乐;挥挥手去操纵游戏...会不会很有意思呢?

技术规格

PAJ7620U2 Gesture Sensor 手势识别传感器尺寸图
  • 工作电压:3.3~5.5V
  • 工作电流:3.5mA
  • 通信接口:Gravity-IIC 4Pin
  • IIC地址:0x73
  • 尺寸:30mmx22mm
  • 安装孔尺寸:15mm
  • 可识别距离:30mm~200mm
  • 手势更新率:120Hz
  • 工作温度:-40℃~85℃
  • 环境光免疫力:<100k Lux
  • 盖板材料:推荐采用玻璃或PC;透明度须>90%;盖板材料厚度<0.7mm;盖板和模块应尽可能靠近,最远距离为0.2mm
SEN0315 sche.png









引脚说明

  • 顶部示意图
  • 底部示意图


丝印 功能描述
D IIC数据SDA
C IIC时钟SCL
- 电源负极
+ 电源正极


使用教程


准备

  • 硬件
    • UNO x1
    • IO 传感器拓展板 x1
    • PAJ7620U2手势识别传感器x1
  • 软件


接线图


准备好硬件后,按照下图将模块与UNO连接好

SEN0315 LinePic.png


样例代码

点击下载库文件例程和库文件如何安装库?

函数参考:

 DFRobot_PAJ7620U2(TwoWire *pWire=&Wire); 
 /**
  * @brief 构造函数
  * @param mode 构造设备时,可以指定它的默认工作模式
  */
 int begin(void) 
  /**
  * @brief 初始化函数
  * @return 返回0表示初始化成功,返回其他值表示初始化失败
  */
 void setGestureHighRate(bool b);
  /**
  * @brief 设置高速手势识别模式
  * @param b true表示配置为高速识别模式,以最快速度识别手势并返回。
  * @n  false表示低速模式,在低速模式下,系统会做更多的判断
  * @n  在高速识别模式下,可以快速识别的动作包括向左滑动 向右滑动 向上滑动 向下滑动 
  * @n  向前滑动 向后滑动 逆时针 顺时针 快速挥手 9个动作
  * @n  高级用户如果想要用这些动作的组合,需要在外部自己完成算法逻辑的编写,比如左右左快速挥手
  * @n  因为每个人用到的动作手势有限 ,我们没有将更多的扩展动作手势集在库中,需要用户在ino文件中自己完成编程
  * @n
  * @n
  * @n  在低速识别模式下,每2秒识别一个动作,我们将一些扩展动作集成到库内部,方便基础用户使用
  * @n  可以识别的动作包括向左滑动 向右滑动 向上滑动 向下滑动 向前滑动 向后滑动 
  * @n  逆时针 顺时针 快速挥手 9个基础动作 左右慢挥手 上下慢挥手 前后慢挥手 乱序慢挥手  4个扩展动作 
  */
 String gestureDescription(eGesture_t gesture);
  /**
  * @brief 获取手势号码对应的字符串描述
  * @param gesture 包含在eGesture_t中的手势号码
  * @return 手势号码对应的文字描述信息,如果输入了手势表中不存在的手势,返回空字符串
  * @n 正常的返回值可能是   "None","Right","Left", "Up", "Down", "Forward", "Backward", "Clockwise",
  * @n "Anti-Clockwise", "Wave", "WaveSlowlyDisorder", "WaveSlowlyLeftRight", "WaveSlowlyUpDown",
  * @n "WaveSlowlyForwardBackward"
  */
 eGesture_t getGesture(void);
 /**
  * @brief 获取手势
  * @return 返回当前手势,可能是的值为eGestureNone  eGestureRight  eGestureLeft  eGestureUp  
  * @n     eGestureDown  eGestureForward  eGestureBackward  eGestureClockwise
  * @n     eGestureWave  eGestureWaveSlowlyDisorder  eGestureWaveSlowlyLeftRight  
  * @n     eGestureWaveSlowlyUpDown  eGestureWaveSlowlyForwardBackward
  */


高速模式:

代码功能:可以识别以下手势。

Warning yellow.png

注:顺时针和逆时针手势需要至少转两圈以上 更多操作详见问答部分参考视频

高速模式可识别手势
gesture code gesture dsctiption
1 Right
2 Left
4 Up
8 Down
16 Forward
32 Backward
64 Clockwise
128 Anti-clockwise
256 Wave(quickly)
the totality of recognizable gesture is 9

/*!
 * @file GestureRecognize_HighRate.ino
 * @brief Present the 9 built-in gestures data the sensor supports. 
 * @n Wave your hand above the sensor (within 0~20cm), it can recognize 9 kinds of gestures: move up, down, left, right, forward,
 * @n backward, clockwise, anti-clockwise, wave.
 * @n For more usages of the sensor, refer to the description about setGestureHighRate in function setup.
 *
 * @copyright   Copyright (c) 2010 DFRobot Co.Ltd (http://www.dfrobot.com)
 * @licence     The MIT License (MIT)
 * @author      Alexander(ouki.wang@dfrobot.com)
 * @version  V1.0
 * @date  2019-07-16
 * @get from https://www.dfrobot.com
 * @url https://github.com/DFRobot/DFRobot_PAJ7620U2
 */
 
#include <DFRobot_PAJ7620U2.h>

DFRobot_PAJ7620U2 paj;

void setup()
{
  Serial.begin(115200);
  delay(300);
  Serial.println("Gesture recognition system base on PAJ7620U2");
  while(paj.begin() != 0){
    Serial.println("initial PAJ7620U2 failure! Please check if all the connections are fine, or if the wire sequence is correct?");
    delay(500);
  }
  Serial.println("PAJ7620U2 init completed, start to test the gesture recognition function");
  
  /*Set fast detection mode 
   *If the parameter is set to false, the module enters slow detection mode, and it detects one gesture every 2s. We have integrated
   *some gestures inside the module to make it convenient for beginners.
   *The slow mode can recognize 9  basic gestures and 4 expanded gestures: move left, right, up, down, forward, backward, clockwise, 
   *counter-clockwise, wave, slowly move left and right, slowly move up and down, slowly move forward and backward, 
   *wave slowly and randomly.
   *
   *
   *
   *If the parameter is set to true, the module enters fast detection mode. 
   *The fast mode can recognize 9 gestures: move left, right, up, down, forward, backward, clockwise, counter-clockwise, wave
   *To detect the combination of these gestures, like wave left, right and left quickly, users needs to design their own algorithms logic.
   *Since users only use limited gestures in this mode, we are not going to integrate too much expanded gestures in the library. 
   *If necessary, you can complete the algorithm logic in the ino file by yourself.
   */
  paj.setGestureHighRate(true);

}

void loop()
{
  /* Read gesture number(return eGesture_t enumerated type)
   * eGestureNone  eGestureRight  eGestureLeft  eGestureUp  eGestureDown  eGestureForward
   * eGestureBackward  eGestureClockwise  eGestureAntiClockwise  eGestureWave  eGestureWaveSlowlyDisorder
   * eGestureWaveSlowlyLeftRight  eGestureWaveSlowlyUpDown  eGestureWaveSlowlyForwardBackward
   */
  DFRobot_PAJ7620U2::eGesture_t gesture = paj.getGesture();
  if(gesture != paj.eGestureNone ){
   /* Get the string descritpion corresponding to the gesture number.
    * The string description could be 
    * "None","Right","Left", "Up", "Down", "Forward", "Backward", "Clockwise", "Anti-Clockwise", "Wave",
    * "WaveSlowlyDisorder", "WaveSlowlyLeftRight", "WaveSlowlyUpDown", "WaveSlowlyForwardBackward"
    */
    String description  = paj.gestureDescription(gesture);//Convert gesture number into string description
    Serial.println("--------------Gesture Recognition System---------------------------");
    Serial.print("gesture code        = ");Serial.println(gesture);
    Serial.print("gesture description  = ");Serial.println(description);
    Serial.println();
  }
}                           


结果

结果:可识别9种手势,可以在串口打印出相应的手势描述,如下图所示:
SEN0315 9ges.png

低速模式:

Warning yellow.png

注:低速模式下默认采样时间为2s,所以完成一项操作后可能需等待1s 更多操作详见问答部分参考视频

代码功能:可以识别以下手势。

低速模式可识别手势
gesture code gesture dsctiption
1 Right
2 Left
3 WaveSlowlyLeftRight
4 Up
8 Down
12 WaveSlowlyUpDown
16 Forward
32 Backward
48 WaveSlowlyForwardBackward
64 Clockwise
128 Anti-clockwise
256 Wave(quickly)
512 WaveSlowlyDisorder
the totality of recognizable gesture is 13

#include <DFRobot_PAJ7620U2.h>
 
/*!
 * @file GestureRecognize_LowRate.ino
 * @brief Present the 9 built-in gestures the sensor supports and 4 extended gestures in the slow mode.  
 * @n Wave you hand above the sensor(within 0~20cm), it can detect: move left, right, up, down, forward, backward, clockwise, 
 * @n anti-clockwise, wave, slowly move left and right, slowly move up and down, slowly move forward and backward, wave randomly and slowly.
 * @n For more usages of the sensor, refer to the description about setGestureLowRate in function setup.  
 *
 * @copyright   Copyright (c) 2010 DFRobot Co.Ltd (http://www.dfrobot.com)
 * @licence     The MIT License (MIT)
 * @author      Alexander(ouki.wang@dfrobot.com)
 * @version  V1.0
 * @date  2019-07-16
 * @get from https://www.dfrobot.com
 * @url https://github.com/DFRobot/DFRobot_PAJ7620U2
 */
 
#include <DFRobot_PAJ7620U2.h>

DFRobot_PAJ7620U2 paj;

void setup()
{
  Serial.begin(115200);
  delay(300);
  Serial.println("Gesture recognition system base on PAJ7620U2");
  while(paj.begin() != 0){
    Serial.println("initial PAJ7620U2 failure! Please check if all the connections are fine, or if the wire sequence is correct?");
    delay(500);
  }
  Serial.println("PAJ7620U2init completed, start to test the gesture recognition function");
  
  /*Set fast detection mode 
   *If the parameter is set to false, the module enters slow detection mode, and it detects one gesture every 2s. We have integrated 
   *some gestures inside the module to make it convenient for beginners.
   *The slow mode can recognize 9  basic gestures and 4 expanded gestures: move left, right, up, down, forward, backward, clockwise, 
   *counter-clockwise, wave, slowly move left and right, slowly move up and down, slowly move forward and backward,
   *wave slowly and randomly. 
   *
   *
   *
   *If the parameter is set to true, the module enters fast detection mode. 
   *The fast mode can recognize 9 gestures: move left, right, up, down, forward, backward, clockwise, counter-clockwise, wave.
   *To detect the combination of these gestures, like wave left, right and left quickly, users needs to design their own
   *algorithms logic.
   *Since users only use limited gestures in this mode, we are not going to integrate too much expanded gestures in the library.
   *If necessary, you can complete the algorithm logic in the ino file by yourself.
   */
  paj.setGestureHighRate(false);

}

void loop()
{
  /* Read gesture number(return eGesture_t enumerated type)
   * eGestureNone  eGestureRight  eGestureLeft  eGestureUp  eGestureDown  eGestureForward
   * eGestureBackward  eGestureClockwise  eGestureAntiClockwise  eGestureWave  eGestureWaveSlowlyDisorder
   * eGestureWaveSlowlyLeftRight  eGestureWaveSlowlyUpDown  eGestureWaveSlowlyForwardBackward
   */
  DFRobot_PAJ7620U2::eGesture_t gesture = paj.getGesture();
  if(gesture != paj.eGestureNone ){
   /* Get the string descritpion corresponding to the gesture number.
    * The string description could be 
    * "None","Right","Left", "Up", "Down", "Forward", "Backward", "Clockwise", "Anti-Clockwise", "Wave",
    * "WaveSlowlyDisorder", "WaveSlowlyLeftRight", "WaveSlowlyUpDown", "WaveSlowlyForwardBackward"
    */
    String description  = paj.gestureDescription(gesture);//Convert gesture number into string description
    Serial.println("--------------Gesture Recognition System---------------------------");
    Serial.print("gesture code        = ");Serial.println(gesture);
    Serial.print("gesture description  = ");Serial.println(description);
    Serial.println();
  }
}


结果

结果:可识别13手势,可以在串口打印出相应的手势描述,如下图所示:
SEN0315 13ges.png

Mind+(基于Scratch3.0)图形化编程

1、下载及安装软件,版本不低于1.6.2 RC2.0。下载地址:http://www.mindplus.cc 详细教程:Mind+基础wiki教程-软件下载安装
2、切换到“上传模式”。 详细教程:Mind+基础wiki教程-上传模式编程流程
3、“扩展”中选择“主控板”中的“Arduino Uno”,“用户库”中搜索加载手势 。详细教程:Mind+基础wiki教程-加载扩展库流程
4、进行编程,程序如下图。
5、菜单“连接设备”,“上传到设备”
6、程序上传完毕后,打开串口即可看到数据输出。详细教程:Mind+基础wiki教程-串口打印

Sen0315-mind.png


Sen0315-block1.png


常见问题

问:有高速模式演示视频吗?

答:https://www.bilibili.com/video/av76484181

问:有低速模式演示视频吗?

答:https://www.bilibili.com/video/av76484092

更多问题及有趣的应用,可以 访问论坛 进行查阅或发帖!


更多

原理图
Datasheet
SVG 文件



DFshopping car1.png DFRobot商城购买链接

个人工具
名字空间

变换
操作
导航
工具箱