Beispiel #1
0
        public void updateMarker(object sender, MarkerEventArgs args)
        {
            // Do not draw if the marker's wasn't previously found
            if (!args.EventMarker.PreviousData.Present)
            {
                return;
            }

            // Draw a segment on our canvas between the marker and where it was previously found
            MarkerEventData data = args.EventData;

            //pen.Color = Color.FromArgb(128, data.ColorAvg.R, data.ColorAvg.G, data.ColorAvg.B);
            //pen.Width = data.Area / 60;
            //p1.X = (data.X - data.DX);
            //p1.Y = (data.Y - data.DY);
            p2.X = data.X;
            p2.Y = data.Y;

            //p3.X = (int)(data.X / (float)cameraWidth * displayWidth);
            //p3.Y = (int)(data.Y / (float)cameraHeight * displayHeight);
            //canvasGFX.DrawLine(pen, p1, p2);
            canvasGFX.Clear(Color.Transparent);

            if (DateTime.Now.Ticks - pics.sTime.Ticks > pic.Delay)
            {
                pic = pics.getPicAutoPlus();
            }
            canvasGFX.DrawImage(pic.Img, new Rectangle(p2, pic.Img.Size));
        }
    public override void MarkerAppear(MarkerEventData data)
    {
        if (!Client.IsConnected())
        {
            return;
        }

        if (createScheme)
        {
            var pos = CoordMappingSchemeManager.Instance.Mapping(
                new Vector3((float)(data.Data.X / Screen.width), (1.0f - (float)(data.Data.Y / Screen.height))));

            FreeCallRequest request = new FreeCallRequest();

            request.Params.Add(Any.Pack(new StringValue {
                Value = "SetCameraPositionAndDirection"
            }));
            request.Params.Add(Any.Pack(new Vec3 {
                X = pos.x, Y = pos.y, Z = pos.z
            }));
            request.Params.Add(Any.Pack(new FloatValue {
                Value = (float)data.Data.Angle + GetComponent <Marker>().AngleOffset
            }));

            Client.RequestOneway("CommonService@freeCall", request);
        }
    }
    public override void MarkerAppear(MarkerEventData data)
    {
        this.text.text = MarkerName;

        MarkerPositionToWorldPosition((float)data.Data.X, (float)data.Data.Y);

        events.GotoAndPlay(1);
    }
    public override void MarkerUpdate(MarkerEventData data)
    {
        if (!Client.IsConnected())
        {
            return;
        }

        if (!createScheme)
        {
            createScheme = true;

            StringValue request = new StringValue {
                Value = "City"
            };

            Client.Request("CommonService@mapping", request, response => {
                var positions = (MappingPositions)response;

                var anchor = AlignAnchorGroupTable.Instance.GetComponent("City");

                var anchor1 = GetAnchor(anchor.Index1.GetComponent <RectTransform>().anchoredPosition);
                var anchor2 = GetAnchor(anchor.Index2.GetComponent <RectTransform>().anchoredPosition);
                var anchor3 = GetAnchor(anchor.Index3.GetComponent <RectTransform>().anchoredPosition);

                var scheme = new CoordMappingScheme(new Vector4[] {
                    anchor1,
                    anchor2,
                    anchor3
                }, new Vector4[] {
                    new Vector3(positions.Index1.X, positions.Index1.Y, positions.Index1.Z),
                    new Vector3(positions.Index2.X, positions.Index2.Y, positions.Index2.Z),
                    new Vector3(positions.Index3.X, positions.Index3.Y, positions.Index3.Z),
                });

                CoordMappingSchemeManager.Instance.Register("City", scheme);
            });
        }

        if (createScheme)
        {
            var pos = CoordMappingSchemeManager.Instance.Mapping(
                new Vector3((float)(data.Data.X / Screen.width), (1.0f - (float)(data.Data.Y / Screen.height))));

            FreeCallRequest freeCallRequest = new FreeCallRequest();

            freeCallRequest.Params.Add(Any.Pack(new StringValue {
                Value = "SetCameraPositionAndDirection"
            }));
            freeCallRequest.Params.Add(Any.Pack(new Vec3 {
                X = pos.x, Y = pos.y, Z = pos.z
            }));
            freeCallRequest.Params.Add(Any.Pack(new FloatValue {
                Value = (float)data.Data.Angle + GetComponent <Marker>().AngleOffset
            }));

            Client.RequestOneway("CommonService@freeCall", freeCallRequest);
        }
    }
    public override void MarkerUpdate(MarkerEventData data)
    {
        if (marker != null)
        {
            if (marker.MarkerFollow)
            {
                MarkerPositionToWorldPosition((float)data.Data.X, (float)data.Data.Y);
            }

            rotation.transform.localEulerAngles = new Vector3(0, (float)data.Data.Angle, 0);
            tips.SetActive(!(data.Data.Angle > 80.0f && data.Data.Angle < 250.0f));
        }
    }
        public void updateMarker(object sender, MarkerEventArgs args)
        {
            // Do not draw if the marker's wasn't previously found
            if (!args.EventMarker.PreviousData.Present)
            {
                return;
            }

            // Draw a segment on our canvas between the marker and where it was previously found
            MarkerEventData data = args.EventData;

            _pen.Color = Color.FromArgb(128, data.ColorAvg.R, data.ColorAvg.G, data.ColorAvg.B);
            _pen.Width = data.Area / 60;
            _p1.X      = (data.X - data.DX);
            _p1.Y      = (data.Y - data.DY);
            _p2.X      = data.X;
            _p2.Y      = data.Y;
            _canvasGFX.DrawLine(_pen, _p1, _p2);
        }
