private AnalyzedState runAnalyzer(string imagePath) { Uri uri = new Uri(imagePath, UriKind.RelativeOrAbsolute); Analyzer analyzer = new Analyzer(); System.Drawing.Bitmap image = new System.Drawing.Bitmap(imagePath); //// Loop through the image int[] map = new int[(int)image.Width * (int)image.Height]; for (int x = 0; x < image.Width; x++) { for (int y = 0; y < image.Height; y++) { System.Drawing.Color pixelColor = image.GetPixel(x, y); map[y*image.Width + x] = pixelColor.ToArgb(); pixelColor.GetHue(); } } List<AnalyzedObject> objectList = analyzer.analyzeImage(map, image.Width, image.Height); return analyzer.decide(objectList); //foreach (AnalyzedObject o in objectList) // if (o.decision == true) // { // if (o.color.Equal(Color.green)) return AnalyzedState.Green; // else if (o.color.Equal(Color.red)) return AnalyzedState.Red; // else return AnalyzedState.Unknown; // } //return AnalyzedState.Unknown; }
private void AnalyzeAndDisplayImage(string filename) { this.Dispatcher.BeginInvoke(delegate() { using (IsolatedStorageFile isStore = IsolatedStorageFile.GetUserStoreForApplication()) using (IsolatedStorageFileStream sourceStream = isStore.OpenFile(filename, FileMode.Open)) { sourceStream.Seek(0, SeekOrigin.Begin); wb.LoadJpeg(sourceStream); wb.Invalidate(); } Analyzer analyzer = new Analyzer(); List<AnalyzedObject> analyzedObjects = analyzer.analyzeImage(wb.Pixels, (int)cam.Resolution.Width, (int)cam.Resolution.Height); GenerateListofRectangles(analyzedObjects); AnalyzedState state_o = analyzer.decide(analyzedObjects); var uri = string.Format("Assets/{0}.mp3", state_o.ToString()); MyMedia.Source = new Uri(uri, UriKind.RelativeOrAbsolute); MyMedia.Play(); }); }