예제 #1
0
 public override void ProcessClick(System.Drawing.PointF mousePoint, System.Drawing.PointF screenPoint,
                                   CMSExtraTrackingInfo extraInfo, System.Drawing.Bitmap [] frames)
 {
     if (!state.Equals(CMSState.ControlTracking))
     {
         return;
     }
     CurrentMousePoint = screenPoint;
 }
        public override void ProcessMouse(System.Drawing.PointF imagePoint, CMSExtraTrackingInfo extraInfo,
                                          System.Drawing.Bitmap[] frames)
        {
            if (state.Equals(CMSState.ControlTracking) && MoveMouse)
            {
                Bitmap frame = frames[0];
                if (firstFrameInControl)
                {
                    imageOriginPoint = new PointF(imagePoint.X, imagePoint.Y);
                }

                PointF tempCursor = ComputeCursor(new PointF(imagePoint.X, imagePoint.Y), imageOriginPoint);

                if (firstFrameInControl)
                {
                    prevCursorPos.X     = tempCursor.X;
                    prevCursorPos.Y     = tempCursor.Y;
                    firstFrameInControl = false;
                }
                PointF newCursor = AdjustCursor(tempCursor, prevCursorPos);
                prevCursorPos = newCursor;

                long newTickCount = Environment.TickCount;
                if (newTickCount - this.lastTickCount > this.waitTime)
                {
                    int nx = (int)newCursor.X;
                    int ny = (int)newCursor.Y;
                    if (!PauseMouse)
                    {
                        //User32.SetCursorPos(nx, ny);
                        SetCursorPosition(nx, ny);
                    }
                    //mousePointer.X = nx;
                    //mousePointer.Y = ny;
                    lastTickCount = newTickCount;
                }
            }

            clickControlModule.UpdateEyeStatusWindow();
        }
        public override void ProcessMouse(System.Drawing.PointF imagePoint,
                                          CMSExtraTrackingInfo extraInfo,
                                          System.Drawing.Bitmap [] frames)
        {
            if (!state.Equals(CMSState.ControlTracking))
            {
                return;
            }

            Bitmap frame = frames[0];

            if (firstFrameInControl)
            {
                imageOriginPoint = new PointF(imagePoint.X, imagePoint.Y);
            }

            PointF tempCursor = ComputeCursor(new PointF(imagePoint.X, imagePoint.Y), imageOriginPoint);

            if (firstFrameInControl)
            {
                prevCursorPos.X     = tempCursor.X;
                prevCursorPos.Y     = tempCursor.Y;
                firstFrameInControl = false;
            }
            PointF newCursor = AdjustCursor(tempCursor, prevCursorPos);

            prevCursorPos = newCursor;

            long newTickCount = Environment.TickCount;

            if (newTickCount - this.lastTickCount > this.waitTime)
            {
                int nx = (int)newCursor.X;
                int ny = (int)newCursor.Y;
                SetCursorPosition(nx, ny);
                lastTickCount = newTickCount;
            }
        }
예제 #4
0
        public override void ProcessClick(PointF mousePoint, PointF screenPoint, CMSExtraTrackingInfo extraInfo, Bitmap[] frames)
        {
            if (extraInfo != null)
            {
                FastBitmap img = new FastBitmap(frames[0]);
                BlinkLinkCMSExtraTrackingInfo blinkLinkExtraTrackingInfo = (BlinkLinkCMSExtraTrackingInfo)extraInfo;

                eyeClicker.Update(blinkLinkExtraTrackingInfo.LeftEyePoint,
                                  blinkLinkExtraTrackingInfo.RightEyePoint,
                                  Math.Abs(blinkLinkExtraTrackingInfo.LeftEyePoint.X - blinkLinkExtraTrackingInfo.RightEyePoint.X),
                                  img, State == CMSState.ControlTracking);

                extraInfoPassedLastProcess = true;
            }
            else
            {
                if (extraInfoPassedLastProcess)
                {
                    eyeClicker.Reset(false);
                    extraInfoPassedLastProcess = false;
                }
            }
        }
        public override void ProcessClick(System.Drawing.PointF mousePoint, System.Drawing.PointF screenPoint, CMSExtraTrackingInfo extraInfo, System.Drawing.Bitmap[] frames)
        {
            try
            {
                if (prevMousePoint.IsEmpty)
                {
                    prevMousePoint = mousePoint;
                    clickingThresholdForm.checkValue(0, false);
                    return;
                }


                AHMTrackingState curState = AHMTrackingState.NoFeature;

                if (extraInfo != null)
                {
                    curState = ((AHMStateExtraInfo)extraInfo).TrackingState;
                }

                if (curState == AHMTrackingState.NoFeature || curState.Equals(AHMTrackingState.Feature))
                {
                    clickingThresholdForm.Reset();
                    prevMousePoint = mousePoint;
                    clickingThresholdForm.checkValue(0, false);
                    return;
                }

                double dx = prevMousePoint.X - mousePoint.X;
                double dy = prevMousePoint.Y - mousePoint.Y;
                if (dy < 0)
                {
                    dy = 0;
                }
                double dist = dy;

                bool isTraining = curState.Equals(AHMTrackingState.AHMSetup);

                movingAverage.AddPoint(dist);
                clickingThresholdForm.checkValue(movingAverage.EMAverage, isTraining);
                prevMousePoint = mousePoint;


                double thresh = ((double)threshold / 100.0) * clickingThresholdForm.MaxValue;

                if (ExperimentClickFrameSaver.IsExperimentFrameEnabled())
                {
                    ExperimentClickFrameSaver.SaveEvent(new ExperimentFrame(dist, movingAverage.EMAverage, thresh, ClickEvent ? 1 : 0));
                }
            }
            catch
            {
            }
        }
