public static IList <string> AnalyzeImage(WriteableBitmap 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);
        }
Exemplo n.º 2
0
        public static void LearnObject(WriteableBitmap learningImage, WriteableBitmap 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(WriteableBitmap bmpImage)
        {
            Bitmap bitmap = BitmapImage2Bitmap(bmpImage);

            return(PaletteAnalyzer.GetColorPallete(bitmap));
        }