Beispiel #7
0
 private void UpdateMarkerDataInUI(MarkerEventData data)
 {
     if (data.Present)
     {
         labelMarkerData.Text =
             "Center X:  " + data.X + "\n"
             + "Center Y:  " + data.Y + "\n"
             + "DX:        " + data.DX + "\n"
             + "DY:        " + data.DY + "\n"
             + "Area:      " + data.Area + "\n"
             + "Left:      " + data.Bounds.Left + "\n"
             + "Right:     " + data.Bounds.Right + "\n"
             + "Top:       " + data.Bounds.Top + "\n"
             + "Bottom:    " + data.Bounds.Bottom + "\n";
     }
     else
     {
         labelMarkerData.Text = "Marker not present";
     }
 }
        private void UpdateMarkerDataInUI(MarkerEventData data)
        {
            if (data.Present)
            {
                string text =
                      "Center X:  " + data.X + "#"
                    + "Center Y:  " + data.Y + "#"
                    + "DX:        " + data.DX + "#"
                    + "DY:        " + data.DY + "#"
                    + "Area:      " + data.Area + "#"
                    + "Left:      " + data.Bounds.Left + "#"
                    + "Right:     " + data.Bounds.Right + "#"
                    + "Top:       " + data.Bounds.Top + "#"
                    + "Bottom:    " + data.Bounds.Bottom + "#";

                this.textBoxMarkerData.Lines = text.Split('#');
            }
            else
                this.textBoxMarkerData.Text = "Marker not present";
        }