예제 #6
0
 public abstract void ProcessMouse(PointF imagePoint,
                                   CMSExtraTrackingInfo extraInfo,
                                   Bitmap [] frames);
 public abstract void ProcessClick(PointF mousePoint, PointF screenPoint,
                                   CMSExtraTrackingInfo extraInfo,
                                   Bitmap [] frames);
예제 #8
0
        public void ProcessFrame(Bitmap [] frames, bool control)
        {
            lock (mutex)
            {
                PointF imagePoint              = PointF.Empty;
                PointF screenPoint             = PointF.Empty;
                CMSExtraTrackingInfo extraInfo = null;

                if (trackingModule != null)
                {
                    trackingModule.Process(frames);
                    imagePoint = trackingModule.ImagePoint;
                    extraInfo  = trackingModule.ExtraTrackingInfo;
                    if (!trackingModule.ImagePoint.IsEmpty)
                    {
                        if (CMSLogger.CanCreateLogEvent(true, false, false, "CMSLogPointerEvent"))
                        {
                            CMSLogPointerEvent ptrEvent = new CMSLogPointerEvent();
                            if (ptrEvent != null)
                            {
                                ptrEvent.X = (int)trackingModule.ImagePoint.X;
                                ptrEvent.Y = (int)trackingModule.ImagePoint.Y;
                                CMSLogger.SendLogEvent(ptrEvent);
                            }
                        }
                    }
                }

                if (mouseControlModule != null)
                {
                    mouseControlModule.ProcessMouse(imagePoint,
                                                    extraInfo,
                                                    frames);
                    screenPoint = mouseControlModule.MousePointer;
                }

                if (clickControlModule != null)
                {
                    clickControlModule.ProcessClick(imagePoint,
                                                    screenPoint,
                                                    extraInfo,
                                                    frames);
                }

                if (trackingModule != null)
                {
                    trackingModule.DrawOnFrame(frames);
                }
                if (mouseControlModule != null)
                {
                    mouseControlModule.DrawOnFrame(frames);
                }

                if (clickControlModule != null)
                {
                    clickControlModule.DrawOnFrame(frames);
                }


                if (control)
                {
                    if (CMSLogger.CanCreateLogEvent(true, false, false, "CMSLogCursorEvent"))
                    {
                        CMSLogCursorEvent csrEvent = new CMSLogCursorEvent();

                        if (csrEvent != null)
                        {
                            csrEvent.X = (int)mouseControlModule.MousePointer.X;
                            csrEvent.Y = (int)mouseControlModule.MousePointer.Y;
                            CMSLogger.SendLogEvent(csrEvent);
                        }
                    }
                }
            }
        }
 public override void ProcessClick(System.Drawing.PointF mousePoint, System.Drawing.PointF screenPoint, CMSExtraTrackingInfo extraInfo, System.Drawing.Bitmap [] frames)
 {
 }
 public override void ProcessMouse(System.Drawing.PointF imagePoint, CMSExtraTrackingInfo extraInfo, System.Drawing.Bitmap [] frames)
 {
 }