public EgsDeviceFaceDetectionOnHost()
        {
            // +X:Right  +Y:Bottom  +Z:Back (camera to user)

            // Parameters input by user
            // 3[m].  10 feet UI
            MaxDetectableDistanceInMeter = new RangedDouble(3.0, 1.0, 5.0, 0.1, 0.5, 0.1);
            // (120,200) Avg: M:162 F:156  But the actual recognition result breadth is smaller than this definition.
            RealFaceBreadth = new RangedDouble(159, 120, 200, 1, 5, 1);
            // ( 65, 95) Avg: M: 82 F: 74
            RealPalmBreadth = new RangedDouble(78, 65, 95, 1, 3, 1);

            IsToUpdateRealHandDetectionAreaFromBodyParameters = true;
            // (310,440) Avg: M:397 F:361
            RealShoulderBreadth = new RangedDouble(379, 310, 440, 1, 10, 1);
            RealHandDetectionAreaCenterXOffset_DividedBy_RealShoulderBreadth = new RangedDouble(0.68, 0, 1, 0.01, 0.1, 0.01);
            RealHandDetectionAreaCenterYOffset_DividedBy_RealFaceBreadth     = new RangedDouble(0.63, 0, 2, 0.01, 0.1, 0.01);
            RealHandDetectionAreaCenterZOffset_DividedBy_RealShoulderBreadth = new RangedDouble(-0.26, -1, 0, 0.01, 0.1, 0.01);
            RealHandDetectionAreaWidth_DividedBy_RealPalmBreadth             = new RangedDouble(4.5, 3, 6, 0.1, 1.0, 0.1);
            RealHandDetectionAreaHeight_DividedBy_RealPalmBreadth            = new RangedDouble(5.1, 3, 6, 0.1, 1.0, 0.1);

            RealHandDetectionAreaCenterXOffset = new RangedDouble(RealHandDetectionAreaCenterXOffset_DividedBy_RealShoulderBreadth * RealShoulderBreadth, 0, 500, 10, 50, 10);
            RealHandDetectionAreaCenterYOffset = new RangedDouble(RealHandDetectionAreaCenterYOffset_DividedBy_RealFaceBreadth * RealFaceBreadth, -100, 200, 10, 50, 10);
            RealHandDetectionAreaCenterZOffset = new RangedDouble(RealHandDetectionAreaCenterZOffset_DividedBy_RealShoulderBreadth * RealShoulderBreadth, -300, 0, 10, 50, 10);
            RealHandDetectionAreaWidth         = new RangedDouble(RealHandDetectionAreaWidth_DividedBy_RealPalmBreadth * RealPalmBreadth, 100, 500, 10, 50, 10);
            RealHandDetectionAreaHeight        = new RangedDouble(RealHandDetectionAreaHeight_DividedBy_RealPalmBreadth * RealPalmBreadth, 100, 500, 10, 50, 10);

            RealFaceCenterZ = double.PositiveInfinity;

            SensitivityAndSpecificity = new RangedInt(0, -3, 3, 1, 1, 1);

            DetectFaceIntervalMillisecondsMinimum = new RangedInt(200, 0, 2000, 10, 100, 10);
            DetectFaceIntervalMinimumStopwatch    = Stopwatch.StartNew();
            Worker         = new System.ComponentModel.BackgroundWorker();
            Worker.DoWork += delegate
            {
                DetectFaces();
            };
            Worker.RunWorkerCompleted += delegate
            {
                DetectFaces_RunWorkerCompleted();
            };
            IsDetecting = false;

            DlibArray2dUcharImage     = new DlibSharp.Array2dUchar();
            DlibHogSvm                = new DlibSharp.FrontalFaceDetector();
            DetectionElapsedStopwatch = new Stopwatch();

            IsToUpdateRealHandDetectionAreaFromBodyParametersChanged += delegate { UpdateRealHandDetectionAreaParametersFromRealBodyParameters(); };
            RealFaceBreadth.ValueChanged     += delegate { UpdateRealHandDetectionAreaParametersFromRealBodyParameters(); };
            RealPalmBreadth.ValueChanged     += delegate { UpdateRealHandDetectionAreaParametersFromRealBodyParameters(); };
            RealShoulderBreadth.ValueChanged += delegate { UpdateRealHandDetectionAreaParametersFromRealBodyParameters(); };
            RealHandDetectionAreaCenterXOffset_DividedBy_RealShoulderBreadth.ValueChanged += delegate { UpdateRealHandDetectionAreaParametersFromRealBodyParameters(); };
            RealHandDetectionAreaCenterYOffset_DividedBy_RealFaceBreadth.ValueChanged     += delegate { UpdateRealHandDetectionAreaParametersFromRealBodyParameters(); };
            RealHandDetectionAreaCenterZOffset_DividedBy_RealShoulderBreadth.ValueChanged += delegate { UpdateRealHandDetectionAreaParametersFromRealBodyParameters(); };
            RealHandDetectionAreaWidth_DividedBy_RealPalmBreadth.ValueChanged             += delegate { UpdateRealHandDetectionAreaParametersFromRealBodyParameters(); };
            RealHandDetectionAreaHeight_DividedBy_RealPalmBreadth.ValueChanged            += delegate { UpdateRealHandDetectionAreaParametersFromRealBodyParameters(); };

            Reset();
        }
 public GameSetting()
 {
     PlayerView        = new RangedInt(1, 5, 3);
     PlayerSpeed       = new RangedInt(1, 9, 4);
     JumpForce         = new RangedFloat(0.5f, 5.0f, 0.5f);
     RotateSensitivity = new RangedFloat(0.2f, 5.0f, 1.0f);
     PickingDistance   = new RangedInt(12, 32, 16);
 }
