Example #1
0
    public void ButtonSubmit()
    {
        // Recuperer les valeurs Hmin, Hmax, Smin, Smax, Vmin, Vmax pour les deux joueurs

        DetectionConfig player1conf = new DetectionConfig()
        {
            minValueH = player1HMin,
            minValueS = player1SMin,
            minValueV = player1VMin,
            maxValueH = player1HMax,
            maxValueS = player1SMax,
            maxValueV = player1VMax
        };

        PlayerPrefs.SetString("player1conf", JsonUtility.ToJson(player1conf));

        DetectionConfig player2conf = new DetectionConfig()
        {
            minValueH = player2HMin,
            minValueS = player2SMin,
            minValueV = player2VMin,
            maxValueH = player2HMax,
            maxValueS = player2SMax,
            maxValueV = player2VMax
        };

        PlayerPrefs.SetString("player2conf", JsonUtility.ToJson(player2conf));

        menuManager.gameObject.SetActive(true);
        gameObject.SetActive(false);
    }
Example #2
0
    public void LoadPrefs()
    {
        if (PlayerPrefs.HasKey("player1conf"))
        {
            DetectionConfig player1conf = JsonUtility.FromJson <DetectionConfig>(PlayerPrefs.GetString("player1conf"));
            player1SliderHmax.value = player1HMax = (int)player1conf.maxValueH;
            player1SliderSmax.value = player1SMax = (int)player1conf.maxValueS;
            player1SliderVmax.value = player1VMax = (int)player1conf.maxValueV;
            player1SliderHmin.value = player1HMin = (int)player1conf.minValueH;
            player1SliderSmin.value = player1SMin = (int)player1conf.minValueS;
            player1SliderVmin.value = player1VMin = (int)player1conf.minValueV;
        }

        if (PlayerPrefs.HasKey("player2conf"))
        {
            DetectionConfig player2conf = JsonUtility.FromJson <DetectionConfig>(PlayerPrefs.GetString("player2conf"));
            player2SliderHmax.value = player2HMax = (int)player2conf.maxValueH;
            player2SliderSmax.value = player2SMax = (int)player2conf.maxValueS;
            player2SliderVmax.value = player2VMax = (int)player2conf.maxValueV;
            player2SliderHmin.value = player2HMin = (int)player2conf.minValueH;
            player2SliderSmin.value = player2SMin = (int)player2conf.minValueS;
            player2SliderVmin.value = player2VMin = (int)player2conf.minValueV;
        }
    }
Example #3
0
        /// <summary>
        /// buildInfo Match helper - Does the build info match heavy lifting
        /// </summary>
        /// <param name="buildInfo">A buildInfo key/value array</param>
        /// <param name="category"></param>
        /// <returns></returns>
        private Dictionary <string, dynamic> V4MatchBiHelper(Dictionary <string, dynamic> buildInfo, string category = "device")
        {
            // ***** Device Detection *****
            Dictionary <string, dynamic> confBiKeys = new Dictionary <string, dynamic>();

            if (DetectionConfig.ContainsKey(string.Format("{0}-bi-order", category)))
            {
                confBiKeys = DetectionConfig[string.Format("{0}-bi-order", category)];
            }

            if (confBiKeys.Count == 0 || buildInfo.Count == 0)
            {
                return(null);
            }

            foreach (KeyValuePair <string, dynamic> platform in confBiKeys)
            {
                string value = "";
                List <List <string> > platformValue = platform.Value;
                for (int index = 0; index < platformValue.Count; index++)
                {
                    List <string> tuple    = platformValue[index];
                    bool          checking = true;
                    for (int i = 0; i < tuple.Count; i++)
                    {
                        string item = tuple[i];
                        if (!buildInfo.ContainsKey(item))
                        {
                            checking = false;
                            break;
                        }
                        else
                        {
                            value += "|" + buildInfo[item];
                        }
                    }

                    if (!checking)
                    {
                        continue;
                    }

                    value = value.Trim(("| \t\n\r\0\x0B").ToArray());
                    string  subtree = string.Compare(category, "device", StringComparison.OrdinalIgnoreCase) == 0 ? _detectionv4Standard : category;
                    dynamic id      = GetMatch("buildinfo", value, subtree, "buildinfo", category);
                    if (!(id is bool))
                    {
                        return(string.Compare(category, "device", StringComparison.OrdinalIgnoreCase) == 0 ? this.FindById(id) : _extra.FindById(id));
                    }
                }
            }

            // If we get this far then not found, so try generic.
            dynamic objplatform = HasBiKeys(buildInfo);

            if (objplatform is bool)
            {
                return(null);
            }

            string[] objTry = new string[2] {
                string.Format("generic|{0}", objplatform.Key.ToLower()), string.Format("{0}|generic", objplatform.Key.ToLower())
            };

            return((from objvalue in objTry let subtree = string.Compare(category, "device", StringComparison.OrdinalIgnoreCase) == 0 ? _detectionv4Generic : category select GetMatch("buildinfo", objvalue, subtree, "buildinfo", category) into id where !(id is bool)select string.Compare(category, "device", StringComparison.OrdinalIgnoreCase) == 0 ? this.FindById(id) : _extra.FindById(id)).FirstOrDefault());
        }
