Пример #1
0
        public override void GetContent(Invert.Core.GraphDesigner.IDocumentationBuilder _)
        {
            base.GetContent(_);

            _.Paragraph("While services can serve for almost any purpose, they can be used to seperate various features of uFrame, and your application. " +
                        "Examples might include, FacebookService, NetworkingService, AchievementsService...etc");
            _.Break();
            _.Paragraph("As a matter of fact, at the time of this writing, uFrame ships with two default services, The 'ViewService', and the 'SceneManagementService'.");

            _.Break();

            _.Paragraph("There is really only one general rule of thumb when implementing services, " +
                        "they should only be listening to events, processing them, and publishing its own " +
                        "events that might be useful to other services.  While you can inject other services " +
                        "and use them directly, it's highly reommended to use events as the means of communication.");
            _.Break();

            _.Title2("Accesing ViewModels in services.");
            _.Paragraph("To access a running list of a specific viewmodel just add this property to any service, and make sure you specify the viewmodel type you need.");
            _.CodeSnippet("[Inject] IViewModelManager<PlayerViewModel> AllPlayers { get;set; }");
            _.LinkToPage<ViewModelManagers>();

            var service = ServiceNode();
            _.Title2("Designer File Implementation");
            _.TemplateExample<ServiceTemplate, ServiceNode>(service);
            _.Break();
            _.Title2("Editable File Implementation");
            _.TemplateExample<ServiceTemplate, ServiceNode>(service,false);
        }
Пример #2
0
        private string reconhecerCaptcha(Image img)
        {
            Bitmap imagem = new Bitmap(img);

            imagem = imagem.Clone(new Rectangle(0, 0, img.Width, img.Height), System.Drawing.Imaging.PixelFormat.Format24bppRgb);
            Erosion        erosion    = new Erosion();
            Dilatation     dilatation = new Dilatation();
            Invert         inverter   = new Invert();
            ColorFiltering cor        = new ColorFiltering();

            cor.Blue  = new AForge.IntRange(200, 255);
            cor.Red   = new AForge.IntRange(200, 255);
            cor.Green = new AForge.IntRange(200, 255);
            Opening            open  = new Opening();
            BlobsFiltering     bc    = new BlobsFiltering();
            Closing            close = new Closing();
            GaussianSharpen    gs    = new GaussianSharpen();
            ContrastCorrection cc    = new ContrastCorrection();

            bc.MinHeight = 10;
            FiltersSequence seq = new FiltersSequence(gs, inverter, open, inverter, bc, inverter, open, cc, cor, bc, inverter);

            imagem = seq.Apply(imagem);
            //imagem.Save(Directory.GetCurrentDirectory() + "\\Captcha2.png", System.Drawing.Imaging.ImageFormat.Png);
            string reconhecido = OCR(imagem);

            //string reconhecido = ocr.Principal(Directory.GetCurrentDirectory() + "\\Captcha2.png");
            return(reconhecido);
        }
Пример #3
0
 public static Task <(Bitmap, string)> DeCaptchAsync(Image img)
 {
     return((Task <(Bitmap, string)>)Task.Run(() =>
     {
         string value;
         Bitmap bmp = new Bitmap(img);
         bmp = bmp.Clone(new Rectangle(0, 0, img.Width, img.Height), System.Drawing.Imaging.PixelFormat.Format24bppRgb);
         Erosion erosion = new Erosion();
         Dilatation dilatation = new Dilatation();
         Invert inverter = new Invert();
         ColorFiltering cor = new ColorFiltering();
         //cor.Blue = new AForge.IntRange(200, 255);
         cor.Red = new AForge.IntRange(50, 255);
         //cor.Green = new AForge.IntRange(200, 255);
         Opening open = new Opening();
         BlobsFiltering bc = new BlobsFiltering()
         {
             MinHeight = 10
         };
         Closing close = new Closing();
         GaussianSharpen gs = new GaussianSharpen();
         ContrastCorrection cc = new ContrastCorrection();
         FiltersSequence seq = new FiltersSequence(gs, inverter, open, inverter, bc, inverter, open, cc, cor, bc, inverter, dilatation);
         Image image = seq.Apply(bmp);
         value = OCR((Bitmap)image);
         return ((Bitmap)image, value);
     }));
 }
Пример #4
0
        /// <summary>
        /// 重置图片的指定大小并且居中
        /// </summary>
        /// <param name="list"></param>
        /// <returns></returns>
        public static List <Bitmap> ToResizeAndCenterIt(List <Bitmap> list, int w = 20, int h = 20)
        {
            List <Bitmap> resizeList = new List <Bitmap>();


            for (int i = 0; i < list.Count; i++)
            {
                //反转一下图片
                list[i] = new Invert().Apply(list[i]);

                int sw = list[i].Width;
                int sh = list[i].Height;

                Crop corpFilter = new Crop(new Rectangle(0, 0, w, h));

                list[i] = corpFilter.Apply(list[i]);

                //再反转回去
                list[i] = new Invert().Apply(list[i]);

                //计算中心位置
                int centerX = (w - sw) / 2;
                int centerY = (h - sh) / 2;

                list[i] = new CanvasMove(new IntPoint(centerX, centerY), Color.White).Apply(list[i]);

                resizeList.Add(list[i]);
            }

            return(resizeList);
        }
Пример #5
0
        public static Image Invert(this Image imagex)
        {
            var image  = AForge.Imaging.Image.Clone(new Bitmap(imagex), PixelFormat.Format24bppRgb);
            var filter = new Invert();

            filter.ApplyInPlace(image);

            var fastImage = new LockBitmap(image);

            fastImage.LockBits();
            var vert = 0;

            while (vert < fastImage.Height)
            {
                var hor = 0;
                while (hor < fastImage.Width)
                {
                    var color = fastImage.GetPixel(hor, vert);
                    if (color.R >= 90)
                    {
                        fastImage.SetPixel(hor, vert, Color.White);
                    }

                    hor++;
                }
                vert++;
            }
            fastImage.UnlockBits();



            return(fastImage.GetBitmap());
        }
