Leap Motion C++ 开发笔记(二) 打开摄像头
来源:互联网 发布:mac 彻底删除office 编辑:程序博客网 时间:2024/05/16 04:29
代码部分
主要使用了SDK中的frame.images()获取图像
遗憾的是,获取的图像仅为8位
摘自官方文档的说明:
If a 32-bit-per-component texture format is not available on your target platform, you can use a separate texture for the x and y lookup values and encode the floating point values into multiple 8-bit color components. You then have to decode the values before using them to look up the raw brightness values.
也就是说Leap Motion并不能像Kinect那样通过像素点得到精确的深度信息值
#include "Leap.h" #include <iostream> // OpenCV Header #include<opencv2/opencv.hpp> #include "opencv2/core/core.hpp"#include "opencv2/highgui/highgui.hpp"using namespace cv;using namespace std;using namespace Leap;class SampleListener : public Listener {public: virtual void onInit(const Controller&); virtual void onConnect(const Controller&); virtual void onDisconnect(const Controller&); virtual void onExit(const Controller&); virtual void onFrame(const Controller&);private:};void SampleListener::onInit(const Controller& controller) { std::cout << "初始化完成~" << std::endl;}void SampleListener::onConnect(const Controller& controller) { std::cout << "正在连接" << std::endl;}void SampleListener::onDisconnect(const Controller& controller) { std::cout << "连接失败" << std::endl;}void SampleListener::onExit(const Controller& controller) {}void SampleListener::onFrame(const Controller& controller) { const Frame frame = controller.frame(); ImageList images = frame.images(); Mat A;//左侧红外摄像头 Mat B;//右侧 if (images.count() >= 2) { A = Mat(images[0].height(), images[0].width(),CV_8UC1, (void *)images[0].data()); B = Mat(images[1].height(), images[1].width(), CV_8UC1, (void *)images[1].data()); imshow("left",A); imshow("right", B); waitKey(1); }}int main(int argc, char** argv) { SampleListener listener; Controller controller; controller.addListener(listener); controller.setPolicy(Leap::Controller::POLICY_BACKGROUND_FRAMES); controller.setPolicy(Leap::Controller::POLICY_IMAGES); std::cout << "输入Enter退出" << std::endl; std::cin.get(); controller.removeListener(listener); return 0;}
实现效果
右下图可以看出,左右两个红外摄像头区别还是很明显的
阅读全文
0 0
- Leap Motion C++ 开发笔记(二) 打开摄像头
- Leap Motion环境配置(C++)
- Leap Motion 之Unity 开发指南(二. 开发架构和SDK)L
- 使用C#开发基于Leap Motion的手势控制应用(二)
- Leap Motion C++开发笔记(一)下载安装及环境配置
- Leap Motion C++开发笔记(三)获取深度值及距离估算
- Unity Leap Motion学习笔记
- Leap Motion的环境配置(使用c#)
- (0)Leap Motion简介
- leap motion
- Leap Motion
- Leap Motion
- Leap Motion开发第一步环境配置
- 【VR】Leap Motion 官网文档 LeapRecorder (Leap记录器)
- 【VR】Leap Motion 官网文档 LeapRecorder (Leap记录器)
- Leap Motion SDK学习--API(翻译)
- 【VR】Leap Motion 官网文档(二) Unity插件概述
- 从Kinect和Leap Motion谈体感的开发(无处不在的机器学习)
- Mathematical Field of Experiments (打表)
- 深度优先搜索—C—python
- exit函数
- SVM之核函数
- codility MinPerimeterRectangle
- Leap Motion C++ 开发笔记(二) 打开摄像头
- spring-boot入门(二)
- 米语录交流学习(三)
- linux下安装python环境
- 程序员如何提问整理
- 剑指offer_表示数字的字符串
- 【设计模式】装饰者模式-明月装饰了你的窗子
- js获取url传递的参数(解决了中文时乱码)
- 搭建 LAMP 环境