Example #4
0
    void Awake()
    {
        // Capture from webcam
        webcam = new VideoCapture(0);
        webcam.FlipHorizontal = true;
        //webcam.FlipVertical = true;
        CvInvoke.CheckLibraryLoaded();

        playersMinimalArea  = 0.001f;
        captureCyclesBuffer = 5;
        windowWidth         = 640;
        windowHeight        = 480;

        player1RigidBody = player1.GetComponent <Rigidbody2D>();
        player2RigidBody = player2.GetComponent <Rigidbody2D>();

        if (PlayerPrefs.HasKey("player1conf"))
        {
            player1Config = JsonUtility.FromJson <DetectionConfig>(PlayerPrefs.GetString("player1conf"));
        }
        else
        {
            // load default values
            player1Config = new DetectionConfig()
            {
                minValueH = 9 - 10,//to do
                minValueS = 182 - 25,
                minValueV = 189 - 40,
                maxValueH = 9 + 10,
                maxValueS = 182 + 25,
                maxValueV = 189 + 40
            };
        }

        if (PlayerPrefs.HasKey("player2conf"))
        {
            player2Config = JsonUtility.FromJson <DetectionConfig>(PlayerPrefs.GetString("player2conf"));
        }
        else
        {
            // load default values
            player2Config = new DetectionConfig()
            {
                minValueH = 96 - 10,
                minValueS = 164 - 25,
                minValueV = 133 - 40,
                maxValueH = 96 + 10,
                maxValueS = 164 + 25,
                maxValueV = 133 + 40
            };
        }

        // Set OpenCV inputs buffers
        player1Centers = new InputBuffer <Vector3>(captureCyclesBuffer);
        player2Centers = new InputBuffer <Vector3>(captureCyclesBuffer);
        // MUST be an even number otherwise there'll be sign problem as we're averaging positive and negative values
        if (captureCyclesBuffer % 2 == 0)
        {
            player1Angles = new InputBuffer <float>(captureCyclesBuffer);
            player2Angles = new InputBuffer <float>(captureCyclesBuffer);
        }
        else
        {
            player1Angles = new InputBuffer <float>(captureCyclesBuffer + 1);
            player2Angles = new InputBuffer <float>(captureCyclesBuffer + 1);
        }

        //player1ScreenSpacePorcentages = new InputBuffer<float>(captureCyclesBuffer);

        // Starting WebcamHandler thread and its variables

        webcam.ImageGrabbed += Webcam_ImageGrabbed;

        mainCamera = Camera.main;
        debugFlag  = Debug.isDebugBuild;
        cameraMainOrthographicSize = Camera.main.orthographicSize;
    }