Пример #6
0
        private string reconhecerCaptcha(Image img)
        {
            Bitmap imagem = new Bitmap(img);

            imagem = imagem.Clone(new Rectangle(0, 0, img.Width, img.Height), System.Drawing.Imaging.PixelFormat.Format24bppRgb);
            Erosion        erosion    = new Erosion();
            Dilatation     dilatation = new Dilatation();
            Invert         inverter   = new Invert();
            ColorFiltering cor        = new ColorFiltering();

            cor.Blue  = new AForge.IntRange(200, 255);
            cor.Red   = new AForge.IntRange(200, 255);
            cor.Green = new AForge.IntRange(200, 255);
            Opening            open  = new Opening();
            BlobsFiltering     bc    = new BlobsFiltering();
            Closing            close = new Closing();
            GaussianSharpen    gs    = new GaussianSharpen();
            ContrastCorrection cc    = new ContrastCorrection();

            bc.MinHeight = 10;
            GrayscaleRMY    gray = new GrayscaleRMY();
            Threshold       thr  = new Threshold(200);
            Difference      diff = new Difference(dilatation.Apply(imagem));
            FiltersSequence seq  = new FiltersSequence(diff, inverter, erosion, gray, thr, cc);

            pictureBox.Image = seq.Apply(imagem);
            string reconhecido = OCR((Bitmap)pictureBox.Image);

            return(reconhecido);
        }
Пример #7
0
        public override void Generate(Map map, GenStepParams parms)
        {
            ModuleBase chambers = new Perlin(0.010, 1.7, 0.5, 6, Rand.Range(0, int.MaxValue), QualityMode.High);

            ModuleBase columns = new Perlin(0.150, 0.5, 0.5, 6, Rand.Range(0, int.MaxValue), QualityMode.High);

            columns = new ScaleBias(0.5, 0.5, columns);

            // push columns to the centers of chambers
            ModuleBase columnsNoise = new Invert(chambers);

            columnsNoise = new ScaleBias(3f, -2f, columnsNoise);
            columnsNoise = new Min(new Const(0.0), columnsNoise);
            columns      = new Add(columns, columnsNoise);

            // broken tunnel network
            ModuleBase tunnels      = new Perlin(0.01, 1.7, 0.5, 6, Rand.Range(0, int.MaxValue), QualityMode.High);
            ModuleBase tunnelsNoise = new Perlin(0.005, 0.0, 0.5, 6, Rand.Range(0, int.MaxValue), QualityMode.Medium);

            tunnels = new Abs(tunnels);
            tunnels = new Add(new Const(0.5), tunnels);
            tunnels = new Add(tunnels, new Clamp(0, 0.5, tunnelsNoise));

            chambers = new Min(new Add(chambers, new Const(0.75)), tunnels);

            MapGenFloatGrid elevation = MapGenerator.Elevation;

            foreach (IntVec3 cell in map.AllCells)
            {
                elevation[cell] = Math.Max(columns.GetValue(cell), chambers.GetValue(cell));
            }
        }
Пример #8
0
        private void Update(EvaluationContext context)
        {
            var   s     = Scale.GetValue(context) * UniformScale.GetValue(context);
            var   r     = Rotation.GetValue(context);
            float yaw   = MathUtil.DegreesToRadians(r.Y);
            float pitch = MathUtil.DegreesToRadians(r.X);
            float roll  = MathUtil.DegreesToRadians(r.Z);
            var   t     = Translation.GetValue(context);
            var   objectToParentObject = Matrix.Transformation(Vector3.Zero, Quaternion.Identity, new Vector3(s.X, s.Y, s.Z), Vector3.Zero,
                                                               Quaternion.RotationYawPitchRoll(yaw, pitch, roll), new Vector3(t.X, t.Y, t.Z));


            // transpose all as mem layout in hlsl constant buffer is row based
            objectToParentObject.Transpose();

            if (Invert.GetValue(context))
            {
                objectToParentObject.Invert();
            }

            _matrix[0]   = objectToParentObject.Row1;
            _matrix[1]   = objectToParentObject.Row2;
            _matrix[2]   = objectToParentObject.Row3;
            _matrix[3]   = objectToParentObject.Row4;
            Result.Value = _matrix;
        }
Пример #9
0
        internal ExamImage(Bitmap im)
        {
            lock (syob)
            {
                orgimg   = im;
                this.img = AForge.Imaging.Image.Clone(im, System.Drawing.Imaging.PixelFormat.Format24bppRgb);
            }
            //img = im;
            Invert inv = new Invert();

            inv.ApplyInPlace(img);
            //BlobsFiltering bf = new BlobsFiltering(new MixFiltering());
            //bf.ApplyInPlace(img);
            BlobCounter bc = new BlobCounter();

            bc.BlobsFilter          = new SyncRectangleFilter();
            bc.FilterBlobs          = true;
            bc.CoupledSizeFiltering = true;
            bc.ProcessImage(img);
            syncboxs = bc.GetObjects(img, true);

            if (isFlip())
            {
                img.RotateFlip(RotateFlipType.Rotate180FlipNone);
                bc.ProcessImage(img);
                syncboxs = bc.GetObjects(img, true);
            }

            bc.BlobsFilter = new AnswerFilter();
            bc.ProcessImage(img);
            answers = bc.GetObjects(img, true);


            stuNumber = getNumber();
        }
Пример #10
0
        private Bitmap preProcess(Bitmap originalImage)
        {
            Invert invertObj   = new Invert();
            Bitmap invertImage = invertObj.Apply((Bitmap)originalImage.Clone());


            invertImage = Grayscale.CommonAlgorithms.BT709.Apply(invertImage);
            Threshold bwObject = new Threshold();

            invertImage = bwObject.Apply(invertImage);

            ExtractBiggestBlob blobObject = new ExtractBiggestBlob();

            invertImage = blobObject.Apply(invertImage);

            ResizeBicubic resize = new ResizeBicubic(60, 90);

            invertImage = resize.Apply(invertImage);


            //CannyEdgeDetector edgeDetector = new CannyEdgeDetector();
            //invertImage = edgeDetector.Apply(invertImage);

            return(invertImage);
        }
