Exemple #1
0
        public void TestLKFlow()
        {
            var im1 = new Gray <float> [480, 640];

            im1.SetValue <Gray <float> >(System.Byte.MaxValue, new Rectangle(272, 82, 116, 64));

            var im2 = new Gray <float> [480, 640];

            im2.SetValue <Gray <float> >(System.Byte.MaxValue, new Rectangle(277, 83, 116, 64));

            var pts = new List <PointF>();

            pts.Add(new PointF(272, 82)); //-> 277,83

            PointF[]           currFeatures;
            KLTFeatureStatus[] featureStatus;

            /*LKOpticalFlow<Gray<float>>.EstimateFlow(lkStorage, pts.ToArray(),
             *                                        out currFeatures, out featureStatus);*/

            PyrLKOpticalFlow <Gray <float> > .EstimateFlow(im1, im2, pts.ToArray(),
                                                           out currFeatures, out featureStatus);

            Assert.IsTrue(featureStatus[0] == KLTFeatureStatus.Success);
            Assert.IsTrue(Math.Round(currFeatures[0].X) == 277 && Math.Round(currFeatures[0].Y) == 83);
        }
Exemple #2
0
        static void Main(string[] args)
        {
            Directory.SetCurrentDirectory(AppDomain.CurrentDomain.BaseDirectory);
            Environment.SetEnvironmentVariable("PATH", Environment.GetEnvironmentVariable("PATH") + ";runtimes/win10-x64/"); //only needed if projects are directly referenced

            //select color
            Bgr <byte>[,] image = new Bgr <byte> [480, 640];
            Hsv <byte> color = UI.PickColor(Bgr <byte> .Red).ToHsv();

            //select mask
            Gray <byte>[,] mask = image.GetMask();
            if (mask.AsEnumerable().Sum(x => x.Intensity) == 0) //if the mask is empty
            {
                mask.SetValue <Gray <byte> >(Byte.MaxValue);
            }

            //increase saturation incrementally
            for (int s = 0; s <= Byte.MaxValue; s++)
            {
                color.S = (byte)s;
                image.SetValue <Bgr <byte> >(color.ToBgr(), mask);

                image.Show(scaleForm: true);
                ((double)s / Byte.MaxValue).Progress(message: "Changing saturation");

                Thread.Sleep(50);
            }

            //save last image
            string fileName = UI.SaveImage();

            if (fileName != null)
            {
                image.Save(fileName);
            }

            //close all
            UI.CloseAll();
        }
Exemple #3
0
        static void Main(string[] args)
        {
            //select color
            Bgr <byte>[,] image = new Bgr <byte> [480, 640];
            Hsv <byte> color = UI.PickColor(Bgr <byte> .Red).ToHsv();

            //select mask
            Gray <byte>[,] mask = image.GetMask();
            if (mask.AsEnumerable().Sum(x => x.Intensity) == 0) //if the mask is empty
            {
                mask.SetValue <Gray <byte> >(Byte.MaxValue);
            }

            //increase saturation incrementally
            for (int s = 0; s <= Byte.MaxValue; s++)
            {
                color.S = (byte)s;
                image.SetValue <Bgr <byte> >(color.ToBgr(), mask);

                image.Show(scaleForm: true);
                ((double)s / Byte.MaxValue).Progress(message: "Changing saturation");

                Thread.Sleep(50);
            }

            //save last image
            string fileName = UI.SaveImage();

            if (fileName != null)
            {
                image.Save(fileName);
            }

            //close all
            UI.CloseAll();
        }