public static IList <string> AnalyzeImage(BitmapImage imageToAnalyze) { IList <string> recognizedObjects = new List <string>(); //get the color palletes Dictionary <Color, ColorInformation> imagePalette = PaletteAnalyzer.GetColorPallete(imageToAnalyze); //see what it matches with List <ObjectSignatureData> signatures = ObjectMemoryService.GetSignatures(); foreach (ObjectSignatureData signature in signatures) { float colors = signature.ObjectColors.Count; float matches = 0.0f; foreach (ObjectColorData colorData in signature.ObjectColors) { if (imagePalette.ContainsKey(colorData.ObjectColor)) { matches++; } } if ((matches / colors) > AgreementCutoffPercent) { recognizedObjects.Add(signature.ObjectName); } } return(recognizedObjects); }
public static void LearnObject(BitmapImage learningImage, BitmapImage backgroundImage, string objectName) { //get the object pallete Dictionary <Color, ColorInformation> objectPalleteData = PaletteAnalyzer.AnalyzeBitmaps(learningImage, backgroundImage); //convert into ColorData List <ObjectColorData> objectColorData = new List <ObjectColorData>(); foreach (Color color in objectPalleteData.Keys) { objectColorData.Add(new ObjectColorData(color)); } ObjectSignatureData objectSignature = new ObjectSignatureData(objectColorData, objectName); //save the learned object ObjectMemoryService.AddSignature(objectSignature); }
public static Dictionary <Color, ColorInformation> GetColorPallete(BitmapImage bmpImage) { Bitmap bitmap = BitmapImage2Bitmap(bmpImage); return(PaletteAnalyzer.GetColorPallete(bitmap)); }