Пример #11
0
        private Bitmap LimparImagem(Image img)
        {
            var imagem = new Bitmap(img);

            imagem = imagem.Clone(new Rectangle(0, 0, img.Width, img.Height), System.Drawing.Imaging.PixelFormat.Format24bppRgb);

            var inverter = new Invert();

            var cor = new ColorFiltering
            {
                Blue  = new AForge.IntRange(200, 255),
                Red   = new AForge.IntRange(200, 255),
                Green = new AForge.IntRange(200, 255)
            };

            var open = new Opening();
            var bc   = new BlobsFiltering();
            var gs   = new GaussianSharpen();
            var cc   = new ContrastCorrection();

            bc.MinHeight = 10;

            var seq = new FiltersSequence(gs, inverter, open, inverter, bc, inverter, open, cc, cor, bc, inverter);

            imagem = seq.Apply(imagem);
            return(imagem);
        }
Пример #12
0
        private void hücreSayToolStripMenuItem_Click(object sender, EventArgs e)
        {
            islem = new ExtractNormalizedRGBChannel(RGB.G).Apply(kaynak);
            islem = new OtsuThreshold().Apply(islem);
            islem = new Invert().Apply(islem);
            islem = new Opening().Apply(islem);

            BlobCounter bc = new BlobCounter();

            bc.FilterBlobs = false;
            bc.MinHeight   = 5;
            bc.MinWidth    = 5;
            bc.ProcessImage(islem);
            Rectangle[] rects = bc.GetObjectsRectangles();
            listBox1.Items.Add(rects.Length + " tane hücre var");

            Bitmap   cizim = new Bitmap(islem.Width, islem.Height);
            Graphics g     = Graphics.FromImage(cizim);

            g.DrawImage(islem, 0, 0);
            Pen cerceve = new Pen(Color.Red, 2);

            foreach (Rectangle rect in rects)
            {
                listBox1.Items.Add(rect.Location + " " + rect.Size);
                g.DrawRectangle(cerceve, rect);
            }
            g.Dispose();
            kaynakBox.Image = cizim;
        }
Пример #13
0
        /// <summary>
        /// Initializes a new instance of the <see cref="T:System.Object"/> class.
        /// </summary>
        /// <remarks></remarks>
        public TileOCR(string trainingPath)
        {
            classifier = new KNearestClassifier(1, Metric.EuclideanDistance, WeightMode.InverseDistance);
            training   = LoadInstancesFromBitmaps(trainingPath);

            classifier.Train(training);

            results = new List <OCRResult>();

            grayscale                = new Grayscale(0, 0.85, 0.15);
            invert                   = new Invert();
            resize                   = new ResizeNearestNeighbor(32, 32);
            floodFill                = new PointedColorFloodFill(Color.Black);
            dilate                   = new BinaryDilatation3x3();
            blobCounter              = new BlobCounter();
            blobCounter.FilterBlobs  = true;
            blobCounter.MinWidth     = 4;
            blobCounter.MinHeight    = 14;
            blobCounter.MaxWidth     = 30;
            blobCounter.MaxHeight    = 30;
            blobCounter.ObjectsOrder = ObjectsOrder.XY;
            threshold                = new BradleyLocalThresholding();
            threshold.PixelBrightnessDifferenceLimit = 0;
            //Threshold.WindowSize = 20;
            threshold.WindowSize = 24;
        }
Пример #14
0
        private string reconhecerCaptcha(Image img)
        {
            Bitmap _bitmap = new Bitmap(img);

            _bitmap = _bitmap.Clone(new Rectangle(0, 0, img.Width, img.Height), System.Drawing.Imaging.PixelFormat.Format24bppRgb);
            Erosion        erosion    = new Erosion();
            Dilatation     dilatation = new Dilatation();
            Invert         inverter   = new Invert();
            ColorFiltering cor        = new ColorFiltering();

            cor.Blue  = new AForge.IntRange(200, 255);
            cor.Red   = new AForge.IntRange(200, 255);
            cor.Green = new AForge.IntRange(200, 255);
            Opening            open  = new Opening();
            BlobsFiltering     bc    = new BlobsFiltering();
            Closing            close = new Closing();
            GaussianSharpen    gs    = new GaussianSharpen();
            ContrastCorrection cc    = new ContrastCorrection();

            bc.MinHeight = 10;
            FiltersSequence seq = new FiltersSequence(gs, inverter, open, inverter, bc, inverter, open, cc, cor, bc, inverter);

            pictureBox1.Image = seq.Apply(_bitmap);
            string recognedString = OCR((Bitmap)pictureBox1.Image);

            return(recognedString);
        }
Пример #15
0
        private void FiltroInvertir(Bitmap bmp)
        {
            IFilter Filtro = new Invert();
            Bitmap  XImage = Filtro.Apply(bmp);

            pictureCapchaE.Image = XImage;
        }
Пример #16
0
        private void detectObjectsToolStripMenuItem_Click(object sender, EventArgs e)
        {
            var img     = (Bitmap)currentImage.Clone();
            var showImg = (Bitmap)currentImage.Clone();

            // img = Grayscale.CommonAlgorithms.Y.Apply(img);
            img = new OtsuThreshold().Apply(img);
            img = new Erosion().Apply(img);
            img = new Invert().Apply(img);

            BlobCounter bc = new BlobCounter();

            bc.BackgroundThreshold = Color.Black;
            bc.ProcessImage(img);
            MessageBox.Show(String.Format("The image contains {0} objects.", bc.ObjectsCount));

            Rectangle  rect    = new Rectangle(0, 0, showImg.Width, showImg.Height);
            BitmapData bmpData = showImg.LockBits(rect, ImageLockMode.ReadWrite, showImg.PixelFormat);

            bc.GetObjectsRectangles().ToList().ForEach(i => {
                Drawing.Rectangle(bmpData, i, Color.GreenYellow);
            });

            showImg.UnlockBits(bmpData);

            pictureBox.Image = showImg;
        }