Ejemplo n.º 3
0
        public void SettingToAbove_UpperBoundary_ReturnsUpperBoundary()
        {
            var sut = new RangedInt(3, 2, 5);

            sut.SetValue(sut.MaxValue + 1);

            Assert.AreEqual(sut.Value, sut.MaxValue);
        }
Ejemplo n.º 4
0
        public void AddingToAbove_UpperBoundary_ReturnsUpperBoundary()
        {
            var sut = new RangedInt(3, 2, 5);

            sut += 9;

            Assert.AreEqual(sut.Value, sut.MaxValue);
        }
Ejemplo n.º 5
0
        public void Adding_WorksWith_Negative_Int()
        {
            var sut = new RangedInt(-10, -15, -5);

            sut += 1;

            Assert.AreEqual(sut.Value, -9);
        }
Ejemplo n.º 6
0
        public void Adding_WorksWith_Int()
        {
            var sut = new RangedInt(3, 2, 5);

            sut += 9;

            Assert.AreEqual(sut.Value, sut.MaxValue);
        }
Ejemplo n.º 7
0
        public void CanSetTo_LowerBoundary()
        {
            var sut = new RangedInt(2, 1, 5);

            sut.SetValue(sut.MinValue);

            Assert.AreEqual(sut.Value, sut.MinValue);
        }
Ejemplo n.º 8
0
        public void SettingToBelow_LowerBoundary_ReturnsLowerBoundary()
        {
            var sut = new RangedInt(3, 2, 5);

            sut.SetValue(sut.MinValue - 1);

            Assert.AreEqual(sut.Value, sut.MinValue);
        }
Ejemplo n.º 9
0
        public void CanSetTo_UpperBoundary()
        {
            var sut = new RangedInt(3, 1, 5);

            sut.SetValue(sut.MaxValue);

            Assert.AreEqual(sut.Value, sut.MaxValue);
        }
Ejemplo n.º 10
0
        public void SubtractingToBelow_LowerBoundary_ReturnsLowerBoundary()
        {
            var sut = new RangedInt(4, 2, 5);

            sut -= 9;

            Assert.AreEqual(sut.Value, sut.MinValue);
        }
Ejemplo n.º 11
0
        public void Subtraction_WorksWith_Int()
        {
            var sut = new RangedInt(3, 2, 5);

            sut -= 9;

            Assert.AreEqual(sut.Value, sut.MinValue);
        }
Ejemplo n.º 12
0
    public static T PickRandomEnum <T>()
    {
        Array     values          = Enum.GetValues(typeof(T));
        RangedInt enumRange       = new RangedInt(0, values.Length);
        int       randomIndex     = enumRange.RandomValue;
        T         randomEnumValue = (T)values.GetValue(randomIndex);

        return(randomEnumValue);
    }
        public void SetValue(RangedInt IntValue)
        {
            m_Slider.wholeNumbers = true;

            m_Slider.minValue = IntValue.MinValue;
            m_Slider.maxValue = IntValue.MaxValue;

            m_Slider.value     = IntValue.Get();
            m_SliderValue.text = IntValue.Get().ToString();
        }
