Exemplo n.º 1
0
        public static FrameInformation DesktopCapture()
        {
            var frameInfo = new FrameInformation();

            if (_canUseGpuAcceleration)
            {
                frameInfo.UsingGpu = true;
                var desktopFrame = GpuCapture();
                if (desktopFrame != null)
                {
                    frameInfo.FinishedRegions = desktopFrame.FinishedRegions;
                }
            }
            else
            {
                var screenData = GetImageChange(CaptureDesktop());
                if (screenData.ScreenBitmap == null || screenData.Rectangle == Rectangle.Empty)
                {
                    return(null);
                }
                frameInfo.Bounds      = screenData.Rectangle;
                frameInfo.ScreenImage = screenData.ScreenBitmap;
            }
            return(frameInfo);
        }
Exemplo n.º 2
0
        public Waiting()
        {
            var waitingFrames = new IAnimationFrame[]
            {
                new AnimationFrame(new FrameInformation(118, 6, 32, 39), 500),
                new AnimationFrame(new FrameInformation(231, 6, 32, 39), 500)
            };

            var fallingAsleepFrames = new IAnimationFrame[]
            {
                new AnimationFrame(new FrameInformation(192, 6, 32, 39), 500),
                new AnimationFrame(new FrameInformation(271, 6, 32, 39), 500)
            };

            var sleepingFrame = new FrameInformation(81, 6, 31, 39);
            var wakeUpFrame   = new FrameInformation(157, 6, 32, 39);

            _animation = new Animation(new IAnimationFrame[]
            {
                new LimitedAnimation(waitingFrames, 10),
                new LimitedAnimation(fallingAsleepFrames, 10),
                new AnimationFrame(sleepingFrame, 3000),
                new AnimationFrame(wakeUpFrame, 500)
            });
        }
Exemplo n.º 3
0
        /// <summary>
        /// Checks the integrity of the Chunk. Reports Error Messages if values are missing
        /// </summary>
        /// <returns></returns>
        public override CheckResult CheckIntegrity() {
            CheckResult result = new CheckResult();

            if (Name == null) {
                result.AddError("Name of the Selection is set to NULL! Must be a string!");
            }

            if (FrameInformation == null) {
                result.AddError("Frame Information of the Selection is set to NULL!");
            }

            if (BoundingBox == null) {
                result.AddError("Bounding Box of the Selection is set to NULL!");
            }


            try {
                result = CheckResult.Merge(result, FrameInformation.CheckIntegrity(), BoundingBox.CheckIntegrity());
            }
            catch (ArgumentNullException ex) {
                result.AddError(ex.Message);
                return result;
            }
            catch (Exception ex) {
                result.AddError("An Unknown Error occured! " + ex.Message);
                return result;
            }

            return result;
        }
Exemplo n.º 4
0
    FrameInformation fetchFrameInformation()
    {
        FrameInformation frameInfo = new FrameInformation();

        frameInfo.grabHeld  = grabHeld;
        frameInfo.pinchHeld = pinchHeld;
        foreach (Leap.Finger f in hand.Fingers)
        {
            FingerInformation fingerInfo = new FingerInformation();
            fingerInfo.isExtended   = f.IsExtended;
            fingerInfo.direction    = f.Direction.ToVector3();
            fingerInfo.padDirection = Vector3.Cross(fingerInfo.direction, Vector3.Cross(fingerInfo.direction, f.bones[1].Direction.ToVector3()));
            fingerInfo.tipPosition  = f.TipPosition.ToVector3();
            fingerInfo.tipVelocity  = f.TipVelocity.ToVector3();
            switch (f.Type)
            {
            case Leap.Finger.FingerType.TYPE_INDEX:
                frameInfo.index = fingerInfo;
                break;

            case Leap.Finger.FingerType.TYPE_MIDDLE:
                frameInfo.middle = fingerInfo;
                break;

            case Leap.Finger.FingerType.TYPE_RING:
                frameInfo.ring = fingerInfo;
                break;

            case Leap.Finger.FingerType.TYPE_PINKY:
                frameInfo.pinky = fingerInfo;
                break;

            case Leap.Finger.FingerType.TYPE_THUMB:
                frameInfo.thumb = fingerInfo;
                break;
            }
        }
        if (handedness == "Right")
        {
            hand = Hands.Right;
        }
        else
        {
            hand = Hands.Left;
        }
        HandInformation handInfo = new HandInformation();

        handInfo.direction    = hand.Direction.ToVector3();
        handInfo.pitch        = hand.Direction.Pitch;
        handInfo.roll         = hand.Direction.Roll;
        handInfo.yaw          = hand.Direction.Yaw;
        handInfo.palmPosition = hand.PalmPosition.ToVector3();
        handInfo.palmVelocity = hand.PalmVelocity.ToVector3();
        handInfo.palmNormal   = hand.PalmNormal.ToVector3();
        handInfo.rotation     = hand.Rotation.ToQuaternion();
        frameInfo.hand        = handInfo;
        return(frameInfo);
    }
