Пример #1
0
        private void Man(string[] args)
        {
            switch (args.Length)
            {
            case 1:
                if (args[0].ToLower().Equals("list"))
                {
                    foreach (string key in Documentation.Keys)
                    {
                        WriteLineColor(key, Cyan);
                    }
                    return;
                }
                string topic = args[0];
                if (Documentation.ContainsKey(topic))
                {
                    try
                    {
                        ManualObject obj = JsonConvert.DeserializeObject <ManualObject>(Documentation[topic]);
                        Console.WriteLine("7Sharp Manual");
                        Console.WriteLine();
                        Console.WriteLine(obj.title);
                        Console.WriteLine();
                        Console.WriteLine($"{new string('=', Console.WindowWidth)}\n");
                        foreach (ManualSection s in obj.sections)
                        {
                            Console.WriteLine(s.header);
                            Console.WriteLine();
                            foreach (ManualTextComponent c in s.text)
                            {
                                if (c.color == null)
                                {
                                    c.color = Gray.ToString();
                                }
                                if (c.back == null)
                                {
                                    c.back = Black.ToString();
                                }
                                Console.BackgroundColor = (ConsoleColor)Enum.Parse(typeof(ConsoleColor), c.back);
                                Console.ForegroundColor = (ConsoleColor)Enum.Parse(typeof(ConsoleColor), c.color);
                                Console.Write(c.text);
                                Console.ResetColor();
                            }
                            Console.WriteLine($"\n{new string('-', Console.WindowWidth)}\n");
                        }
                    }
                    catch (Exception e)
                    {
                        Utils.PrintError(e);
                    }
                }
                else
                {
                    WriteLineColor("Topic not found!\nType man list for a list of topics!", Red);
                    return;
                }
                break;

            default:
                WriteLineColor("Invalid syntax! man <topic>\nType man list for a list of topics!", Red);
                break;
            }
        }
Пример #2
0
        /// <summary>
        /// build template List from a Gray image
        /// </summary>
        /// <param name="image">input image</param>
        /// <param name="buildXMLTemplateFile">true to build a xml file with current templates</param>
        /// <param name="angles">the number of angles, default to 360</param>
        /// <param name="sizes">number of sizes, default to 1</param>
        /// <param name="minRatio">The ratio of smallest size to original, default to 0.6</param>
        /// <param name="maxFeaturesPerLevel">the array of maximum features per pyrimid level, default to 200 in DEFAULT_MAX_FEATURES_PER_LEVEL from ImageTemplatePyramid.cs:56,
        ///                                     increase to increase the precision in expense of detection time-delay</param>
        /// <param name="userFunc">Input User Function for customization and diversity</param>
        /// <returns>List of templates.</returns>
        public static List <TemplatePyramid> buildTemplate(Gray <byte>[,] image, int Width, int Height, bool buildXMLTemplateFile = false, int angles = 360, int sizes = 1, float minRatio = 0.6f, int[] maxFeaturesPerLevel = null, Func <TemplatePyramid, Gray <byte> [, ], TemplatePyramid> userFunc = null)
        {
            List <TemplatePyramid> retList = new List <TemplatePyramid>();
            float Ratio = 1;

            Gray <byte>[,] tempIMG;
            rotateLoad(retList, image, angles, Width, Height, false, userFunc: validateFeatures);
            for (int i = 0; i < sizes - 1; i++)
            {
                Ratio -= (float)(1 - minRatio) / sizes;
                int width  = (int)(image.Width() * Ratio);
                int height = (int)(image.Height() * Ratio);

                DotImaging.Primitives2D.Size Nsize = new DotImaging.Primitives2D.Size(width, height);
                tempIMG = ResizeExtensions_Gray.Resize(image, Nsize, Accord.Extensions.Imaging.InterpolationMode.NearestNeighbor);

                rotateLoad(retList, tempIMG, angles, Width, Height, false, maxFeaturesPerLevel, image.ToString(), userFunc: userFunc);
            }
            if (buildXMLTemplateFile)
            {
                XMLTemplateSerializer <ImageTemplatePyramid <ImageTemplate>, ImageTemplate> .ToFile(retList,
                                                                                                    Path.Combine(Directory.GetParent(Directory.GetCurrentDirectory()).FullName, "Resources", "template" + ".xml"));
            }

            return(retList);
        }