Beispiel #1
0
        public bool LoadFile(Stream s)
        {
            //Read file headers
            if (_ReadUInt(s) != 1178686535)
            {
                return(false);
            }
            if (_ReadUShort(s) != 0)
            {
                return(false);
            }
            challenges    = new GtaFingerprintChallenge[_ReadUShort(s)];
            modified_utc  = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc).AddSeconds(_ReadUInt(s));
            screen_width  = _ReadUShort(s);
            screen_height = _ReadUShort(s);

            //Read name
            name = _ReadString(s);

            //Read finger
            finger = new GtaFingerprintTarget(_LoadMask(s));

            //Read challeneges
            for (int i = 0; i < challenges.Length; i++)
            {
                challenges[i] = new GtaFingerprintChallenge(_LoadMask(s));
            }

            return(true);
        }
        private void LoadChallenge(int left, int top, Label viewClick, PictureBox viewImg)
        {
            //Load
            GtaFingerprintChallenge challenge = null;

            foreach (var c in session.screenChallenges)
            {
                if (c.fingerX == left && c.fingerY == top)
                {
                    challenge = c;
                }
            }

            //Check if this was a match
            int matchIndex = session.matches.IndexOf(challenge);

            //Set
            if (matchIndex == -1)
            {
                viewClick.Text = "Not Correct";
            }
            else
            {
                viewClick.Text      = "MATCH " + (matchIndex + 1);
                viewClick.BackColor = Color.LimeGreen;
            }
            SetImageOnView(challenge.ReadDataAsBitmap(), viewImg);
        }
Beispiel #3
0
        public GtaFingerprintChallenge GetComponent(int leftIndex, int topIndex)
        {
            //var f = new GtaFingerprintChallenge(GetComponentBitmap(leftIndex, topIndex));
            var f = new GtaFingerprintChallenge(image, 480 + (145 * leftIndex), 277 + (144 * topIndex), 106, 106, 1920, 1080);

            f.fingerX = leftIndex;
            f.fingerY = topIndex;
            return(f);
        }
Beispiel #4
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="target">FROM THE PACKAGE, the finger to check</param>
        /// <param name="challenges">FROM THE SCREEN, the fingers to check</param>
        /// <returns></returns>
        private GtaFingerprintChallenge FindMatchingTarget(GtaFingerprintChallenge target, GtaFingerprintChallenge[] challenges)
        {
            //Find finger with the highest match
            GtaFingerprintChallenge highestMatch = null;
            int highestMatchValue = int.MinValue;

            foreach (var c in challenges)
            {
                //Resize the mask
                bool[,] targetMask = c.ResizeDataArray(target.width, target.height);

                //Loop through and generate an number to tell us how closely this matches
                int value = 0;
                for (int x = 0; x < c.width; x++)
                {
                    for (int y = 0; y < c.height; y++)
                    {
                        //Check
                        bool isMatch = targetMask[x, y] == target.data[x, y];
                        if (isMatch)
                        {
                            value++;
                        }
                        else
                        {
                            value--;
                        }
                    }
                }

                //Check if this is the best match
                if (value > highestMatchValue)
                {
                    highestMatchValue = value;
                    highestMatch      = c;
                }
            }

            //Validate
            if (highestMatch == null)
            {
                throw new Exception("Could not find any fingers!");
            }

            return(highestMatch);
        }