Exemplo n.º 5
0
        public IViewComponentResult Invoke(int notificationId)
        {
            FrameInformation frame = CameraService.GetEarliestStatFrameForNotification(notificationId);

            if (frame == null)
            {
                return(Content(string.Empty));
            }
            return(View("NotificationFramesCard", frame));
        }
Exemplo n.º 6
0
 // Use this for initialization
 void Start()
 {
     util              = new HandsUtil();
     frameQueue        = new Queue <FrameInformation>();
     currentFrame      = new FrameInformation();
     tapCooldownTime   = Time.time;
     swipeCooldownTime = Time.time;
     forming           = false;
     if (handedness == "Right")
     {
         palmDirectorRight.OnActivate.AddListener(freeFormRight);
         palmDirectorLeft.OnActivate.AddListener(freeFormLeft);
         palmDirectorRightUp.OnActivate.AddListener(freeFormEndRight);
         palmDirectorLeftUp.OnActivate.AddListener(freeFormEndLeft);
         PinchDetectorInitRight();
         gunReady.OnActivate.AddListener(CockGun);
         gunFire.OnActivate.AddListener(FireGun);
     }
 }
Exemplo n.º 7
0
        public JpgStatFrameList GetStatFrameList(int cameraId)
        {
            List <DatabasePerSecondStat> statsForCamera = _dbQueryService.GetPerSecondStatsForCamera(cameraId);
            JpgStatFrameList             frmList        = new JpgStatFrameList();

            frmList.JpgFramePathList = new List <FrameInformation>();
            foreach (DatabasePerSecondStat stat in statsForCamera)
            {
                if (!stat.FrameJpgPath.IsNullOrEmpty())
                {
                    FrameInformation frmInfo = new FrameInformation(stat);
                    if (frmInfo.FrmJpgRelPath.IsNullOrEmpty() == false)
                    {
                        frmList.JpgFramePathList.Add(frmInfo);
                    }
                }
            }

            return(frmList);
        }
Exemplo n.º 8
0
        /// <summary>
        /// 获取栈帧信息
        /// </summary>
        /// <param name="stackFrame">栈帧</param>
        /// <param name="symbolTable">符号表</param>
        /// <returns>栈帧信息</returns>
        private List <FrameInformation> GetFrame(StackFrame stackFrame, Dictionary <string, int> symbolTable)
        {
            List <FrameInformation> informations = new List <FrameInformation>();

            // 遍历符号表填充栈帧信息
            foreach (KeyValuePair <string, int> item in symbolTable)
            {
                string name    = item.Key;
                int    address = item.Value;
                Object value   = stackFrame.getVariable(address);
                if (value != null)
                {
                    FrameInformation information = new FrameInformation();
                    information.Name    = name;
                    information.Address = address;
                    information.Value   = value.ToString();
                    informations.Add(information);
                }
            }
            return(informations);
        }
Exemplo n.º 9
0
        public FrameInformation GetEarliestStatFrameForNotification(int notificationId)
        {
            DatabaseNotification         dbNotification = _dbQueryService.GetNotificationById(notificationId);
            DatabaseAlert                dbAlert        = _dbQueryService.GetAlertById(dbNotification.AlertId);
            List <DatabasePerSecondStat> statsForCamera =
                _dbQueryService.GetPerSecondStatsWithFrmTriggeringAlert(dbAlert, dbNotification.TriggerDateTime, dbNotification.TriggerDateTime.AddMinutes(30));
            var sortedStats = statsForCamera.OrderBy(stat => stat.DateTime);

            foreach (DatabasePerSecondStat stat in sortedStats)
            {
                if (!stat.FrameJpgPath.IsNullOrEmpty())
                {
                    FrameInformation frmInfo = new FrameInformation(stat);
                    if (frmInfo.FrmJpgRelPath.IsNullOrEmpty() == false)
                    {
                        return(frmInfo);
                    }
                }
            }

            return(null);
        }
Exemplo n.º 10
0
        public JpgStatFrameList GetTriggeringStatsFrameList(int notificationId)
        {
            DatabaseNotification         dbNotification = _dbQueryService.GetNotificationById(notificationId);
            DatabaseAlert                dbAlert        = _dbQueryService.GetAlertById(dbNotification.AlertId);
            List <DatabasePerSecondStat> statsForCamera = _dbQueryService.GetPerSecondStatsWithFrmTriggeringAlert(dbAlert, dbNotification.TriggerDateTime, dbNotification.TriggerDateTime.AddMinutes(30));
            JpgStatFrameList             frmList        = new JpgStatFrameList();

            frmList.JpgFramePathList = new List <FrameInformation>();
            foreach (DatabasePerSecondStat stat in statsForCamera)
            {
                if (!stat.FrameJpgPath.IsNullOrEmpty())
                {
                    FrameInformation frmInfo = new FrameInformation(stat);
                    if (frmInfo.FrmJpgRelPath.IsNullOrEmpty() == false)
                    {
                        frmList.JpgFramePathList.Add(frmInfo);
                    }
                }
            }

            return(frmList);
        }
