Study on Somatosensory interaction airkinect-Case study 1

Source: Internet
Author: User

Directory:

Research on Somatosensory interaction and Kinect-Basic

Study on Somatosensory interaction airkinect-Case study 1

Study on Somatosensory interaction airkinect-Case 2

 

Case 1:

Objective: To implement the interaction between air production and control by Using Kinect. When the Mobile Virtual Control moves to "play a video" and "sandbox Experience", water waves appear. When the water waves are full, the corresponding page is displayed.

 

Preliminary completion: the source code will be provided later, and the Kinect gesture Control Sandbox will be updated later.

 

 

 

package {    import flash.display.Sprite;    import flash.events.Event;    import flash.ui.Mouse;    import flash.display.StageDisplayState;    import com.as3nui.nativeExtensions.air.kinect.Kinect;    import com.as3nui.nativeExtensions.air.kinect.KinectSettings;    import com.as3nui.nativeExtensions.air.kinect.events.CameraImageEvent;    import com.as3nui.nativeExtensions.air.kinect.constants.CameraResolution;    import flash.display.Bitmap;    import com.as3nui.nativeExtensions.air.kinect.data.User;    import com.as3nui.nativeExtensions.air.kinect.data.SkeletonJoint;    import com.as3nui.nativeExtensions.air.kinect.events.UserEvent;    public class Main extends Sprite    {        private var device:Kinect;        private var bmp:Bitmap;        private var skeletonContainer:Sprite;        private var circle:Circle;        public function Main()        {            if (Kinect.isSupported())            {                bmp = new Bitmap  ;                addChild(bmp);                skeletonContainer = new Sprite  ;                addChild(skeletonContainer);                /*circle = new Circle  ;                circle.x = -100;                circle.y = -100;                skeletonContainer.addChild(circle);*/                device = Kinect.getDevice();                device.addEventListener(CameraImageEvent.DEPTH_IMAGE_UPDATE, rgbImageUpdateHandler);                device.addEventListener(UserEvent.USERS_WITH_SKELETON_ADDED, skeletonsAddedHandler, false, 0, true);                device.addEventListener(UserEvent.USERS_WITH_SKELETON_REMOVED, skeletonsRemovedHandler, false, 0, true);                var settings:KinectSettings = new KinectSettings();                settings.depthEnabled = true;                settings.skeletonEnabled = true;                addEventListener(Event.ENTER_FRAME,loop);                device.start(settings);            }        }        public function skeletonsAddedHandler(event:UserEvent):void        {            circle = new Circle  ;            circle.x = -100;            circle.y = -100;            skeletonContainer.addChild(circle);        }        public function skeletonsRemovedHandler(event:UserEvent):void        {            clearContainer();        }        public function loop(e:Event):void        {            //clearContainer();            for each (var user:User in device.usersWithSkeleton)            {                var head:SkeletonJoint = user.getJointByName("right_hand");                circle.x = head.position.depthRelative.x * stage.stageWidth;                circle.y = head.position.depthRelative.y * stage.stageHeight;                /*for each (var joint:SkeletonJoint in user.skeletonJoints)                {                skeletonContainer.graphics.beginFill(0xff0000)                skeletonContainer.graphics.drawCircle(joint.position.depth.x,joint.position.depth.y,3)                skeletonContainer.graphics.endFill()                                var circle:Circle = new Circle  ;                circle.x = joint.position.depth.x;                circle.y = joint.position.depth.y;                skeletonContainer.addChild(circle);                                }*/            }        }        public function rgbImageUpdateHandler(event:CameraImageEvent):void        {            bmp.bitmapData = event.imageData;        }        public function clearContainer():void        {            while (skeletonContainer.numChildren != 0)            {                skeletonContainer.removeChildAt(0);            }        }    }}

 

The rest is only the collision detection to determine whether or not to select.

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.