Пример #17
0
        private void FiltroInvertir(Bitmap bmp)
        {
            IFilter filtro = new Invert();
            Bitmap  xImage = filtro.Apply(bmp);

            peCaptcha.Image = xImage;
        }
Пример #18
0
        public IScanImage Scan(ISource source, ScannerOptions options)
        {
            var image = new Bitmap(source.Take());

            // create grayscale filter (BT709)
            var filter     = new Grayscale(0.2125, 0.7154, 0.0721);
            var mBinarized = filter.Apply(image);

            // Binarize Picture.
            var bin = new Threshold(options.Threshold);

            bin.ApplyInPlace(mBinarized);

            // create filter
            var inv = new Invert();

            inv.ApplyInPlace(mBinarized);

            // create an instance of blob counter algorithm
            var bc = new BlobCounter {
                ObjectsOrder = ObjectsOrder.XY
            };

            bc.ProcessImage(mBinarized);
            var blobsRect = bc.GetObjectsRectangles();

            var b = Order(blobsRect);

            return(new ScanImage(image, b));
        }
Пример #19
0
        public override void GetContent(Invert.Core.GraphDesigner.IDocumentationBuilder _)
        {
            base.GetContent(_);
            _.Paragraph("uFrame utilizes a new concept developed to fit the uFrame and RX paradigm of programming.  " +
                        "We like to call this \"Re-active\" state machines. ");
            _.Paragraph("The main concept of state machines in uFrame MVVM is that when defining them in your " +
                        "diagrams you don't need to focus on anything other than the states and transitions that " +
                        "make up the machine.  Making the machine come to life is a matter of wiring them to " +
                        "computed properties, command bindings, and view bindings.  But initially, you can focus " +
                        "purely on the high-level rather than implementation, once commands and transitions " +
                        "are all wired together transitions and states can be easily tweaked with minimal to " +
                        "zero changes in your code.");
            _.Paragraph("Reactive State Machines employ the concept of data subscriptions causing transitions, rather than polling data every frame, this can give a definite increase in performance.");
            _.Break();
            _.ImageByUrl("http://i.imgur.com/CPymbPH.png");
            _.Break();
            _.Title2("Manually triggering transitions");
            _.Paragraph("To set a transition in code, you'll need to access the state machine property.  This should be the property that is connected to your state machine.");
            _.CodeSnippet("{ViewModel}.{StateMachinePropertyName}Property.Transition(\"NAME OF TRANSITION HERE\");");
            _.Break();
            _.Title2("Manually setting the state");
            _.CodeSnippet("{ViewModel}.{StateMachinePropertyName}Property.SetState<STATE_CLASS_NAME>();");
            _.Title3("or");
            _.CodeSnippet("{ViewModel}.{StateMachinePropertyName}Property.SetState(\"STATE_NAME\");");
            _.Break();

            //            _.AlsoSeePages(typeof(UsingStateMachines));
        }
Пример #20
0
        public Bitmap ToInvert(Bitmap Im)
        {
            AForge.Imaging.Filters.Invert Img = new Invert();
            Bitmap bmImage = AForge.Imaging.Image.Clone(new Bitmap(Im), PixelFormat.Format24bppRgb);

            return(Img.Apply(bmImage));
        }
 private void InitializeFilters()
 {
     grayscaleFilter               = new Grayscale(0.299, 0.587, 0.114);
     bradleyLocalFilter            = new BradleyLocalThresholding();
     bradleyLocalFilter.WindowSize = 9;
     bradleyLocalFilter.PixelBrightnessDifferenceLimit = 0.01f;
     plateBlobsFiltering     = new BlobsFiltering(10, 20, 80, 66);
     blobCounter             = new BlobCounter();
     blobCounter.FilterBlobs = true;
     blobCounter.MinWidth    = 50;
     blobCounter.MinHeight   = 10;
     blobCounter.MaxWidth    = 520;
     blobCounter.MaxHeight   = 110;
     plateBlobCounter        = new BlobCounter();
     shapeChecker            = new SimpleShapeChecker();
     otsuThresholdFilter     = new OtsuThreshold();
     fillHoles = new FillHoles();
     fillHoles.MaxHoleWidth  = 100;
     fillHoles.MaxHoleHeight = 40;
     pen                             = new Pen(Color.GreenYellow, 4);
     openingFilter                   = new Opening();
     contrastCorrectionFilter        = new ContrastCorrection(80);
     colorFiltering                  = new ColorFiltering();
     colorFiltering.Red              = new IntRange(150, 255);
     colorFiltering.Green            = new IntRange(150, 255);
     colorFiltering.Blue             = new IntRange(150, 255);
     colorFiltering.FillOutsideRange = true;
     invert                          = new Invert();
 }
Пример #22
0
        static void Main(string[] args)
        {
            Bitmap bitmap_0 = new Bitmap(@"D:\Projects\hisdocpro\HisDocPro\HisDocProUI\bin\Debug\tokens\t_0_c000.png");
            //Bitmap bitmap_0 = new Bitmap(PageFileSelected);
            Bitmap bitmapTemp = new Grayscale(0.2125, 0.7154, 0.0721).Apply(bitmap_0);

            bitmapTemp = new Threshold(100).Apply(bitmapTemp);
            bitmapTemp = new Invert().Apply(bitmapTemp);

            double[,] image  = ToolsConvolution.BitMapToDoubleArray(bitmapTemp, 0.5);
            double[,] kernel = ToolsConvolution.BitMapToDoubleArray(bitmapTemp, 0.5);
            Print(image);
            Print(kernel);
            //double[,] image = new double[6, 6];
            //image[2, 1] = 1;
            //image[2, 2] = 1;
            //image[2, 3] = 1;
            //image[2, 4] = 1;
            //double[,] kernel = new double[3, 3];
            //kernel[0, 0] = 1;
            //kernel[0, 1] = 1;
            //kernel[0, 2] = 1;
            //kernel[2, 1] = 1;
            //Print(image);
            //Print(kernel);

            //double[,] result = ToolsConvolution.CorrelationFFT(image, kernel);

            //Print(result);
            //Console.ReadLine();
            double [,] result = ToolsConvolution.CorrelationFFT(image, kernel);
            Print(result);
            //List<string> page = ToolsPDF.Convert(@"D:\Projects\hisdocpro\page.pdf");
        }