Beispiel #9
0
 private void UpdateMarkerDataInUI(MarkerEventData data)
 {
     if (data.Present)
     {
         labelMarkerData.Text =
               "Center X:  " + data.X + "\n"
             + "Center Y:  " + data.Y + "\n"
             + "DX:        " + data.DX + "\n"
             + "DY:        " + data.DY + "\n"
             + "Area:      " + data.Area + "\n"
             + "Left:      " + data.Bounds.Left + "\n"
             + "Right:     " + data.Bounds.Right + "\n"
             + "Top:       " + data.Bounds.Top + "\n"
             + "Bottom:    " + data.Bounds.Bottom + "\n";
     }
     else
         labelMarkerData.Text = "Marker not present";
 }
        public void updateMarker(object sender, MarkerEventArgs args)
        {
            MarkerEventData data = args.EventData;

            _xm = data.X;
            _ym = data.Y;

            // Translate x & y coords to have an origin of the image center, and flip Y
            int x = data.X - _captureWidth / 2;
            int y = _captureHeight / 2 - data.Y;

            // Is the marker in our null region?
            if (_nullZone.Contains(new Point(x, y)))
            {
                _hudStringMarkerDir = "Null (Center)";
                _snake.dxm          = _snake.dym = 0;
                return;
            }

            // Get the angle of the point from the center
            // angle: E = 0, W = 180(ccw)/-180(cw)
            int angle = (int)(Math.Atan2(y, x) * 180 / Math.PI);

            // Compare the angle with the diagonals and change the snake direction, ignore double-backing
            if (angle < _angleSW || angle >= _angleNW)
            {
                _hudStringMarkerDir = "Left";
                if (_snake.dx == 1)
                {
                    return;
                }
                _snake.dxm = -1;
                _snake.dym = 0;
            }
            else if (angle < _angleSE)
            {
                _hudStringMarkerDir = "Down";
                if (_snake.dy == -1)
                {
                    return;
                }
                _snake.dxm = 0;
                _snake.dym = 1;
            }
            else if (angle < _angleNE)
            {
                _hudStringMarkerDir = "Right";
                if (_snake.dx == -1)
                {
                    return;
                }
                _snake.dxm = 1;
                _snake.dym = 0;
            }
            else /*if (angle < _angleNW)*/
            {
                _hudStringMarkerDir = "Up";
                if (_snake.dy == 1)
                {
                    return;
                }
                _snake.dxm = 0;
                _snake.dym = -1;
            }
        }
 public override void MarkerDisappear(MarkerEventData data)
 {
 }
Beispiel #12
0
        private void UpdateMarkerDataInUI(MarkerEventData data)
        {
            if (x.Count < liczba_usrednianych_klatek)
            {
                x.Add(Wspolny.X(_markerSelected));
                y.Add(Wspolny.Y(_markerSelected));
            }
            else
            {
                x.RemoveAt(0);
                x.Add(Wspolny.X(_markerSelected));
                y.RemoveAt(0);
                y.Add(Wspolny.Y(_markerSelected));

                curent_x = Cursor.Position.X;
                curent_y = Cursor.Position.Y;

                int x_suma = 0;
                int y_suma = 0;

                int x_wynik=0;
                int y_wynik=0;
                if (rodzaj_sredniej == 0)
                {
                    for (int i = 0; i < liczba_usrednianych_klatek; i++)
                    {
                        x_suma += x[i];
                        y_suma += y[i];
                    }
                    x_wynik = Convert.ToInt32(x_suma / liczba_usrednianych_klatek - 1);
                    y_wynik = Convert.ToInt32(y_suma / liczba_usrednianych_klatek - 1);
                }
                else if (rodzaj_sredniej == 1)
                {
                    int dzielnik=0;
                    for (int i = 0; i < liczba_usrednianych_klatek; i++)
                    {
                        if (i == 0)
                        {
                            x_suma += x[i];
                            y_suma += y[i];
                        }
                        else
                        {
                            x_suma += x[i] * i;
                            y_suma += y[i] * i;
                        }
                        dzielnik +=i;
                    }
                    x_wynik = Convert.ToInt32(x_suma / dzielnik);
                    y_wynik = Convert.ToInt32(y_suma / dzielnik);
                }
                else if (rodzaj_sredniej == 2)
                {
                    int dzielnik = 0;
                    double alfa = 2 / liczba_usrednianych_klatek;
                    for (int i = 0; i < liczba_usrednianych_klatek; i++)
                    {
                        if (i == 0)
                        {
                            x_suma += x[i];
                            y_suma += y[i];
                            dzielnik += 1;
                        }
                        else
                        {
                            int a = Convert.ToInt32(potega((1 - alfa), i));
                            x_suma += x[i] * a;
                            y_suma += y[i] * a;
                            dzielnik += a;
                        }

                    }
                    x_wynik = Convert.ToInt32(x_suma / dzielnik);
                    y_wynik = Convert.ToInt32(y_suma / dzielnik);
                }
                double y_screen_max = SystemInformation.PrimaryMonitorSize.Height;
                double x_screen_max = SystemInformation.PrimaryMonitorSize.Width;
                double x_camera_max = Wspolny.ostatnia_klatka.Width;
                double y_camera_max = Wspolny.ostatnia_klatka.Height;
                double x_waga = x_screen_max / x_camera_max;
                double y_waga = y_screen_max / y_camera_max;
                SetCursorPos(Convert.ToInt32(x_wynik*x_waga),Convert.ToInt32(y_wynik*y_waga));
               // MessageBox.Show(x_wynik.ToString() + "  " + x_waga.ToString() + "   " + Convert.ToInt32(x_wynik * x_waga).ToString() +"\n"+
                //    x_screen_max.ToString() + "  " + x_camera_max.ToString());
            }
        }
 public override void MarkerDisappear(MarkerEventData data)
 {
     events.GotoAndPlay(71);
 }
        /// <summary>
        /// Show marker information in textbox
        /// </summary>
        /// <param name="data"></param>
        private void UpdateMarkerDataInUI(MarkerEventData data)
        {
            if (data.Present)
            {
                string text =
                      "Center X:  " + data.X + "#"
                    + "Center Y:  " + data.Y + "#"
                    + "DX:        " + data.DX + "#"
                    + "DY:        " + data.DY + "#"
                    + "Area:      " + data.Area + "#"
                    + "Left:      " + data.Bounds.Left + "#"
                    + "Right:     " + data.Bounds.Right + "#"
                    + "Top:       " + data.Bounds.Top + "#"
                    + "Bottom:    " + data.Bounds.Bottom + "#"
                    + "CameraWidth " + this.tMgr.Touchless.CurrentCamera.CaptureWidth + "#"
                    + "CameraHeight " + this.tMgr.Touchless.CurrentCamera.CaptureHeight + "+";

                this.textBoxMarkerData.Lines = text.Split('#');
            }
            else
                this.textBoxMarkerData.Text = "Marker not present";
        }
