Esempio n. 1
0
        // Function that parses XML and stores data into a list of DMVDatabase objects
        private static List <DMVDatabase> ParseXML()
        {
            List <DMVDatabase> listOfDMVEntries = new List <DMVDatabase>();
            XmlDocument        xmlDoc           = new XmlDocument();

            xmlDoc.Load("DMVDatabase.xml");
            XmlNode     rootElement   = xmlDoc.DocumentElement;
            XmlNodeList rootsChildren = rootElement.ChildNodes;

            foreach (XmlNode child in rootsChildren)
            {
                DMVDatabase dbEntry = new DMVDatabase();
                dbEntry.VehiclePlate = child.Attributes[0].Value;
                dbEntry.Make         = child.Attributes[1].Value;
                dbEntry.Model        = child.Attributes[2].Value;
                dbEntry.Year         = child.Attributes[3].Value;

                foreach (XmlNode grandChild in child.ChildNodes)
                {
                    dbEntry.Name = grandChild.Attributes[0].Value;
                    if (grandChild.InnerText.StartsWith('+'))
                    {
                        dbEntry.Phone = grandChild.InnerText;
                    }
                    //else
                    //{
                    //    dbEntry.Email = grandChild.InnerText;
                    //}
                }
                dbEntry.HasViolation = false;
                listOfDMVEntries.Add(dbEntry);
            }

            return(listOfDMVEntries);
        }
Esempio n. 2
0
        private static void DetectLicensePlates(List <DMVDatabase> listOfEntries)
        {
            DMVDatabase driver     = new DMVDatabase();
            string      bucketName = "cs455final-images";
            // list of photos
            List <string> listOfPhotos = new List <string>();

            listOfPhotos.Add("Car1.jpg");
            listOfPhotos.Add("Car2.jpg");
            listOfPhotos.Add("Car3.jpg");
            listOfPhotos.Add("Car4.png");
            listOfPhotos.Add("Car5.jpg");

            AmazonRekognitionClient rekogClient = new AmazonRekognitionClient(Amazon.RegionEndpoint.USEast1);

            foreach (string photo in listOfPhotos)
            {
                DetectTextRequest textRequest = new DetectTextRequest
                {
                    Image = new Image
                    {
                        S3Object = new S3Object
                        {
                            Bucket = bucketName,
                            Name   = photo
                        }
                    }
                };

                DetectTextResponse textResponse = rekogClient.DetectText(textRequest);
                foreach (var textLabel in textResponse.TextDetections)
                {
                    if (textLabel.DetectedText.Contains('-'))
                    {
                        string licensePlate = textLabel.DetectedText;
                        foreach (DMVDatabase dbEntry in listOfEntries)
                        {
                            if (dbEntry.VehiclePlate.Equals(licensePlate) && dbEntry.HasViolation == false)
                            {
                                dbEntry.HasViolation = true;
                            }
                        }
                    }
                }
            }

            NotifyDriverOfViolation(listOfEntries);
        }