Kinect虚拟试衣间开发(1)-显示colorFrame图像
来源:互联网 发布:分布式算法有哪些 编辑:程序博客网 时间:2024/04/29 07:58
- 声明变量
private KinectSensor kinectSensor = null;//读取多源数据,以便于同时处理private MultiSourceFrameReader multiSourceFrameReader = null;private MultiSourceFrame multiSourceFrame;//变量转换器private CoordinateMapper coordinateMapper;//存储要显示图像private WriteableBitmap bitmap;//帧描述,有可以使用的元变量private FrameDescription colorFrameDescription;
- 变量初始化
public MainWindow() {this.kinectSensor = KinectSensor.GetDefault();this.multiSourceFrameReader = this.kinectSensor.OpenMultiSourceFrameReader(FrameSourceTypes.Color | FrameSourceTypes.Depth | FrameSourceTypes.Body);this.multiSourceFrameReader.MultiSourceFrameArrived += this.Reader_multiSourceFrameArrived;colorFrameDescription = this.kinectSensor.ColorFrameSource.CreateFrameDescription(ColorImageFormat.Bgra); //存储图,bitmap的长和高都是以pixel度量的,colorFrame.width返回值也是以pixel为单位的长度this.bitmap = new WriteableBitmap(colorFrameDescription.Width, colorFrameDescription.Height, 96.0, 96.0, PixelFormats.Bgr32, null);//坐标转换器this.coordinateMapper =this.kinectSensor.CoordinateMapper; this.kinectSensor.Open(); this.DataContext = this; InitializeComponent();}
- 监听事件处理
private void Reader_multiSourceFrameArrived(object sender, MultiSourceFrameArrivedEventArgs e){ multiSourceFrame = e.FrameReference.AcquireFrame(); using (ColorFrame colorFrame = multiSourceFrame.ColorFrameReference.AcquireFrame()) { if (colorFrame != null) { //锁一下,保存后台缓冲 this.bitmap.Lock(); //dataFrame:The pointer to the buffer to which the data will be copied. size:The size of the buffer.ColorFormat:The color format of the converted data colorFrame.CopyConvertedFrameDataToIntPtr(this.bitmap.BackBuffer, (uint)(this.colorFrameDescription.Width * this.colorFrameDescription.Height * 4), ColorImageFormat.Bgra); //重设bitmap的数据 this.bitmap.AddDirtyRect(new Int32Rect(0, 0, this.bitmap.PixelWidth, this.bitmap.PixelHeight)); //解锁 this.bitmap.Unlock(); } }}
- 返回彩图
public ImageSource imageSource { get { return this.bitmap; } }
阅读全文
1 0
- Kinect虚拟试衣间开发(1)-显示colorFrame图像
- Kinect虚拟试衣间开发(3)-拍照和声控功能
- Kinect虚拟试衣间开发(4)-2D衣物试穿
- Kinect虚拟试衣间开发(5)-动作识别
- Kinect虚拟试衣
- Kinect虚拟试衣间开发(2)-Hand Point Gesture,手掌交互部分
- Kinect学习笔记一ColorFrame
- Kinect V2开发(3)用OpenCV显示Kinect图像
- 网络虚拟试衣间受白领追捧
- 基于HTML5实现的在线3D虚拟试衣系统(试衣间)解决方案
- Kinect for Windows 实践笔记NO.1 彩色图像显示
- Kinect入门(1)——显示彩色图像数据流
- Kinect开发教程二:OpenNI读取深度图像与彩色图像并显示
- Kinect开发教程二:OpenNI读取深度图像与彩色图像并显示
- Kinect开发教程二:OpenNI读取深度图像与彩色图像并显示
- [KinectWPF程序]1深度图像,使用WriteableBitmap对象改进Kinect图像显示&复杂的Kinect初始化方法
- Kinect开发教程八:OpenNI2显示深度、彩色及融合图像
- kinect 开发入门——读取深度信息和显示深度信息图像
- unity中SmoothFollow.js的c#代码
- SQLServer使用Checksum结合NewID获得随机数
- ios-block作为属性的时候为什么用copy
- (0060)iOS开发之iOS 9: UIStackView入门
- Javascript获取页面、屏幕尺寸大小参数
- Kinect虚拟试衣间开发(1)-显示colorFrame图像
- HBase运维实践-聊聊RIT的那点事
- LIC(最长子序列)
- Jquery中Datatable表格控件插入超链接,点击数据转页面
- HDU 2870 Largest Submatrix(最大子矩阵面积)
- 如何开启QtCreator的代码自动补全功能
- phpcmsv9实现手机端与PC端双模板的方法与详细教程(转)
- JSONObject的toBean 和 fromObject
- 如何判断一个数的二进制有多少个1