Beispiel #15
0
 public abstract void MarkerDisappear(MarkerEventData data);
Beispiel #16
0
 public abstract void MarkerUpdate(MarkerEventData data);
Beispiel #17
0
        private void UpdateMouseDataInUI(MarkerEventData data)
        {
            if (ilosc_markerow != _touchlessMgr.Markers.Count)
            {
                start_x        = _touchlessMgr.Markers[_touchlessMgr.Markers.Count - 1].CurrentData.X;
                start_y        = _touchlessMgr.Markers[_touchlessMgr.Markers.Count - 1].CurrentData.Y;
                curent_x       = MousePosition.X;
                curent_y       = MousePosition.Y;
                ilosc_markerow = _touchlessMgr.Markers.Count;
            }
            int poz_x = 0;
            int poz_y = 0;

            poz_x = _touchlessMgr.Markers[0].CurrentData.X;
            poz_y = _touchlessMgr.Markers[0].CurrentData.Y;

            if (flaga_mouse == true)
            {
                poz_x = Mark.CurrentData.X;
                poz_y = Mark.CurrentData.Y;
                if (start_x > poz_x + martwa_strefa || start_x < poz_x - martwa_strefa)
                {
                    if (curent_x < SystemInformation.PrimaryMonitorSize.Width)
                    {
                        curent_x += (start_x - poz_x) * waga_x / 10;
                        if (Convert.ToInt32(curent_x) <= 10)
                        {
                            curent_x = 10;
                        }
                        SetCursorPos(Convert.ToInt32(curent_x), Convert.ToInt32(curent_y));
                        CurrTime = DateTime.Now;
                    }
                    else
                    {
                        curent_x -= 5;
                    }
                }


                if (start_y > poz_y + martwa_strefa || start_y < poz_y - martwa_strefa)
                {
                    if (curent_y < SystemInformation.PrimaryMonitorSize.Height - 20)
                    {
                        curent_y -= (start_y - poz_y) * waga_y / 10;
                        if (Convert.ToInt32(curent_y) <= 20)
                        {
                            curent_y = 10;
                        }
                        SetCursorPos(Convert.ToInt32(curent_x), Convert.ToInt32(curent_y));
                        CurrTime = DateTime.Now;
                    }
                    else
                    {
                        curent_y -= 5;
                    }
                }

                if ((DateTime.Now.Second - CurrTime.Second) > czas_reakcji)
                {
                    if (flaga_okna_myszy == false)
                    {
                        stary_curent_x = Convert.ToInt32(curent_x);
                    }
                    stary_curent_y  = Convert.ToInt32(curent_y);
                    myForm.Location = new Point(Convert.ToInt32(curent_x) - 100, Convert.ToInt32(curent_y) - 100);
                    myForm.Visible  = true;
                }
            }



            labelMarkerData.Text =
                "pozycja przeliczona\t: x " + Convert.ToString(poz_x * zwrot_x) + "  y" + Convert.ToString(poz_y * zwrot_y) + "\n"
                + "pozycja obrazowa\t: x " + poz_x.ToString() + "  y" + poz_x.ToString() + "\n"
                + "pozycja startowa\t: x " + start_x + "  y" + start_y + "\n"
                + "pozycja obecna \t: x " + curent_x + "  y" + curent_y + "\n"
                + "pozycja kursora \t: x " + MousePosition.X + "  y" + MousePosition.Y + "\n"
                + "czas ruchu\t:" + CurrTime.Second + "\n"
                + "roznica czasow \t:" + (DateTime.Now.Second - CurrTime.Second) + "\n"
                + (poz_x - start_x) + "  " + (start_y - poz_y) + "\n"
                + ilosc_markerow;


            //  this.Cursor = new Cursor(Cursor.Current.Handle);
            //  Cursor.Position = new Point(poz_x*zwrot_x, poz_y*zwrot_y);
            //   Cursor.Clip = new Rectangle(this.Location, this.Size);
        }
