예제 #1
0
    void Start()
    {
        pp = new PXCUPipeline();

        int[] size = new int[2] {
            320, 240
        };
        if (pp.Init(PXCUPipeline.Mode.GESTURE))
        {
            pp.QueryLabelMapSize(size);
            print("LabelMap: width=" + size[0] + ", height=" + size[1]);
            labelmap = new byte[size[0] * size[1]];
        }
        else
        {
            options.SetMessage("Failed to detect the Creative* camera. Please plugin the camera and click restart.");
        }
        handImage = new Texture2D(size[0], size[1], TextureFormat.ARGB32, false);
        ZeroImage(handImage);
        handData    = new PXCMGesture.GeoNode[2][];
        handData[0] = new PXCMGesture.GeoNode[6];
        handData[1] = new PXCMGesture.GeoNode[6];

        mouse_nodes = new PXCMGesture.GeoNode[1][] { new PXCMGesture.GeoNode[12] };
    }
예제 #2
0
        private PXCMGesture.GeoNode QueryGeoNode(PXCMGesture.GeoNode.Label bodyLabel)
        {
            var values = new PXCMGesture.GeoNode();

            QueryGesture().QueryNodeData(0, bodyLabel, out values);
            return(values);
        }
예제 #3
0
 public bool QueryGeoNode(PXCMGesture.GeoNode.Label body, out PXCMGesture.GeoNode data)
 {
     if (initialized)
     {
         return(QueryGeoNodeC(instance, body, out data));
     }
     data = new PXCMGesture.GeoNode();
     return(false);
 }
예제 #4
0
        private void TrackPosition(Item item, PXCMGesture.GeoNode geoNode)
        {
            item.IsVisible = geoNode.body != PXCMGesture.GeoNode.Label.LABEL_ANY;
            if (!item.IsVisible)
            {
                return;
            }
            var imagePosition = ToPoint3D(geoNode.positionImage);
            var worldPosition = ToPoint3D(geoNode.positionWorld);

            item.Position = CreatePosition(imagePosition, worldPosition);
        }
예제 #5
0
    public override bool OnNewFrame()
    {
        /* Retrieve individual node data */
           PXCMGesture.GeoNode thumb_data;
           //gesture.
           QueryGesture().QueryNodeData(0, PXCMGesture.GeoNode.Label.LABEL_BODY_HAND_PRIMARY | PXCMGesture.GeoNode.Label.LABEL_FINGER_THUMB, out thumb_data);

           /* Retrieve data of all five fingers in a single call */
           PXCMGesture.GeoNode[] hand_data = new PXCMGesture.GeoNode[5];
           //gesture.
           QueryGesture().QueryNodeData(0, PXCMGesture.GeoNode.Label.LABEL_BODY_HAND_PRIMARY | PXCMGesture.GeoNode.Label.LABEL_FINGER_THUMB, hand_data);
           return true;
    }
예제 #6
0
 private void TrackOpeness(FlexiblePart part, PXCMGesture.GeoNode geoNode)
 {
     if (!part.IsVisible)
     {
         return;
     }
     if (geoNode.openness > 75)
     {
         part.IsOpen = true;
     }
     else if (geoNode.openness < 10)
     {
         part.IsOpen = false;
     }
 }
예제 #7
0
        private void TrackPosition(Item item, PXCMGesture.GeoNode geoNode)
        {
            item.IsVisible = geoNode.body != PXCMGesture.GeoNode.Label.LABEL_ANY;
            if (!item.IsVisible)
            {
                return;
            }
            Func <double, double> meterToCentimeters = p => p * 100;

            item.Position = new Point3D {
                X = geoNode.positionImage.x,
                Y = geoNode.positionImage.y,
                Z = meterToCentimeters(geoNode.positionWorld.y)
            };
        }
        public void  ProcessNode(PXCMGesture.GeoNode node)
        {
            Debug.WriteLine("Label=" + node.body);
            PXCMPoint3DF32 pos = node.positionImage;

            if ((node.body & PXCMGesture.GeoNode.Label.LABEL_FINGER_RING) != 0)
            {
                Debug.WriteLine("無名指 X=" + pos.x + ", Y=" + pos.y);
                MainWindow.mainwin.MoveEllipse2((int)pos.x, (int)pos.y);
            }
            else if ((node.body & PXCMGesture.GeoNode.Label.LABEL_FINGER_INDEX) != 0)
            {
                Debug.WriteLine("食指 X=" + pos.x + ", Y=" + pos.y);
                MainWindow.mainwin.MoveEllipse1((int)pos.x, (int)pos.y);
            }
        }
