关于体感互动kinect研究-《基础篇》

目录:

关于体感互动kinect研究-《基础篇》

关于体感互动Airkinect研究-《案例篇1》

关于体感互动Airkinect研究-《案例篇2》

 

 

这里简单的记录一下airKinect的基础。

 

AIRKinect 使用起来非常简单,类似AS3 使用摄像头Camera, 加速器Accelerometer 类, 先判断一下系统是否支持kinect

if(Kinect.isSupported())
{
}

如果支持

if (Kinect.isSupported())
            {
                device = Kinect.getDevice();
                rgbBitmap = new Bitmap();
                addChild(rgbBitmap);
                device.addEventListener(CameraImageEvent.RGB_IMAGE_UPDATE, rgbImageUpdateHandler);
                var settings:KinectSettings = new KinectSettings();
                settings.rgbEnabled = true;
                settings.rgbResolution = CameraResolution.RESOLUTION_160_120;
                device.start(settings);
            }

这里定义device:Kinect 支持的话获取kinect设备(Kinect.getDevice),

我们可以通过KinectSettings设置画面的大小,那kinect提供了几个画面大小:

160*120、320*240、640*480、1280*960

这些设置都是在KinectSettings下的Resolution下设置,并且必须把settings下的对应的获取的是什么画面的**Enabled设置为true

 var settings:KinectSettings = new KinectSettings();
     settings.rgbEnabled = true;
     settings.rgbResolution = CameraResolution.RESOLUTION_160_120;

 

如果要设置手势跟踪 则

        settings.handTrackingEnabled = true;

 最后记得让设备运行设置的内容

 device.start(settings);

那这里可以通过kinect获取 RGB画面、深度画面、红外线画面。

 

RGB画面

if (Kinect.isSupported()) {
            device = Kinect.getDevice();

            rgbBitmap = new Bitmap();
            addChild(rgbBitmap);

            device.addEventListener(CameraImageEvent.RGB_IMAGE_UPDATE, rgbImageUpdateHandler, false, 0, true);
            device.addEventListener(DeviceInfoEvent.INFO, deviceInfoHandler, false, 0, true);
            device.addEventListener(DeviceErrorEvent.ERROR, deviceErrorHandler, false, 0, true);
            device.addEventListener(DeviceEvent.STARTED, kinectStartedHandler, false, 0, true);
            device.addEventListener(DeviceEvent.STOPPED, kinectStoppedHandler, false, 0, true);

            var settings:KinectSettings = new KinectSettings();
            settings.rgbEnabled = true;
            settings.rgbResolution = CameraResolution.RESOLUTION_1280_960;

            device.start(settings);
        }

 

protected function rgbImageUpdateHandler(event:CameraImageEvent):void 
{ rgbBitmap.bitmapData
= event.imageData; }

 

深度画面

 

 if (Kinect.isSupported()) {
            device = Kinect.getDevice();

            depthBitmap = new Bitmap();
            addChild(depthBitmap);

            device.addEventListener(CameraImageEvent.DEPTH_IMAGE_UPDATE, depthImageUpdateHandler, false, 0, true);
            device.addEventListener(DeviceEvent.STARTED, kinectStartedHandler, false, 0, true);
            device.addEventListener(DeviceEvent.STOPPED, kinectStoppedHandler, false, 0, true);

            var settings:KinectSettings = new KinectSettings();
            settings.depthEnabled = true;
            settings.depthResolution = CameraResolution.RESOLUTION_640_480;
            settings.depthShowUserColors = true;

            device.start(settings);
        }

红外线画面(红外线的话则需要判断是否支持红外线)

 if (Kinect.isSupported()) {
            device = Kinect.getDevice();
            if (device.capabilities.hasInfraredSupport) {
                infraredBitmap = new Bitmap();
                addChild(infraredBitmap);

                device.addEventListener(CameraImageEvent.INFRARED_IMAGE_UPDATE, infraredImageUpdateHandler, false, 0, true);
                device.addEventListener(DeviceEvent.STARTED, kinectStartedHandler, false, 0, true);
                device.addEventListener(DeviceEvent.STOPPED, kinectStoppedHandler, false, 0, true);

                var config:OpenNIKinectSettings = new OpenNIKinectSettings();
                config.infraredEnabled = true;
                config.infraredResolution = CameraResolution.RESOLUTION_640_480;

                device.start(config);
            }
        }

 

 

 

 

 

posted @ 2013-05-09 17:26  洪小瑶  阅读(1490)  评论(0编辑  收藏  举报