Exemplo n.º 11
0
        public FrameInformation GetFullFrame()
        {
            HandleDesktop();
            var tempBounds = Display.GetWindowRectangle();
            var frameInfo  = new FrameInformation
            {
                Bounds      = tempBounds,
                ScreenImage = ScreenData.CaptureDesktop()
            };

            if (frameInfo.ScreenImage != null)
            {
                return(frameInfo);
            }
            var bmp = new Bitmap(frameInfo.Bounds.Width, frameInfo.Bounds.Height);

            using (var gfx = Graphics.FromImage(bmp))
                using (var brush = new SolidBrush(Color.FromArgb(67, 75, 99)))
                {
                    gfx.FillRectangle(brush, 0, 0, frameInfo.Bounds.Width, frameInfo.Bounds.Height);
                }
            frameInfo.ScreenImage = bmp;
            return(frameInfo);
        }
Exemplo n.º 12
0
    // Update is called once per frame
    void Update()
    {
        removeExtraHands(); //Recent test found that a third hand can enter scene. Gets that outta there
        if (handedness == "Right")
        {
            hand = Hands.Right;
        }
        else
        {
            hand = Hands.Left;
        }
        if (hand == null)
        {
            OnPinchGone();
        }
        position = util.getIndexPos(hand);
        #region  FreeForm Logic
        //I really hate this logic section.
        //end case
        if (formingEnabled)
        {
            if (pinchWait)
            {
                pinchCounter--;
                if (pinchCounter <= 0)
                {
                    OnPinchGone();
                }
            }
            if (!hudAnchor)
            {
                if (!leftStart && !rightStart && forming && util.checkHandsDist() < .1f)
                {
                    Debug.Log("Ending");
                    forming = false;
                    freeFormEnd();
                    rFrameCount = 0;
                    lFrameCount = 0;
                }
                //continue
                if (forming)
                {
                    return;
                }
                //start
                if (rightStart && leftStart && util.checkHandsDist() < .2f)
                {
                    forming = true;
                    freeForm();
                    rFrameCount = 0;
                    lFrameCount = 0;
                }
            }
        }
        #endregion
        swipe = false;
        #region Pinch and Grab Logic

        /*bool grab = checkGrab();
         * if (!grab)
         * {
         *  grab = checkRecentGrabData();
         *  if (grab)
         *      flippedGrab = true;
         * }
         * //begin checking pinch logic
         * bool pinch = false;
         * swipe = false;
         * if (!grab)
         * {
         *  //Debug.Log("Not Grabbing");
         *  OnGrabGone();
         *  pinch = checkPinch();
         *  //if pinch is false, chyeck recent frames to determine if its a leap motion hiccup
         *  if (!pinch)
         *  {
         *      pinch = checkRecentPinchData();
         *      if (pinch) flippedPinch = true;
         *  }
         * }
         * if (!pinch) OnPinchGone();
         * //Final grab check
         * if (grab && !grabHeld && !flippedGrab)
         * {
         *  Debug.Log("Grabbing");
         *  OnGrabHeld();
         * }
         * //Final pinch check
         * else if (pinch && !pinchHeld && !flippedPinch)
         * {
         *  OnPinchHeld();
         * }*/
        #endregion

        #region Swipe and Tap Logic
        //Begin swipe check
        if (checkSwipe())
        {
            //We have a cooldown so swipes cannot be spammed
            if (Time.time > swipeCooldownTime)
            {
                swipe = true;
                swipeMade();
                swipeCooldownTime = Time.time + cooldown;
            }
            else
            {
                Debug.Log("Cooldown!!");
            }
        }
        if (checkTap() && !swipe)
        {
            if (Time.time > tapCooldownTime)
            {
                tapMade(frameQueue.ToArray()[frameQueue.Count - 2].index.tipPosition);
                tapCooldownTime = Time.time + tapCooldown;
            }
        }
        #endregion

        #region Additional Pinch and Grab logic
        if (flippedPinch)
        {
            pinchHeld    = false;
            flippedPinch = false;
            pinchInput   = true;
        }
        else
        {
            pinchInput = false;
        }
        if (flippedGrab)
        {
            grabHeld     = false;
            flippedPinch = false;
            gripInput    = true;
        }
        else
        {
            gripInput = false;
        }
        #endregion
        if (hand != null)
        {
            currentFrame = fetchFrameInformation();
            frameQueue.Enqueue(currentFrame);
            if (frameQueue.Count > heldFrames)
            {
                frameQueue.Dequeue();
            }
        }
    }//end Update()