Пример #23
0
        public override void GetContent(Invert.Core.GraphDesigner.IDocumentationBuilder _)
        {
            base.GetContent(_);
            _.Paragraph("Commands define a property of type ISignal<TCommandClass> on an element.  These act as a delegate to a pre-initialized handler." +
                        "The handlers are setup in the controllers initialize method to point to a method, this makes a controller a factory for a view-model." +
                        "");

            var ele = new ScaffoldGraph()
                .BeginNode<ElementNode>("Player")
                .AddItem<CommandsChildItem>("Hit")
            .EndNode();
            _.Title2("Executing a command from a viewmodel.");
            _.CodeSnippet("MyViewModel.CommandName.OnNext(new {CommandName}Command() { });");
            _.Break();
            _.Title2("Generated Model Commands");
            _.TemplateExample<ViewModelTemplate, ElementNode>(ele as ElementNode, true, "CommandItems", "Bind");
            _.Break();
            _.Title2("Generated Controller Command Handlers");
            _.TemplateExample<ControllerTemplate, ElementNode>(ele as ElementNode, true, "CommandItems", "CommandMethod");
            _.Break();

            _.Break();
            _.Title3("Also See");
            _.LinkToPage<Controllers>();
            _.LinkToPage<CreationAndInitialization>();
        }
Пример #24
0
        public static Bitmap ApplyFilters(Image img)
        {
            Bitmap imagem = new Bitmap(img);

            imagem = imagem.Clone(new Rectangle(0, 0, img.Width, img.Height), System.Drawing.Imaging.PixelFormat.Format24bppRgb);
            Erosion        erosion    = new Erosion();
            Dilatation     dilatation = new Dilatation();
            Invert         inverter   = new Invert();
            ColorFiltering cor        = new ColorFiltering();

            cor.Blue  = new AForge.IntRange(200, 255);
            cor.Red   = new AForge.IntRange(200, 255);
            cor.Green = new AForge.IntRange(200, 255);
            Opening            open  = new Opening();
            BlobsFiltering     bc    = new BlobsFiltering();
            Closing            close = new Closing();
            GaussianSharpen    gs    = new GaussianSharpen();
            ContrastCorrection cc    = new ContrastCorrection();

            bc.MinHeight = 10;
            FiltersSequence seq           = new FiltersSequence(gs, inverter, open, inverter, bc, inverter, open, cc, cor, bc, inverter);
            var             filteredImage = seq.Apply(imagem);

            return(filteredImage);
        }
Пример #25
0
        /// <summary>
        /// Корректирует центр первой ячейки ответа
        /// </summary>
        /// <param name="image">ссылка на изображение</param>
        public void CorrectFirstCellCenter(Bitmap image)
        {
            //увеличиваем ячейки
            int maxWidth  = _cellswidth + Convert.ToInt16(_cellswidth * 2 / 3);
            int maxHeigth = _cellsheight + Convert.ToInt16(_cellsheight * 2 / 3);

            _cells.ReMeasure(_firstcelldistances, _intercentresdistx, maxWidth, maxHeigth);
            BitmapData  data        = image.LockBits(_cells[0].Rect, ImageLockMode.ReadWrite, image.PixelFormat);
            BlobCounter blobCounter = new BlobCounter();

            Invert invertfilter = new Invert();

            invertfilter.ApplyInPlace(data);
            blobCounter.ProcessImage(data);

            Blob[] blobs = blobCounter.GetObjectsInformation();
            int    maxar = 0;
            int    b     = 0;

            for (int i = 0; i < blobs.Count(); i++)
            {
                if (blobs[i].Area > maxar)
                {
                    maxar = blobs[i].Area; b = i;
                }
            }
            invertfilter.ApplyInPlace(data);
            image.UnlockBits(data);


            System.Drawing.Point p = new System.Drawing.Point(_cells[0].CenterOfGravity.X - ((maxWidth / 2) - Convert.ToInt16(blobs[b].CenterOfGravity.X)), _cells[0].CenterOfGravity.Y - ((maxHeigth / 2) - Convert.ToInt16(blobs[b].CenterOfGravity.Y)));
            _cells.ReMeasure(p, _intercentresdistx, _cellswidth, _cellsheight);
        }
Пример #26
0
        private Image <Gray, Byte> prepareImg2(System.Drawing.Image img, int threshold, bool invertImg)
        {
            Image <Gray, Byte> GrayImg = new Image <Gray, byte>((Bitmap)img);


            EmgImgProcssing = new ImageProcessing_Emgu();


            // create the filter
            BradleyLocalThresholding filter2 = new BradleyLocalThresholding();

            // apply the filter
            filter2.ApplyInPlace(GrayImg.Bitmap);

            GrayImg = GrayImg.Erode(1).Dilate(5).Erode(1);

            // create filter
            Invert filter3 = new Invert();

            // apply the filter
            filter3.ApplyInPlace(GrayImg.Bitmap);


            return(GrayImg);
        }
Пример #27
0
        public Bitmap Invert(Bitmap imgEdgeDetected)
        {
            Invert inv = new Invert();

            inv.ApplyInPlace(imgEdgeDetected);
            return(imgEdgeDetected);
        }
Пример #28
0
        public override bool CreateConfigurationMenu(ExtensionParameter extensionParameter, ref Dictionary <string, object> Parameters)
        {
            Invert = ImGuiExtension.Checkbox("Invert", Invert);
            ImGuiExtension.ToolTip("Check this box to invert the returned value of this condition.\nFor Example when enabled, if the condition returns true when in hideout, it would now return true when NOT in hideout.");
            Parameters[InvertString] = Invert.ToString();

            return(true);
        }
