Online handwriting with upper letter
I just try to make use of the letter stroke num & the track of the stroke to classify the letter.
the result is pretty good.I finish it base OPENCV 1.0, with VC2005 at XP.
1.traning process
recording the mouse track => disperse the track => got 50 points => get max square width
=>make them into same size(ignore the letter size)=> calculate FFT from X,Y, and got the first 5 num
=> write data.txt
2.recognizing part
load the data=>use the Random Trees to classify => get feature data => predict the letter.
3.the format of feature data
letter + stroke num + stroke n X 5FFT + stroke n Y 5FFT (n = 0,1,2)
A 3 .....
if the letter has no more strokes,just write 0 data.
4. how to write the letter
online upper letter rule
1. C J L O S U V W Z finish in one stroke
2. B D G K M N P Q T X Y finish in two stroke
3. A E F H I R finish in three stroke
You’d better follow the rule from attach video.
5.shortage
although the training data is not enough, maybe need more training.
sometime the letter K will be as P .
can not rotate the letter.
6.need improve
can not classify lower letter, because the lower letter “c o x v s z p” looks same with the upper ones.
maybe need add HMM later.
maybe classify the Arabic numerals later.
7.how to use
1. there two state (recognizing and training) for the app,In recognizing mode,use your mouse write upper letter on ‘Win’ window,after 1 second,then will get result on Win2。
2. you can press ‘m’ key to change mode from recognizing to training or back.
3. In training mode,change the value of letter, then you can write upper letter on ‘Win’ window, and app will write data into data.txt.”
4. you can retrain the training data by press ‘t’ without restart program.
5. you can modify the training data ‘data.txt’ by hand if you want or any error input.
联机手写大写英文字母识别演示
利用了联机手写的笔画数目,笔画轨迹做为特征量进行识别。训练测试接近100%.实际识别也比较准。
1。训练部分
记录鼠标轨迹=>将轨迹离散化=>提取每个轨迹上等距的50个点=>求取轨迹最大外接正方形宽度
=>整理数据统一大小(使得特征数据不依赖书写的大小)=> 对X,Y分别傅立叶变换提取五个主要谐波A0-A4
=>写入数据
2。识别部分
载入训练数据=>使用Random Trees分类=>得到特征数据=>预测
3.特征数据格式
类别 + 轨迹数量 + 轨迹n X分量的傅立叶变换 + 轨迹n Y分量的傅立叶变换 (n = 0,1,2)
A 3 ..... .....
如果没有轨迹用0补充.
4.大写字母书写规则
26个字母要按一定笔划顺序书写。书写的规律有以下几点:
联机大写字母书写规则
1. C J L O S U V W Z 一笔划完成
2. B D G K M N P Q T X Y 两笔划完成
3. A E F H I R 三笔划完成
详细的书写方法见视频, 需要严格按照视频中的书写笔划。
5.缺点
因为数据量大小,训练测试接近100%,是否需要加入更多的数据?
需要使用者按照标准的大写写法写,偶尔有的时候K字母有点问题.
不支持带角度的书写.
目前特征数据也没有做归一化,因为觉得识别结果还可以就没做。
目前只尝试了Random Trees,参数也没怎么调整过。
是否需要SVM训练?(目前版本svm存储训练结果有问题).
6。改进
这只是个DEMO , 目前不能识别小写字母,因为某些小写字母:c o x v s z p 等基本与大写字母一样,还要想方法解决。
还没有充分利用到笔顺特征,笔划时间,加入HMM预测(单词?)。
还要加入阿拉伯数字识别。
7.使用方法
1.程序有两个状态,识别状态与训练状态,默认为识别状态,用鼠标在win窗口书写大写字母,当鼠标离开一秒后,win2窗口显示训练结果。
2.使用m切换状态
3.在训练状态,调节letter控条,显示需要训练的字母,然后在win窗口书写大写字母,特征数据会写入data.txt
4.可以按t键,重新训练模型
5.如果程序出错,或者写入出错,可以手工编辑data.txt
代码下载(download)
opencv_share@163.com download