예제 #9
0
 private PXCMGesture.GeoNode QueryGeoNode(PXCMGesture.GeoNode.Label bodyLabel) {
     var values = new PXCMGesture.GeoNode();
     QueryGesture().QueryNodeData(0, bodyLabel, out values);
     return values;
 }
예제 #10
0
 public bool QueryGeoNode(PXCMGesture.GeoNode.Label body, out PXCMGesture.GeoNode data)
 {
     if (instance!=IntPtr.Zero) return QueryGeoNodeC(instance, body,out data);
     data=new PXCMGesture.GeoNode();
     return false;
 }
예제 #11
0
 private static extern bool QueryGeoNodeC(IntPtr pp, PXCMGesture.GeoNode.Label body, out PXCMGesture.GeoNode data);
예제 #12
0
        public void update(float dt)
        {
            if (!this.AcquireFrame(false)){
                return;
            }

            PXCMGesture.GeoNode geoNode1 = new PXCMGesture.GeoNode();
            PXCMGesture.GeoNode geoNode2 = new PXCMGesture.GeoNode();

            QueryGesture().QueryNodeData(0, PXCMGesture.GeoNode.Label.LABEL_BODY_HAND_PRIMARY, out geoNode1);
            QueryGesture().QueryNodeData(0, PXCMGesture.GeoNode.Label.LABEL_BODY_HAND_SECONDARY, out geoNode2);

            CCSize screenSize = CCDirector.SharedDirector.WinSize;

            float cameraX = geoNode1.positionImage.x;
            float cameraY = geoNode1.positionImage.y;
            float screenWidth = (float)screenSize.Width * 1.5f;
            float screenHeight = (float)screenSize.Height * 1.5f;

            this.hand1Pos = new CCPoint(screenWidth - cameraX * (screenWidth / 320) - 100,
                                 screenHeight - cameraY * (screenHeight / 240));

            this.hand2Pos = new CCPoint((float)(screenSize.Width * 1.5 - geoNode2.positionImage.x * (screenSize.Width * HAND_PRECISION / 320) - 100),
                                 (float)(screenSize.Height * 1.5 - geoNode2.positionImage.y * (screenSize.Height * HAND_PRECISION / 240)));

            this.labelPos.SetString("X: " + geoNode1.positionImage.x + " Y: " + geoNode1.positionImage.y);

            if (geoNode1.opennessState == PXCMGesture.GeoNode.Openness.LABEL_CLOSE)
            {
                newTouches.Clear();
                newTouches.Add(new CCTouch(1, hand1Pos.X, hand1Pos.Y));

                CCDirector.SharedDirector.TouchDispatcher.TouchesBegan(newTouches);

                if (this.hand1sprite == null)
                {
                    return;
                }
                this.hand1sprite.RemoveFromParentAndCleanup(true);
                this.hand1sprite = new CCSprite("hand_close.png");
                this.hand1sprite.Opacity = 150;
                this.parent.AddChild(hand1sprite);
                this.isHand1Closed = true;

            }
            else if (this.isHand1Closed)
            {
                newEndTouches.Clear();
                newEndTouches.Add(new CCTouch(1, hand1Pos.X, hand1Pos.Y));

                CCDirector.SharedDirector.TouchDispatcher.TouchesEnded(newEndTouches);

                if (this.hand1sprite == null)
                {
                    return;
                }
                this.hand1sprite.RemoveFromParentAndCleanup(true);
                this.hand1sprite = new CCSprite("hand.png");
                this.hand1sprite.Opacity = 150;
                this.parent.AddChild(hand1sprite);
                this.isHand1Closed = false;
            }

            if (hand1sprite.Parent == null || hand2sprite.Parent ==null ){
                return;
            }
            this.hand1sprite.Position = this.hand1Pos;
            this.hand2sprite.Position = this.hand2Pos;

            this.ReleaseFrame();
        }
 public bool QueryGeoNode(PXCMGesture.GeoNode.Label body, out PXCMGesture.GeoNode data)
 {
     if (initialized) return QueryGeoNodeC(instance, body,out data);
     data=new PXCMGesture.GeoNode();
     return false;
 }