Пример #29
0
        public Bitmap GetNegativeImage()
        {
            Bitmap newImage = (Bitmap)image.Clone();
            Invert filter   = new Invert();

            filter.ApplyInPlace(newImage);
            return(newImage);
        }
Пример #30
0
        public Bitmap Invert()
        {
            Invert inv = new Invert();

            this.imgHandContour = inv.Apply(this.imgHandContour);
            //this.imgHandContour = inv.Apply(this.imgHandContourCut);
            return(this.imgHandContour);
        }
Пример #31
0
        public static Bitmap Invert(Bitmap Imagem)
        {
            Invert filter = new Invert();

            Imagem = Imagem.Clone(new Rectangle(0, 0, Imagem.Width, Imagem.Height), System.Drawing.Imaging.PixelFormat.Format24bppRgb);
            Imagem = filter.Apply(Imagem);
            return(Imagem);
        }
Пример #32
0
        /*
         * 1- gray scale transform;
         * */
        public void ToGray(ref Bitmap image)
        {
            image = (Bitmap)ResizeImage((System.Drawing.Image)image);

            // Create a blank bitmap with the same dimensions
            Bitmap imageGray = new Bitmap(image);


            Median medianFilter = new Median();

            // apply the filter
            medianFilter.ApplyInPlace(image);


            // create grayscale filter (BT709)
            Grayscale filter = new Grayscale(0.2125, 0.7154, 0.0721);

            // apply the filter
            image = filter.Apply(imageGray);

            // create filter
            Invert invertFilter = new Invert();

            // apply the filter
            invertFilter.ApplyInPlace(image);

            // create filter
            OtsuThreshold filterOtsuThreshold = new OtsuThreshold();

            // apply the filter
            filterOtsuThreshold.ApplyInPlace(image);
            // check threshold value
            int t = filterOtsuThreshold.ThresholdValue;

            /*
             * // create and configure the filter
             * FillHoles holesFilter = new FillHoles();
             * holesFilter.MaxHoleHeight = 2;
             * holesFilter.MaxHoleWidth = 2;
             * holesFilter.CoupledSizeFiltering = false;
             * // apply the filter
             * Bitmap result = holesFilter.Apply(image);
             *
             *
             * BinaryDilatation3x3 bd = new BinaryDilatation3x3();
             * bd.ApplyInPlace(image);
             * bd.ApplyInPlace(image);
             *
             * // create filter
             * BlobsFiltering filterBlobsFiltering = new BlobsFiltering();
             * // configure filter
             * filterBlobsFiltering.CoupledSizeFiltering = true;
             * filterBlobsFiltering.MinWidth = 5;
             * filterBlobsFiltering.MinHeight = 5;
             * // apply the filter
             * filterBlobsFiltering.ApplyInPlace(image);
             */
        }
Пример #33
0
        public Bitmap Invert(Bitmap Bmp)
        {
            Invert a = new Invert();

            Bmp = a.Apply(Bmp);
            AForge.Imaging.Image.FormatImage(ref Bmp);

            return(Bmp);
        }
Пример #34
0
        public override void GetContent(Invert.Core.GraphDesigner.IDocumentationBuilder _)
        {
            base.GetContent(_);

            _.Paragraph(
                "These are basically simple classes that automatically implement " +
                "INotifyPropertyChanged, which can help when quickly encapsulating " +
                "portable data and bridging uFrame with other Unity assets, libraries," +
                " and frameworks.  Class nodes can be used as Element node properties " +
                "and command parameters, which adds a whole new level of flexibility.");
        }
Пример #35
0
        public override void GetContent(Invert.Core.GraphDesigner.IDocumentationBuilder _)
        {
            base.GetContent(_);
            _.Paragraph("Collections are a bindable list on a view model that allow anything to be notified when a change occurs to the collection.");

            var ele = new ScaffoldGraph()
                .BeginNode<ElementNode>("Player")
                .AddItem<CollectionsChildItem>("Children")
            .EndNode();

            _.Title2("Generated Model Collections");
            _.TemplateExample<ViewModelTemplate, ElementNode>(ele as ElementNode, true, "CollectionProperty", "Bind");
        }
Пример #36
0
        public override void GetContent(Invert.Core.GraphDesigner.IDocumentationBuilder _)
        {
            base.GetContent(_);
            if (_uFrameBindingTypes == null)
            _uFrameBindingTypes = InvertApplication.Container.ResolveAll<uFrameBindingType>();
            foreach (var item in _uFrameBindingTypes)
            {
                _.Title2(item.DisplayFormat,"{Name}");
                _.Paragraph(item.Description);

                //var tempDecleration = new CodeTypeDeclaration();
                //item.CreateBindingSignature(new CreateBindingSignatureParams(tempDecleration,_=>new CodeTypeReference("PROPERTY_TYPE"), ))
             //   item.CreateBindingSignature()
            }
        }
Пример #37
0
        public override void GetContent(Invert.Core.GraphDesigner.IDocumentationBuilder _)
        {
            base.GetContent(_);
            var ele = new ScaffoldGraph()
            .BeginNode<ElementNode>("Player")
            .AddItem<PropertiesChildItem>("FirstName")
            .AddItem<PropertiesChildItem>("LastName")
            .EndNode();

            _.Title2("Subscribable Properties");
            _.TemplateExample<ViewModelTemplate, ElementNode>(ele as ElementNode, true, "ViewModelProperty");

            _.Title2("Value Wrapper Properties");
            _.TemplateExample<ViewModelTemplate, ElementNode>(ele as ElementNode, true, "ViewModelValueProperty");

            _.Title2("The Bind Method");
            _.TemplateExample<ViewModelTemplate, ElementNode>(ele as ElementNode, true, "Bind");
        }
    private void JumpStateChanged(CharacterViewModel character, Invert.StateMachine.State state)
    {
        if (state is NoJump)
        {
            character.JumpsPerformed = 0;
        }
        else if (state is DoJump)
        {
            character.JumpsPerformed++;
            character.JumpLocked = true;

            Observable
                .Timer(TimeSpan.FromMilliseconds(100))
                .Subscribe(l =>
                {
                    character.JumpLocked = false;
                });

        }
    }
