Ejemplo n.º 1
0
 public static bool ExecuteAlgorithm(this Bitmap bmp, string algorithmName, params object[] args)
 {
     if (!IPAlgorithmManager.algorithms.ContainsKey(algorithmName))
     {
         ImgTools.Error("Error: cannot find algorithm with name '{0}'", algorithmName);
         return(false);
     }
     return(IPAlgorithmManager.algorithms[algorithmName].Execute(bmp, args));
 }
Ejemplo n.º 2
0
        /// <summary>
        /// The constructor of the QR finde, which starts by
        /// scaling the input image and binarizes the image using
        /// the integral image in adaptative threshold
        /// </summary>
        /// <param name="image">input image to analize</param>
        /// <param name="scale">an option to tell the software if we want to scale the input</param>
        /// <param name="maskSize">size of the adaptative threshold window</param>
        public QRFinder(Bitmap image, SCALARS scale, int maskSize)
        {
            names  = (KnownColor[])Enum.GetValues(typeof(KnownColor));
            random = new Random();
            switch (scale)
            {
            case SCALARS.NONE:
                bmp = image;
                break;

            case SCALARS.SCALE:
                bmp = ImgTools.Scale(image, 640, 480);
                break;
            }

            bmp = IAdaptative.Execute(bmp, maskSize);
            BlobFinder.Execute(bmp);
        }
Ejemplo n.º 3
0
        public static int LoadAlgorithmsFromFile(string binaryPath, bool silent = false)
        {
            int count = 0;

            try
            {
                foreach (var type in Assembly.LoadFile(binaryPath).GetTypes())
                {
                    if ((!type.IsClass) || type.IsNotPublic)
                    {
                        continue;
                    }
                    if (typeof(ProcessingAlgorithm).IsAssignableFrom(type))
                    {
                        try
                        {
                            var pa = Activator.CreateInstance(type) as ProcessingAlgorithm;
                            if (!algorithms.ContainsKey(pa.GetName()))
                            {
                                algorithms[pa.GetName()] = pa;
                                count++;
                            }
                        }
                        catch (Exception)
                        {
                            if (!silent)
                            {
                                ImgTools.Error("Error: failed to instantiate algorithm '{0}' in file '{1}'!", type.Name, binaryPath);
                            }
                            continue;
                        }
                    }
                }
            }
            catch (Exception)
            {
                if (!silent)
                {
                    ImgTools.Error("Error: cannot load algorithms from file '{0}'!", binaryPath);
                }
            }
            return(count);
        }