示例#1
0
        public void Left()
        {// soldan tarama
            BitmapSettings bmps = new BitmapSettings(bmp1);

            bmps.LockBits();

            for (int x = 1; x < bmp1.Width - 1; x++)
            {
                for (int y = 0; y < bmp1.Height; y++)
                {
                    lock (_LOCK)
                    {
                        if (bmps.GetPixel(x, y) == Color.FromArgb(255, 255, 255))
                        {
                            LeftHis[x] += 1;
                        }
                    }
                }

                if (LeftHis[x] > setoff_x && LeftHis[x - 1] <= setoff_x)
                {
                    Koordinat[1] = x;    //x_min
                }
            }

            bmps.UnlockBits();

            if (LeftHis[2] >= setoff_bilek) /* bilek fonksiyonunu çağır*/ Koordinat {
示例#2
0
        //find fingertip countour
        public Bitmap finger_tip(Bitmap otsut, int x_max, int x_min, int y_max, int y_min)
        {

            int count_pixel;
            int deger;
            int limit_first;
            int limit_second;
            int aralik;

            BitmapSettings otsus = new BitmapSettings(otsut);
            otsus.LockBits();
            for (int x = x_min; x <= x_max; x++)
            {
                count_pixel = 0;

                aralik = 1;
                limit_first = 0;
                limit_second = 0;


                for (int y = y_max; y >= y_min; y--)//aşagıdan yukarı tarama
                {
                    if (otsus.GetPixel(x, y) == Color.FromArgb(255, 255, 255))
                    {
                        limit_first = y;
                        break;
                    }

                }

                for (int y = y_min; y <= y_max; y++)//yukarıdan aşağı tarama
                {
                    if (otsus.GetPixel(x, y) == Color.FromArgb(255, 255, 255))
                    {
                        limit_second = y;
                        break;
                    }
                }

                count_pixel = (limit_first - limit_second) + 1;



                for (int y = limit_first; y >= limit_second; y--)
                {

                    deger = (int)Math.Round(aralik * (255 / (double)count_pixel));
                    otsus.SetPixel(x, y, Color.FromArgb(deger, deger, deger));

                    aralik++;
                }

            }


            for (int y = y_min; y <= y_max; y = y + 1)
            {
                for (int x = x_min; x <= x_max; x = x + 1)
                {
                    if (otsus.GetPixel(x, y).R != 255)
                    {
                        otsus.SetPixel(x, y, Color.FromArgb(0, 0, 0));

                    }

                }
            }
            otsus.UnlockBits();
            return otsut;
        }
示例#3
0
        public int[] FingersFind(Bitmap otsu, int x_max, int x_min, int y_max, int y_min)//parmak uçları olan bitmap
        {


              int[] parmak_xy = new int[10];//5 olacak
          
         
            Array.Clear(parmak_xy, 0, parmak_xy.Length);
          



            BitmapSettings otsus = new BitmapSettings(otsu);
            otsus.LockBits();

            int dizi_boyutu = Math.Abs(x_max - x_min);
         
         



            int[] beyazPiksel_Y = new int[dizi_boyutu + 10];
            int[] beyazPiksel_X = new int[dizi_boyutu + 10];
            int t = 0;

            for (int x = x_min; x < x_max; x++)
            {
                for (int y = y_min; y < y_max; y++)
                {
                    if (otsus.GetPixel(x, y).R == 255)
                    {
                        if(t<beyazPiksel_Y.Length){
                        beyazPiksel_Y[t] = y;
                        beyazPiksel_X[t] = x;
                        //otsus.SetPixel(x, y, Color.Blue);
                        t++;
                    }
                }
                 
                    for (int p = 0; p < beyazPiksel_Y.Length; p++)
                    {
                        if (beyazPiksel_Y[p] == 0) { beyazPiksel_Y[p] = 1000; beyazPiksel_X[p] = 1000; }
                    }

                }
            }
            beyazPiksel_Y[0] = 1000;
            beyazPiksel_X[0] = 1000;

            beyazPiksel_Y[1] = 1000;
            beyazPiksel_X[1] = 1000;

            
            
                parmak_xy[0] = beyazPiksel_Y.Min();
                parmak_xy[5] = beyazPiksel_X[beyazPiksel_Y.ToList().IndexOf(beyazPiksel_Y.Min())];

                int d = 25;
                int s = beyazPiksel_Y.ToList().IndexOf(beyazPiksel_Y.Min());
            for (int n = s -d; n < s + d; n++)
            {
                if (n > 0 && n < beyazPiksel_Y.Length)
                {
                   
                    beyazPiksel_Y[n] = 1000;
                    beyazPiksel_X[n] = 1000;

                }
            }

            
                parmak_xy[1] = beyazPiksel_Y.Min();  //y
                parmak_xy[6] = beyazPiksel_X[beyazPiksel_Y.ToList().IndexOf(beyazPiksel_Y.Min())];//x
            

            s = beyazPiksel_Y.ToList().IndexOf(beyazPiksel_Y.Min());
            for (int n = s - d; n < s + d; n++)
            {
                if (n > 0 && n < beyazPiksel_Y.Length)
                {
                    
                    beyazPiksel_Y[n] = 1000;
                    beyazPiksel_X[n] = 1000;

                }
            }

          


                parmak_xy[2] = beyazPiksel_Y.Min();
                parmak_xy[7] = beyazPiksel_X[beyazPiksel_Y.ToList().IndexOf(beyazPiksel_Y.Min())];
            
            s = beyazPiksel_Y.ToList().IndexOf(beyazPiksel_Y.Min());
            for (int n = s - d; n < s + d; n++)
            {
                if (n > 0 && n < beyazPiksel_Y.Length)
                {
                    
                    beyazPiksel_Y[n] = 1000;
                    beyazPiksel_X[n] = 1000;

                }
            }


           
                parmak_xy[3] = beyazPiksel_Y.Min();
                parmak_xy[8] = beyazPiksel_X[beyazPiksel_Y.ToList().IndexOf(beyazPiksel_Y.Min())];
            

            s = beyazPiksel_Y.ToList().IndexOf(beyazPiksel_Y.Min());
            for (int n = s - d; n < s + d; n++)
            {
                if (n > 0 && n < beyazPiksel_Y.Length)
                {
                    
                    beyazPiksel_Y[n] = 1000;
                    beyazPiksel_X[n] = 1000;

                }
            }

          
                parmak_xy[4] = beyazPiksel_Y.Min();
                parmak_xy[9] = beyazPiksel_X[beyazPiksel_Y.ToList().IndexOf(beyazPiksel_Y.Min())];
            
            s = beyazPiksel_Y.ToList().IndexOf(beyazPiksel_Y.Min());
            for (int n = s - d; n < s + d; n++)
            {
                if (n > 0 && n < beyazPiksel_Y.Length)
                {
                    beyazPiksel_Y[n] = 1000;
                    beyazPiksel_X[n] = 1000;

                }
            }


            otsus.UnlockBits();


            return parmak_xy;

        }
示例#4
0
        public void Up()
        {
            ///Yukarıdan tarama
            ///
            BitmapSettings bmps = new BitmapSettings(bmp3);
            bmps.LockBits();

                for (int y = 1; y < bmp3.Height - 1; y++)
                {
                    for (int x = 0; x < bmp3.Width; x++)
                    {
                        lock (_LOCK)
                        {

                          if (bmps.GetPixel(x, y) == Color.FromArgb(255, 255, 255))
                          {
                             UpHis[y] += 1;
                           }
                        }
                    }

                    if (first_ymin == 0 && UpHis[y] > setoff_y && UpHis[y - 1] <= setoff_y)
                    {
                        first_ymin = 1;
                        Koordinat[3] = y;//y_min

                    }

            }
                bmps.UnlockBits();

            if (UpHis[2] >= setoff_bilek) { /* bilek fonksiyonunu çağır*/  Koordinat[3] = bilek_bul(UpHis, 0); yon = 4; }
        }
示例#5
0
        public void Right()
        {
            ///sağdan tarama
            BitmapSettings bmps = new BitmapSettings(bmp2);
            bmps.LockBits();

                for (int x = bmp2.Width - 2; x >= 0; x--)
                {
                    for (int y = 0; y < bmp2.Height; y++)
                    {
                        lock (_LOCK)
                        {
                          if (bmps.GetPixel(x, y) == Color.FromArgb(255, 255, 255))
                          {
                            RightHis[x] += 1;
                          }
                        }
                    }

                    if (first_xmax == 0 && RightHis[x] > setoff_x && RightHis[x + 1] <= setoff_x)
                    {
                        first_xmax = 1;
                        Koordinat[0] = x;//x_max

                    }

            }

                bmps.UnlockBits();

            if (RightHis[bmp2.Width - 3] >= setoff_bilek)
            { /* bilek fonksiyonunu çağır*/    Koordinat[0] = bilek_bul(RightHis, 1); yon = 2; }
        }
示例#6
0
        public void Left()
        {
            // soldan tarama

            BitmapSettings bmps = new BitmapSettings(bmp1);
            bmps.LockBits();

                for (int x = 1; x < bmp1.Width - 1; x++)
                {
                    for (int y = 0; y < bmp1.Height; y++)
                    {
                        lock (_LOCK)
                        {

                           if (bmps.GetPixel(x, y) == Color.FromArgb(255, 255, 255))
                           {
                            LeftHis[x] += 1;
                           }

                        }

                    }

                    if (LeftHis[x] > setoff_x && LeftHis[x - 1] <= setoff_x)
                    {
                        Koordinat[1] = x;//x_min
                    }

            }

                bmps.UnlockBits();

            if (LeftHis[2] >= setoff_bilek) { /* bilek fonksiyonunu çağır*/   Koordinat[1] = bilek_bul(LeftHis, 0); yon = 1; }
        }
示例#7
0
        public void Down()
        {
            ///Aşağıdan tarama
            BitmapSettings bmps = new BitmapSettings(bmp4);
            bmps.LockBits();
                for (int y = bmp4.Height - 2; y >= 0; y--)
                {
                    for (int x = 0; x < bmp4.Width; x++)
                    {

                        lock (_LOCK)
                        {
                          if (bmps.GetPixel(x, y) == Color.FromArgb(255, 255, 255))
                           {
                            DownHis[y] += 1;
                           }
                        }
                    }

                    if (first_ymax == 0 && DownHis[y] > setoff_y && DownHis[y + 1] <= setoff_y)
                    {
                        first_ymax = 1;
                        Koordinat[2] = y;//ymax
                    }

            }

                bmps.UnlockBits();

            if (DownHis[bmp4.Height - 3] >= 30)
            { /* bilek fonksiyonunu çağır*/  Koordinat[2] = bilek_bul(DownHis, 1); yon = 3; }
        }
示例#8
0
        //parmak uçları olan bitmap
        public int[] FingersFind(Bitmap otsu, int x_max, int x_min, int y_max, int y_min)
        {
            int[] parmak_xy = new int[10];//5 olacak

            Array.Clear(parmak_xy, 0, parmak_xy.Length);

            BitmapSettings otsus = new BitmapSettings(otsu);
            otsus.LockBits();

            int dizi_boyutu = Math.Abs(x_max - x_min);

            int[] beyazPiksel_Y = new int[dizi_boyutu + 10];
            int[] beyazPiksel_X = new int[dizi_boyutu + 10];
            int t = 0;

            for (int x = x_min; x < x_max; x++)
            {
                for (int y = y_min; y < y_max; y++)
                {
                    if (otsus.GetPixel(x, y).R == 255)
                    {
                        if(t<beyazPiksel_Y.Length){
                        beyazPiksel_Y[t] = y;
                        beyazPiksel_X[t] = x;
                        //otsus.SetPixel(x, y, Color.Blue);
                        t++;
                    }
                }

                    for (int p = 0; p < beyazPiksel_Y.Length; p++)
                    {
                        if (beyazPiksel_Y[p] == 0) { beyazPiksel_Y[p] = 1000; beyazPiksel_X[p] = 1000; }
                    }

                }
            }
            beyazPiksel_Y[0] = 1000;
            beyazPiksel_X[0] = 1000;

            beyazPiksel_Y[1] = 1000;
            beyazPiksel_X[1] = 1000;

                parmak_xy[0] = beyazPiksel_Y.Min();
                parmak_xy[5] = beyazPiksel_X[beyazPiksel_Y.ToList().IndexOf(beyazPiksel_Y.Min())];

                int d = 25;
                int s = beyazPiksel_Y.ToList().IndexOf(beyazPiksel_Y.Min());
            for (int n = s -d; n < s + d; n++)
            {
                if (n > 0 && n < beyazPiksel_Y.Length)
                {

                    beyazPiksel_Y[n] = 1000;
                    beyazPiksel_X[n] = 1000;

                }
            }

                parmak_xy[1] = beyazPiksel_Y.Min();  //y
                parmak_xy[6] = beyazPiksel_X[beyazPiksel_Y.ToList().IndexOf(beyazPiksel_Y.Min())];//x

            s = beyazPiksel_Y.ToList().IndexOf(beyazPiksel_Y.Min());
            for (int n = s - d; n < s + d; n++)
            {
                if (n > 0 && n < beyazPiksel_Y.Length)
                {

                    beyazPiksel_Y[n] = 1000;
                    beyazPiksel_X[n] = 1000;

                }
            }

                parmak_xy[2] = beyazPiksel_Y.Min();
                parmak_xy[7] = beyazPiksel_X[beyazPiksel_Y.ToList().IndexOf(beyazPiksel_Y.Min())];

            s = beyazPiksel_Y.ToList().IndexOf(beyazPiksel_Y.Min());
            for (int n = s - d; n < s + d; n++)
            {
                if (n > 0 && n < beyazPiksel_Y.Length)
                {

                    beyazPiksel_Y[n] = 1000;
                    beyazPiksel_X[n] = 1000;

                }
            }

                parmak_xy[3] = beyazPiksel_Y.Min();
                parmak_xy[8] = beyazPiksel_X[beyazPiksel_Y.ToList().IndexOf(beyazPiksel_Y.Min())];

            s = beyazPiksel_Y.ToList().IndexOf(beyazPiksel_Y.Min());
            for (int n = s - d; n < s + d; n++)
            {
                if (n > 0 && n < beyazPiksel_Y.Length)
                {

                    beyazPiksel_Y[n] = 1000;
                    beyazPiksel_X[n] = 1000;

                }
            }

                parmak_xy[4] = beyazPiksel_Y.Min();
                parmak_xy[9] = beyazPiksel_X[beyazPiksel_Y.ToList().IndexOf(beyazPiksel_Y.Min())];

            s = beyazPiksel_Y.ToList().IndexOf(beyazPiksel_Y.Min());
            for (int n = s - d; n < s + d; n++)
            {
                if (n > 0 && n < beyazPiksel_Y.Length)
                {
                    beyazPiksel_Y[n] = 1000;
                    beyazPiksel_X[n] = 1000;

                }
            }

            otsus.UnlockBits();

            return parmak_xy;
        }
示例#9
0
        //find fingertip countour
        public Bitmap finger_tip(Bitmap otsut, int x_max, int x_min, int y_max, int y_min)
        {
            int count_pixel;
            int deger;
            int limit_first;
            int limit_second;
            int aralik;

            BitmapSettings otsus = new BitmapSettings(otsut);
            otsus.LockBits();
            for (int x = x_min; x <= x_max; x++)
            {
                count_pixel = 0;

                aralik = 1;
                limit_first = 0;
                limit_second = 0;

                for (int y = y_max; y >= y_min; y--)//aşagıdan yukarı tarama
                {
                    if (otsus.GetPixel(x, y) == Color.FromArgb(255, 255, 255))
                    {
                        limit_first = y;
                        break;
                    }

                }

                for (int y = y_min; y <= y_max; y++)//yukarıdan aşağı tarama
                {
                    if (otsus.GetPixel(x, y) == Color.FromArgb(255, 255, 255))
                    {
                        limit_second = y;
                        break;
                    }
                }

                count_pixel = (limit_first - limit_second) + 1;

                for (int y = limit_first; y >= limit_second; y--)
                {

                    deger = (int)Math.Round(aralik * (255 / (double)count_pixel));
                    otsus.SetPixel(x, y, Color.FromArgb(deger, deger, deger));

                    aralik++;
                }

            }

            for (int y = y_min; y <= y_max; y = y + 1)
            {
                for (int x = x_min; x <= x_max; x = x + 1)
                {
                    if (otsus.GetPixel(x, y).R != 255)
                    {
                        otsus.SetPixel(x, y, Color.FromArgb(0, 0, 0));

                    }

                }
            }
            otsus.UnlockBits();
            return otsut;
        }