Пример #39
0
        public override void GetContent(Invert.Core.GraphDesigner.IDocumentationBuilder _)
        {
            base.GetContent(_);

            _.Title2("What Is It?");
            _.Paragraph("Views are perhaps the easiest layer to understand in the context of Unity, due to the fact that they exist specifically to interact with the UnityEngine namespace and environment.  Views are the \"presentation\" layer, where the data of ViewModels are represented through the implementation of bindings.  The idea is that for the most part, ViewModel data exists somewhere already, and Views merely \"bind\" to that data in order to represent changes in a way that Unity and players can understand.");
            _.Title2("Where does it exist in Unity?");
            _.Paragraph("Views generated by uFrame inherit from Monobehaviour, and therefore are much like normal Unity components.  Building on top of Monobehaviour, uFrame ties into Unity methods like Update, Start, OnEnable, and OnDestroy in order to implement necessary MVCVM functionality within the Unity environment.  Every View that uFrame generates is meant to exist as a component on a particular GameObject.  For instance, a PlayerView should probably exist on some kind of Player GameObject, and a PlayerHUDView should probably exist on some kind of GUI GameObject to bind to and express a player's stats and other properties.");

            _.Title2("What Else?");
            _.Title3("The Presentation Layer");

            _.Paragraph("Views are the so-called \"presentation\" layer, where a programmer will implement the logic of how the abstracted ViewModel data is represented in a particular environment.  So if you have a PlayerViewModel, you may decide to represent that in any number of ways, including:");
            _.Paragraph(" - a PlayerView that represents the player as an animated character moving in space");
            _.Paragraph(" - a PlayerHUDView that represents the player's health, stamina, energy and other stats in your GUI");
            _.Paragraph(" - and maybe a PlayerMapView that represents your player's position relative to some kind of GUI Map object");

            _.Paragraph("All of these would typically want to bind to the same player ViewModel \"instance\", such that they are said to share the same ViewModel, representing the data in different ways.  The most important distinction is that each of these views should concern themselves with ONLY their own representation, meaning that the PlayerView in the above example should not be updating GUI elements, but rather leave that to the PlayerHUDView or possibly PlayerMapView.  Views should be as independent as possible, handling just themselves and their own interactions.  Since any number of Views can bind to the same ViewModel instance, it is up to you to determine how many Views are needed and what their individual responsibilities will be in representing that data inside Unity.");

            ImportantMethods(_);
        }
Пример #40
0
 public override void GetContent(Invert.Core.GraphDesigner.IDocumentationBuilder _)
 {
     base.GetContent(_);
     _.Title2("What is it?");
     _.Paragraph("ViewModels are the theoretical objects in your game.  " +
                       "They consist of data in the form of properties and collections, " +
                       "and also define the available commands for that object.  Because " +
                       "they are regular C# classes and do not inherit from Monobehaviour, " +
                       "ViewModels are very portable.  Although they do not require a View " +
                       "in order to exist, if you would like to represent a ViewModel's data " +
                       "in Unity, you would create a View and bind it to that ViewModel.");
     _.Break();
     _.Title2("Where does it exist in Unity?");
     _.Paragraph("ViewModels don't technically exist until runtime, at which point they are " +
                       "instantiated into memory as needed.  If a View exists in your scene, at runtime " +
                       "it will publish the 'ViewCreatedEvent' for the specific ViewModel it wants to bind to, at which " +
                       "point the ViewService will set the ViewModel with the matching given identifier," +
                       " creating it if it doesn't exist.  When defining single instances of a particular " +
                       "ViewModel through the uFrame Editor window on a subsystem, these instances are also " +
                       "created at runtime and will be readily available in the SceneManager's Dependency " +
                       "Container for any Views requesting them.");
 }
        public override void GetContent(Invert.Core.GraphDesigner.IDocumentationBuilder _)
        {
            base.GetContent(_);
            ElementNode elementNode;
            ScaffoldComputed(out elementNode);

            _.ImageByUrl("http://i.imgur.com/qeDjrVR.png");
            _.Paragraph("A Computed Property is an extremely powerful feature added to uFrame's ViewModel layer.  These properties can calculate their value based on other properties, and are recalculated whenever one of those change.  So for example, if you have a boolean IsDead computed property on a PlayerViewModel, dependent on a Player.Health property, uFrame will generate these three things on that PlayerViewModel for you to override:");
            _.Break();
            _.Title2("Under the hood");
            _.TemplateExample<ViewModelTemplate, ElementNode>(elementNode, true, "ComputedDependents", "ResetComputed", "Compute");

            _.Title3("ResetIsDead");
            _.Paragraph("Usually fine without overriding, used to set up the computed observable");

            _.Title3("ComputeIsDead");
            _.Paragraph("A \"getter\" used to compute the property, based on dependents");

            _.Title3("GetIsDeadDepedents");
            _.Paragraph("This where you would override and provide additional dependents, if needed");

            _.Break();
            _.Note("It's important to correctly set all the dependents, because the computed only knows when it needs to be recalculated by observing these dependents for changes.  This is done in the diagram by dragging a link from a ViewModel's property to the computed, or in code by overriding the Get{ComputedName}Dependents() function.");
        }
