private void AddSignDetectedResult(SignDetectionResult signDetectionResult) { lock (signDetectionResult) { signDetectionResults.Add(signDetectionResult); } }
private void DetectSignsForStreetView(StreetView streetView) { Bitmap image = new Bitmap(streetView.Path); SignDetectionResult detectionResult = new SignDetectionResult(); detectionResult.Image = image; Color[] colorArray = new Color[] { Color.Red, Color.Green, Color.Blue, Color.Yellow, Color.Cyan, Color.Brown }; using (Graphics newGraphics = Graphics.FromImage(image)) { for (int j = 0; j < detectors.Count; j++) { detectionResult.DetectorsResult.Add(detectors[j].Name, new List <DatabaseService.Model.Sign>()); List <CommonDetectorApi.Sign> signs = detectors[j].Detect(image); using (SolidBrush shadowBrush = new SolidBrush(Color.FromArgb(50, colorArray[j]))) { foreach (CommonDetectorApi.Sign sign in signs) { newGraphics.FillRectangle(shadowBrush, new Rectangle(sign.X, sign.Y, sign.Width, sign.Height)); DatabaseService.Model.Sign signModel = new DatabaseService.Model.Sign(streetView, detectors[j].Name, sign); detectionResult.DetectorsResult[detectors[j].Name].Add(signModel); dbContext.Signs.Add(signModel); dbContext.SaveChanges(); } } } } AddSignDetectedResult(detectionResult); }