研究生记录(4)2015-4-28

本文介绍了一种使用Leap Motion检测手势并在Windows记事本中输入指定文字的技术,通过编写C++代码实现手势识别并进行相应操作。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

1、读了导师的四项发明专利书,有了一些了解

        2、学习使用了windowsAPI里的函数,可以用leapmotion来检测到swipe的手势,并在鼠标停留的记事本里输入指定的文字。

class SampleListener : public Listener {
  public:
    virtual void onFrame(const Controller&);
  private:
};


void SampleListener::onFrame(const Controller& controller) {
  // Get the most recent frame and report some basic information
  const Frame frame = controller.frame();

const GestureList gestures = frame.gestures();
  for (int g = 0; g < gestures.count(); ++g) {
    Gesture gesture = gestures[g];

     switch (gesture.type()) {

case Gesture::TYPE_SWIPE:
      {
        SwipeGesture swipe = gesture;
        std::cout << std::string(2, ' ')
          << "Swipe id: " << gesture.id()
          << ", state: " << stateNames[gesture.state()]
          << ", direction: " << swipe.direction()
          << ", speed: " << swipe.speed() << std::endl;
 //HWND wnd;
 POINT curpos; 
         GetCursorPos(&curpos);                    //获取当前鼠标的位置,位置将储存在curpos里。
HWND hWnd = WindowFromPoint(curpos);      //根据curpos所指的坐标点获取窗口句柄
SendMessage(hWnd,WM_CHAR,WPARAM('g'),0);  //发送一个字符(按键)消息g给当前鼠标所指向的窗口句柄
                             
        break;
      }

 default:
        std::cout << std::string(2, ' ')  << "Unknown gesture type." << std::endl;
        break;
    }
  }

   int main(int argc, char** argv) {
  // Create a sample listener and controller
  SampleListener listener;
  Controller controller;


  // Have the sample listener receive events from the controller
  controller.addListener(listener);


  if (argc > 1 && strcmp(argv[1], "--bg") == 0)
    controller.setPolicy(Leap::Controller::POLICY_BACKGROUND_FRAMES);


  // Keep this process running until Enter is pressed
  std::cout << "Press Enter to quit..." << std::endl;
  std::cin.get();


  // Remove the sample listener when done
  controller.removeListener(listener);


  return 0;
}

以仓央嘉措的两句话结尾:

我问佛:如何才能如你般睿智?
佛曰:佛是过来人,人是未来佛

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值