Пример #42
0
        public override void GetContent(Invert.Core.GraphDesigner.IDocumentationBuilder _)
        {
            base.GetContent(_);
            _.Paragraph("Usually a property binding is a one-way stream of information, where a View is simply receiving information about a property's changing values.  In a game environment however, there are times where it makes sense to allow Views to actually determine these values as well, for things like a GameObject's position, rotation, etc.  This is where two-way bindings are needed.");
            _.Paragraph("Scene Properties are two-way bindings, and allows for a View to calculate and set a property on its ViewModel.  This is done in an observable way, and when adding a scene property to a view, 3 specific methods are made available.  For example, adding a Position scene property on a PlayerView will result in these underlying base methods:");

            var graph = new ScaffoldGraph();
            PropertiesChildItem positionProperty;
            var player = graph.BeginNode<ElementNode>("Player")
                .AddItem("Position", out positionProperty, "Vector3")
                .EndNode();

            var view = (ViewNode) graph
                .BeginNode<ViewNode>("PlayerView")

                .EndNode()
                ;
            graph.AddConnection(player, view.ElementInputSlot);
            graph.AddConnection(positionProperty,view.ScenePropertiesInputSlot);

            _.Break();
            _.Title2("Under the hood. Generated Scene Properties");
            _.TemplateExample<ViewTemplate, ViewNode>(view, true,new [] {"ResetProperty", "CalculateProperty", "GetPropertyObservable", "Bind"});
            _.Break();
            _.Title3("ResetPosition");
            _.Paragraph("ResetPosition() is mostly used to initialize the binding, is called in the View's base Bind() method, and typically doesn't need to be overridden and altered.");
            _.Break();
            _.Title3("CalculatePosition");
            _.Paragraph("CalculatePosition() is the main method you would override on your generated PlayerView, where you would return a Vector3 to give the player's position.");
            _.ShowGist("2e5c9b6d07b76bcaedb1","CalculatePosition.cs");
            _.Break();
            _.Title3("GetPositionObservable");
            _.Paragraph("GetPositionObservable() should only be overridden in cases where you have a more convenient or performant method of observing the scene property change, because as you see, this calculation is happening every Update by default.  In this case, we know that ViewBase is already monitoring a TransformChangedObservable (and specifically a PositionChangedObservable as well), so on our PlayerView we would override the GetPositionObservable like this:");
            _.ShowGist("3d0e2f8bd65a044e82d6","GetPositionObservable.cs");
            _.Break();
        }
Пример #43
0
 public override void AnimalStateChanged(Invert.StateMachine.State arg1)
 {
     base.AnimalStateChanged (arg1);
 }
 /// Subscribes to the state machine property and executes a method for each state.
 public override void MovementStateMachineChanged(Invert.StateMachine.State value)
 {
     base.MovementStateMachineChanged(value);
 }
 /// Subscribes to the state machine property and executes a method for each state.
 public virtual void FireStateMachineChanged(Invert.StateMachine.State value)
 {
     if (value is Stop) {
         this.OnStop();
     }
     if (value is Fire) {
         this.OnFire();
     }
 }
 /// Subscribes to the state machine property and executes a method for each state.
 public virtual void MovementStateMachineChanged(Invert.StateMachine.State value)
 {
     if (value is Idle) {
         this.OnIdle();
     }
     if (value is Move) {
         this.OnMove();
     }
 }
Пример #47
0
 public virtual void InGameStateChanged(Invert.StateMachine.State arg1)
 {
     if (arg1 is Ready) {
         this.OnReady();
     }
     if (arg1 is Ongoing) {
         this.OnOngoing();
     }
     if (arg1 is Stop) {
         this.OnStop();
     }
 }
 /// Subscribes to the state machine property and executes a method for each state.
 public override void FireStateMachineChanged(Invert.StateMachine.State value)
 {
     base.FireStateMachineChanged(value);
 }
 public StringNodeViewModel(StringNode graphItemObject, Invert.Core.GraphDesigner.DiagramViewModel diagramViewModel) : 
         base(graphItemObject, diagramViewModel) {
 }
 public AllFalseNodeViewModel(AllFalseNode graphItemObject, Invert.Core.GraphDesigner.DiagramViewModel diagramViewModel) : 
         base(graphItemObject, diagramViewModel) {
 }
 public CollectionItemAddedNodeViewModel(CollectionItemAddedNode graphItemObject, Invert.Core.GraphDesigner.DiagramViewModel diagramViewModel) : 
         base(graphItemObject, diagramViewModel) {
 }
 public HandlerNodeViewModel(HandlerNode graphItemObject, Invert.Core.GraphDesigner.DiagramViewModel diagramViewModel) : 
         base(graphItemObject, diagramViewModel) {
 }
Пример #53
0
 public override void GetContent(Invert.Core.GraphDesigner.IDocumentationBuilder _)
 {
     base.GetContent(_);
 }
 public PropertyChangedNodeViewModel(PropertyChangedNode graphItemObject, Invert.Core.GraphDesigner.DiagramViewModel diagramViewModel) : 
         base(graphItemObject, diagramViewModel) {
 }
 public ComponentNodeViewModel(ComponentNode graphItemObject, Invert.Core.GraphDesigner.DiagramViewModel diagramViewModel) : 
         base(graphItemObject, diagramViewModel) {
 }
Пример #56
0
 public virtual void AnimalStateChanged(Invert.StateMachine.State arg1)
 {
     if (arg1 is Idle) {
         this.OnIdle();
     }
     if (arg1 is Destroying) {
         this.OnDestroying();
     }
     if (arg1 is Dropping) {
         this.OnDropping();
     }
 }
 public LiteralNodeViewModel(LiteralNode graphItemObject, Invert.Core.GraphDesigner.DiagramViewModel diagramViewModel) : 
         base(graphItemObject, diagramViewModel) {
 }
 public Vector2NodeViewModel(Vector2Node graphItemObject, Invert.Core.GraphDesigner.DiagramViewModel diagramViewModel) : 
         base(graphItemObject, diagramViewModel) {
 }
 public ActionGroupNodeViewModel(ActionGroupNode graphItemObject, Invert.Core.GraphDesigner.DiagramViewModel diagramViewModel) : 
         base(graphItemObject, diagramViewModel) {
 }
 public EnumValueNodeViewModel(EnumValueNode graphItemObject, Invert.Core.GraphDesigner.DiagramViewModel diagramViewModel) : 
         base(graphItemObject, diagramViewModel) {
 }