Ejemplo n.º 1
0
        static void test_1()
        {
            Bitmap app  = new Bitmap(@"C:\logs\pictures\save_11.jpg");
            Bitmap app1 = new Bitmap(@"C:\logs\pictures\save_12.jpg");

            Tuple <bool, Rectangle, Bitmap> menu = ImUtility.extrac_context_menu(app, app1);

            if (menu.Item1 && menu.Item3 != null)
            {
                menu.Item3.Save("temp_1.jpg");
            }
            Image <Bgr, byte> am = new Image <Bgr, byte>(menu.Item3);
            //
            Mat t = CvInvoke.Imread(@"C:\logs\pictures\ios_icons\scroll.jpg");
            Mat m = new Mat();

            CvInvoke.MatchTemplate(am, t, m, TemplateMatchingType.CcoeffNormed);
            double max  = 0;
            double min  = 0;
            Point  maxP = new Point();
            Point  minP = new Point();

            CvInvoke.MinMaxLoc(m, ref min, ref max, ref minP, ref maxP);
            Program.logIt(string.Format("{0}: {1}", max, new Rectangle(maxP, t.Size)));
        }
Ejemplo n.º 2
0
        static void test_ppm()
        {
            //string folder = @"C:\projects\local\ca3\ca3";
            //foreach(string fn in System.IO.Directory.GetFiles(folder, "*.ppm"))
            //{
            //    ReadBitmapFromPPM(fn).Save("temp_1.jpg");
            //}
            //ReadBitmapFromPPM(@"C:\projects\svn\FDDev\GreenT Enterprise\Tools\AirPlay\AirplaySdkExample\Debug\screen\frame_0.ppm").Save("temp_1.bmp");
            byte[] data = System.IO.File.ReadAllBytes(@"C:\projects\svn\FDDev\GreenT Enterprise\Tools\AirPlay\release\screen\label_1.ppm");
            Bitmap b    = ImUtility.fromPPM(data);

            b.Save("temp_1.jpg");
            //Bitmap b1 = new Bitmap(@"C:\projects\svn\FDDev\GreenT Enterprise\Tools\AirPlay\release\screen\label_1.ppm");
        }
Ejemplo n.º 3
0
        static void camera_init()
        {
            Mat img = CvInvoke.Imread(@"C:\logs\pictures\save_10.jpg", ImreadModes.AnyColor);
            Tuple <bool, Rectangle, Bitmap> res = ImUtility.extrac_blue_block(img.Bitmap);

            if (res.Item3 != null && res.Item1)
            {
                res.Item3.Save("temp_1.jpg");
            }

            Tuple <bool, Rectangle> r = ImUtility.extra_blue_block_in_settings(img.Bitmap);

            if (r.Item1 && !r.Item2.IsEmpty)
            {
                Bitmap b = ImUtility.crop_image(img.Bitmap, r.Item2);
                b.Save("temp_2.jpg");
            }
        }
Ejemplo n.º 4
0
        static void test_similarity()
        {
            Bitmap    b1  = new Bitmap("temp_1.jpg");
            Bitmap    t   = new Bitmap(@"C:\projects\local\github\testMQ\testMQ\scripts\get_imei\xhahnbyc.jpg");
            Rectangle r   = new Rectangle(33, 908, 102, 102);
            Bitmap    b10 = ImUtility.crop_image(b1, r);
            Bitmap    b20 = ImUtility.crop_image(t, r);

            Image <Gray, Byte> b11 = new Image <Gray, byte>(b10);
            Image <Gray, Byte> t11 = new Image <Gray, byte>(b20);
            Mat m = new Mat();

            CvInvoke.Threshold(b11, m, 0, 255, ThresholdType.Otsu | ThresholdType.Binary);
            b1 = m.Bitmap;
            CvInvoke.Threshold(t11, m, 0, 255, ThresholdType.Otsu | ThresholdType.Binary);
            t = m.Bitmap;
            //var res = ImUtility.multiscale_matchtemplate(b1, t);
            ImUtility.is_same_image(b1, t);

            //b11.Save("temp_2.jpg");
            //b21.Save("temp_3.jpg");
            //ImUtility.is_same_image(b11, b21);
        }
Ejemplo n.º 5
0
        static void test3()
        {
            Bitmap    b1 = new Bitmap(@"C:\logs\pictures\save_01.jpg");
            Bitmap    b2 = new Bitmap(@"C:\logs\pictures\save_06.jpg");
            Rectangle r  = ImUtility.detect_blue_rectangle(b1, b2);
            Bitmap    m  = ImUtility.crop_image(b2, r);

            m.Save("temp_1.jpg");
            //ImUtility.crop_image(m, r).Save("temp_2.jpg");
            if (m != null)
            {
                Image <Gray, Byte> bb1 = new Image <Gray, byte>(m);
                Mat tmp = new Mat();
                CvInvoke.Threshold(bb1, tmp, 0, 255, ThresholdType.Binary | ThresholdType.Otsu);
                tmp.Save("temp_1.jpg");
                Rectangle ret = Rectangle.Empty;
                using (VectorOfVectorOfPoint contours = new VectorOfVectorOfPoint())
                {
                    CvInvoke.FindContours(tmp, contours, null, RetrType.External, ChainApproxMethod.ChainApproxNone);
                    int    count = contours.Size;
                    double mx    = 0.0;
                    for (int i = 0; i < count; i++)
                    {
                        double d = CvInvoke.ContourArea(contours[i]);
                        if (d > mx)
                        {
                            mx  = d;
                            ret = CvInvoke.BoundingRectangle(contours[i]);
                            Program.logIt(string.Format("{0}: {1}", d, ret));
                        }
                    }
                }
                Image <Bgr, Byte> b = new Image <Bgr, byte>(m);
                b.GetSubRect(ret).Save("temp_2.jpg");
            }
        }