コード例 #1
0
        private void _worker_DoWork(object sender, DoWorkEventArgs e)
        {
            int fileIndex = 1;

            foreach (var file in Directory.GetFiles(FilePath))
            {
                if (ServiceRunning && System.IO.Path.GetExtension(file).ToLower() == ".jpg")
                {
                    _worker.ReportProgress(fileIndex++, file);

                    var result        = scoreSingleImage(file);
                    var fires         = result.labels.Where((l) => l == 1);
                    var imageLocation = BingMapsRestServices.GetLatLongFromImage(file);
                    if (imageLocation == null)
                    {
                        imageLocation = new double[] { 0, 0 }
                    }
                    ;
                    else
                    {
                        CoveredArea.Add(new LocationMark()
                        {
                            Latitude  = imageLocation[0],
                            Longitude = imageLocation[1]
                        });
                    }

                    if (fires.Count() > 0)
                    {
                        DetectedFires.Add(new LocationMark(imageLocation[0], imageLocation[1], file, filterResults(result)));
                    }
                }
            }
        }
コード例 #2
0
        private void CmdAccept_Execute(object obj)
        {
            double lon, lat;

            BingMapsRestServices.FindLocationByName(Location, out lon, out lat);

            if (lon == 0 && lat == 0)
            {
                MessageBox.Show("We could find the location you mentioned");
                return;
            }

            ResolvedLocation = new double[] { lat, lon };
            this.Hide();
        }
コード例 #3
0
        private void _worker_DoWorkByBatch(object sender, DoWorkEventArgs e)
        {
            int  fileIndex  = 0;
            int  batchIndex = 0;
            var  allFiles   = Directory.GetFiles(FilePath);
            bool filesLeft  = allFiles.Count() > 0;

            while (filesLeft)
            {
                var batch        = allFiles.Skip(batchIndex * Settings.IMAGE_BATCH_SIZE).Take(Settings.IMAGE_BATCH_SIZE);
                var batchResults = scoreImageBatch(batch);

                foreach (var result in batchResults)
                {
                    var scoreFile = allFiles.First((f) => System.IO.Path.GetFileName(f) == result.fileName);

                    var fires         = result.labels.Where((l) => l == 1);
                    var imageLocation = BingMapsRestServices.GetLatLongFromImage(scoreFile);
                    if (imageLocation == null)
                    {
                        imageLocation = new double[] { 0, 0 }
                    }
                    ;
                    else
                    {
                        CoveredArea.Add(new LocationMark()
                        {
                            Latitude  = imageLocation[0],
                            Longitude = imageLocation[1]
                        });
                    }

                    if (fires.Count() > 0)
                    {
                        var filteredScores = filterResults(result);
                        if (filteredScores.labels.Any())
                        {
                            DetectedFires.Add(new LocationMark(imageLocation[0], imageLocation[1], scoreFile, filteredScores));
                        }
                    }
                    _worker.ReportProgress((int)Math.Ceiling((decimal)fileIndex / allFiles.Count() * 100), scoreFile);
                    fileIndex++;
                }
                batchIndex++;
                filesLeft = batchIndex * Settings.IMAGE_BATCH_SIZE < allFiles.Count();
            }
        }