Beispiel #18
0
        private void UpdateMarkerDataInUI(MarkerEventData data)
        {
            if (ilosc_markerow != Wspolny.w_touchlessMgr.Markers.Count)
            {
                start_x = Wspolny.X(_markerSelected);
                start_y = Wspolny.Y(_markerSelected);

                ilosc_markerow = Wspolny.w_touchlessMgr.Markers.Count;
            }
            curent_x = Cursor.Position.X;
            curent_y = Cursor.Position.Y;

            int poz_x = 0;
            int poz_y = 0;

            poz_x = Wspolny.X(_markerSelected);
            poz_y = Wspolny.Y(_markerSelected);
            if (start_x > poz_x + martwa_x || start_x < poz_x - martwa_x)
            {
                curent_x += (start_x - poz_x) * (przyspieszenie_x / 10) / _markerSelected.Count;
                if (Convert.ToInt32(curent_x) <= 10)
                    curent_x = 10;
                SetCursorPos(Convert.ToInt32(curent_x), Convert.ToInt32(curent_y));
                base.CurrTime = DateTime.Now;
            }

            if (start_y > poz_y + martwa_y || start_y < poz_y - martwa_y)
            {
                curent_y -= (start_y - poz_y) * (przyspieszenie_y / 10) / _markerSelected.Count;
                if (Convert.ToInt32(curent_y) <= 10)
                    curent_y = 10;
                SetCursorPos(Convert.ToInt32(curent_x), Convert.ToInt32(curent_y));
                base.CurrTime = DateTime.Now;
            }
            //sprawdzam czy zostal przekroczony czas bezruchu potrzebny do otwarcia okna przycisku myszy
            if ((DateTime.Now.Second - base.CurrTime.Second) > czas_otwarcia_okienka)
            {
                if (myForm.Visible == false)
                {
                    myForm.Location = new Point(Convert.ToInt32(curent_x) - 100, Convert.ToInt32(curent_y) - 100);
                    this.myForm.Visible = true;
                }
            }
        }