Ejemplo n.º 14
0
        public void Adding_WorksWith_RangedInt()
        {
            var sut = new RangedInt(3, 2, 5);

            var newValue = new RangedInt(4, 3, 6);

            sut += newValue;  // ~3+4

            Assert.AreEqual(sut.Value, sut.MaxValue);
        }
Ejemplo n.º 15
0
        public void Subtraction_WorksWith_RangedInt()
        {
            var sut = new RangedInt(3, 2, 5);

            var newValue = new RangedInt(4, 3, 6);

            sut -= newValue;  // ~3-4

            Assert.AreEqual(sut.Value, sut.MinValue);
        }
Ejemplo n.º 16
0
        public void CanCreateWith_int()
        {
            int creator = 4;

            RangedInt sut = creator;

            Assert.AreEqual(sut.Value, creator);
            Assert.AreEqual(sut.MinValue, int.MinValue);
            Assert.AreEqual(sut.MaxValue, int.MaxValue);
        }
Ejemplo n.º 17
0
 private int GetFreeTileInBoard(List <Tile> tiles, RangedInt range, int startingTile)
 {
     for (int tile = 0; tile < tiles.Count; ++tile)
     {
         if (range.isInRange(tile - startingTile))
         {
             if (!tiles[tile].isConnected)
             {
                 return(tile);
             }
         }
     }
     return(-1);
 }
Ejemplo n.º 18
0
        public void HandleGoing_Below_IntMinValue()
        {
            BoundaryExceededArgs raisedArgs = null;

            Action <BoundaryExceededArgs> onErr = (args) => raisedArgs = args;

            var sut = new RangedInt(int.MinValue + 1, int.MinValue, int.MaxValue, onErr);

            sut -= 4;

            Assert.AreEqual(int.MinValue, (int)sut.Value);
            Assert.IsNotNull(raisedArgs.ImpossibleValue);
            Assert.AreEqual("-2147483647 - 4 < int.MinValue", raisedArgs?.ImpossibleValue ?? 0);
        }
Ejemplo n.º 19
0
        public void EventRaisedWhen_LowerBoundaryExceeded()
        {
            BoundaryExceededArgs raisedArgs = null;

            Action <BoundaryExceededArgs> onErr = (args) => raisedArgs = args;

            var sut = new RangedInt(3, 2, 5, onErr);

            sut -= 4;

            Assert.AreEqual(sut.Value, sut.MinValue);
            Assert.IsNotNull(raisedArgs.ImpossibleValue);
            Assert.AreEqual(-1, raisedArgs?.ImpossibleValue ?? 0);
        }
Ejemplo n.º 20
0
        public void HandleGoing_Above_IntMaxValue_WithRangedInt()
        {
            BoundaryExceededArgs raisedArgs = null;

            Action <BoundaryExceededArgs> onErr = (args) => raisedArgs = args;

            var sut = new RangedInt(int.MaxValue - 1, 0, int.MaxValue, onErr);

            var addFive = new RangedInt(5);

            sut += addFive;

            Assert.AreEqual(int.MaxValue, (int)sut.Value);
            Assert.IsNotNull(raisedArgs.ImpossibleValue);
            Assert.AreEqual("2147483646 + 5 > int.MaxValue", raisedArgs?.ImpossibleValue ?? 0);
        }
Ejemplo n.º 21
0
        public void HandleGoing_Above_IntMaxValue()
        {
            BoundaryExceededArgs raisedArgs = null;

            Action <BoundaryExceededArgs> onErr = (args) => raisedArgs = args;

            var sut = new RangedInt(int.MaxValue - 1, 0, int.MaxValue, onErr);

            sut += 4;

            // Assert.IsTrue(false, int.MaxValue.ToString()); // 2147483647

            Assert.AreEqual(int.MaxValue, (int)sut.Value);
            Assert.IsNotNull(raisedArgs.ImpossibleValue);
            Assert.AreEqual("2147483646 + 4 > int.MaxValue", raisedArgs?.ImpossibleValue ?? 0);
        }
    public List <int> SelectIds(List <float> weights, RangedInt range)
    {
        List <int> selections = new List <int>();
        float      total      = 0f;
        float      amount     = Random.Range(range.start, range.end);

        for (int i = 0; i < weights.Count; i++)
        {
            total += weights[i];
            if (amount <= total)
            {
                selections.Add(i);
            }
        }
        return(selections);
    }
        public HidAccessPropertyRect(RangedInt newXRange, RangedInt newYRange, RangedInt newWidthRange, RangedInt newHeightRange)
        {
            XRange      = newXRange;
            YRange      = newYRange;
            WidthRange  = newWidthRange;
            HeightRange = newHeightRange;
            var XBytes = BitConverter.GetBytes((int)newXRange.Value);
            var YBytes = BitConverter.GetBytes((int)newYRange.Value);
            var WBytes = BitConverter.GetBytes((int)newWidthRange.Value);
            var HBytes = BitConverter.GetBytes((int)newHeightRange.Value);

            XBytes.CopyTo(ByteArrayData, OneValueOffsetInByteArrayData + 0);
            YBytes.CopyTo(ByteArrayData, OneValueOffsetInByteArrayData + 4);
            WBytes.CopyTo(ByteArrayData, OneValueOffsetInByteArrayData + 8);
            HBytes.CopyTo(ByteArrayData, OneValueOffsetInByteArrayData + 12);
        }
