Directory:
Research on Somatosensory interaction and Kinect-Basic
Study on Somatosensory interaction airkinect-Case study 1
Study on Somatosensory interaction airkinect-Case 2
Here we will briefly record the basics of airkinect.
Airkinect is very easy to use. For example, as3 uses the camera and accelerator accelerometer. First, determine whether the system supports Kinect.
if(Kinect.isSupported()){}
If
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 is defined here: if the Kinect supports this function, obtain the Kinect device (Kinect. getdevice ),
We can set the screen size through kinectsettings, And the Kinect provides several screen sizes:
160*120, 320*240, 640*480, 1280*960
These settings are all set under resolution under kinectsettings, and you must set ** enabled to true for the corresponding images obtained under settings.
var settings:KinectSettings = new KinectSettings(); settings.rgbEnabled = true; settings.rgbResolution = CameraResolution.RESOLUTION_160_120;
If you want to set a gesture tracking
settings.handTrackingEnabled = true;
Finally, remember to set the device to run.
device.start(settings);
This can be obtained through Kinect.RGB Images, deep images, and infrared images.
RGB image
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;}
Deep Screen
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); }
Infrared Image (if it is infrared, You need to determine whether infrared is supported)
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); } }