基于Aforge的手势识别之一 简单的手写识别

本文介绍了一种基于运动物体捕捉和手写识别的手势识别技术。通过记录运动轨迹并利用手写识别引擎进行匹配,实现了对字母和数字的手势识别。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

               

本文来自http://blog.youkuaiyun.com/hellogv/ ,引用必须注明出处!

     上一篇文章介绍了如何用Aforge去捕捉运动物体,现在就介绍一个更深入的操作----手势识别。
      我实现手势识别的原理很简单:捕捉运动物体+手写识别,把运动的物体的轨迹记录下来,然后通过手写识别引擎去搜索数据中最匹配的数据,从而知道“写”的是什么。目前常见的开源手写识别引擎有zinnia,wagomu 这些,不过小弟我比较业余,只把网上的比较常见的手写识别代码改进一下,只能识别字母和数字,真想通过摄像头隔空“手写”的朋友就要多花时间玩玩上面提到的几个开源手写类库了。

      本文介绍的手写识别:先在一个固定大小的画板上,用鼠标画下某图形,输入该图形对应的字母,程序把画板上的字母特征点都保存下来特征数据库(相当于学习记忆),然后再在画板上画出类似该字母的图形,程序就通过新画的特征点搜索特征数据库从而找出最类似的字母。

接下来贴出核心代码,详细的代码请到这里下载:http://download.youkuaiyun.com/source/2312865

GetBMPContext()是把画板中的图形的特征分析出来,Learn()是把特征与特定的字母/数字对应起来保存到数据库,Recognise()是把当前画板的图形特征从数据库中搜索,从而找出对应的字母/数字。

        const int SCAN_GAP = 10;        private String GetBMPContext(Bitmap bmp)        {            Boolean bool1stScan = true;            int ax = 0, ay = 0, bx = 0, by = 0;            String result = "";            for (int i = 1; i < bmp.Width; i = i + SCAN_GAP)            {                for (int j = 1; j < bmp.Height; j = j + SCAN_GAP)                {                    if (bmp.GetPixel(i, j).ToArgb() == Color.Black.ToArgb())                    {                        if (bool1stScan == false)                        {                            if (i <= ax) ax = i;                            if (i >= bx) bx = i;                            if (j <= ay) ay = j;                            if (j >= by) by = j;                        }                        else                        {                            bool1stScan = false;                            ax = i;                            bx = i;                            ay = j;                            by = j;                        }                    }                }            }            Bitmap bmp2 = new Bitmap(20, 20);            Graphics g2 = Graphics.FromImage((Image)bmp2);            g2.Clear(Color.White);            g2.DrawImage(bmp, new Rectangle(0, 0, bmp2.Width, bmp2.Height),                new Rectangle(0, 0, bmp.Width, bmp.Height), GraphicsUnit.Pixel);            g2.Dispose();            //            pictureBox1.Image = bmp2;            int a = 0, b = 0;            for (int i = 0; i < bmp2.Width; i++)            {                for (int j = 0; j < bmp2.Height; j++)                {                    if (bmp2.GetPixel(i, j).ToArgb() == Color.Black.ToArgb())                        result = result + "0";                    else                        result = result + "1";                }            }            return result;        }        public void Learn(String name)        {            StreamWriter sw = new StreamWriter(fileName, true);            sw.WriteLine(name + " " + GetBMPContext(bmpDraw));            sw.Close();        }        public String Recognise()        {            String current = GetBMPContext(bmpDraw);            StreamReader sr = new StreamReader(fileName);            int max = 0;            String result = "";            while (sr.EndOfStream == false)            {                String[] key = sr.ReadLine().Split(' ');                String name = key[0];                String data = key[1];                int match = 0;                for (int i = 0; i < current.Length; i++)                {                    if (current[i] == data[i])                        match++;                }                if (match >= max)                {                    result = name;                    max = match;                }                //Trace.WriteLine(result + ":" + match + "," + max);            }            sr.Close();            return result;        }  

           

再分享一下我老师大神的人工智能教程吧。零基础!通俗易懂!风趣幽默!还带黄段子!希望你也加入到我们人工智能的队伍中来!https://blog.youkuaiyun.com/jiangjunshow

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值