Ejemplo n.º 24
0
 private int GetRandomTileInBoard(List <Tile> tiles, RangedInt range, int startingTile = 0)
 {
     for (int attempts = 0; attempts < 15; ++attempts)
     {
         int tile = startingTile + range.Value;
         if (tile < 0)
         {
             continue;
         }
         else if (tile >= tiles.Count)
         {
             continue;
         }
         else if (!tiles[tile].isConnected)
         {
             return(tile);
         }
     }
     return(GetFreeTileInBoard(tiles, range, startingTile));
 }
Ejemplo n.º 25
0
        static void Main(string[] args)
        {
            // Define a variable that holds a number between zero and ten
            var foo = 7;

            foo += 5;

            Console.WriteLine(foo); // 12

            RangedInt dpp = foo;

            Console.WriteLine(dpp.Value);

            var bar = new RangedInt(7, 0, 10);

            bar += 5;

            Console.WriteLine(bar.Value); // 10

            RangedInt xyz = (7, 0, 10);   // Funky C#7 syntax

            xyz += 5;

            Console.WriteLine(xyz.Value); // 10

            var a = xyz < 5;
            var b = xyz > 5;
            var c = xyz <= 5;
            var d = xyz >= 5;
            var e = xyz == 5;
            var f = xyz != 5;

            sbyte bb = 8;

            RangedInt rib = bb;

            Console.WriteLine(rib);

            Console.ReadKey(true);
        }
Ejemplo n.º 26
0
    public void AddEdgarRooms(RoomType type, params Edgar.Unity.RoomTemplateSettings[] rooms)
    {
        Debug.Assert(!roomTypes.ContainsKey(type), $"The type: {type} has already been added");
        roomTypes[type] = new RangedInt(this.rooms.Count, this.rooms.Count + rooms.Length - 1);
        foreach (var room in rooms)
        {
            var         rect  = room.GetOutline().BoundingRectangle;
            var         doors = room.GetComponent <Edgar.Unity.Doors>();
            GenRoomInfo info  = new GenRoomInfo(rect.Width + 1, rect.Height + 1, doors.DoorsList.Count, room.name, room.gameObject);
            foreach (var door in doors.DoorsList)
            {
                Debug.Assert(rect.A.X < rect.B.X && rect.A.Y < rect.B.Y, $"({rect.A}, {rect.B})"); // A is always min and B is always max
                Vector2Int pos = door.From.ToVector3Int().ToVector2Int();
                pos.x -= rect.A.X; pos.y -= rect.A.Y;

                // NOTE: The door.To isn't neccessary greater than the door.From and they might be negative
                Vector2Int size = MathUtils.Abs((door.To - door.From).ToVector3Int().ToVector2Int()) + Vector2Int.one;
                info.doors.Add(new RectInt(pos, size));
            }
            this.rooms.Add(info);
        }
    }
Ejemplo n.º 27
0
 /// <summary>
 /// Value is in a RangedInt, max-inclusive.
 /// </summary>
 public static bool InRangeInclusive(this int value, RangedInt range) =>
 value.InRangeInclusive(range.Min, range.Max);
 public HidAccessPropertySize()
 {
     WidthRange  = new RangedInt(1, 1, short.MaxValue);
     HeightRange = new RangedInt(1, 1, short.MaxValue);
 }
 public HidAccessPropertyPoint()
 {
     XRange = new RangedInt(0, short.MinValue, short.MaxValue);
     YRange = new RangedInt(0, short.MinValue, short.MaxValue);
 }
 public HidAccessPropertyRangedInt()
 {
     RangedValue = new RangedInt();
     RangedValue.ValueChanged += (sender, e) => { OnValueChanged(e); };
 }