微波EDA网,见证研发工程师的成长!
首页 > 硬件设计 > 嵌入式设计 > 基于FPGA的手势语音转换器

基于FPGA的手势语音转换器

时间:06-04 来源:互联网 点击:

*PixelValue;

m10=m10+temp;

}

}

BarycenterX=(int)(m01/m00+0.5);

BarycenterY=(int)(m10/m00+0.5);

printf(%d,%d\n,BarycenterX,BarycenterY);

*(imgBufIn+BarycenterX*lineByte+BarycenterY)=0;

*(imgBufIn+(BarycenterX+1)*lineByte+BarycenterY)=0;

*(imgBufIn+BarycenterX*lineByte+BarycenterY+1)=0;

*(imgBufIn+(BarycenterX+1)*lineByte+BarycenterY+1)=0;

int ii,jj;

ii=0;jj=0;

for(j=0;jimgHeight;j++)

{

for(i=0;iimgWidth;i++)

{

PixelValue=*(imgBufIn+i*lineByte+j)/255;

m00=m00+PixelValue;

temp=i*PixelValue;//有问题的地方

m01=m01+temp;

temp=j*PixelValue;

m10=m10+temp;

m02=m02+(i-BarycenterX)*(i-BarycenterX)*PixelValue;

m20=m20+(j-BarycenterY)*(j-BarycenterY)*PixelValue;

m11=m11+(i-BarycenterX)*(j-BarycenterY)*PixelValue;

m30=m30+(j-BarycenterY)*(j-BarycenterY)*(j-BarycenterY)*PixelValue;

m03=m03+(i-BarycenterX)*(i-BarycenterX)*(i-BarycenterX)*PixelValue;

m21=m21+(j-BarycenterY)*(j-BarycenterY)*(i-BarycenterX)*PixelValue;

m12=m12+(i-BarycenterX)*(i-BarycenterX)*(j-BarycenterY)*PixelValue;

}

}

u20=m20/(m00*m00);u02=m02/(m00*m00);

u11=m11/(m00*m00);u21=m21/(pow(m00,2.5));

u12=m12/(pow(m00,2.5));u30=m30/(pow(m00,2.5));u03=m03/(pow(m00,2.5));

t1=m02/(m00*m00)+m20/(m00*m00);

t2=((m20-m02)/(m00*m00))*((m20-m02)/(m00*m00))+4*(m11/(m00*m00))*(m11/(m00*m00));

t3=m20*m02/(m00*m00*m00*m00)-(m11/(m00*m00))*(m11/(m00*m00));

t4=u02+u20;

t5=(u20-u02)*(u20-u02)+4*pow(u11,2);

t6=(u30-3*u12)*(u30-3*u12)+pow((3*u21-u03),2);

t7=(u30+u12)*(u30+u12)+(u03+u21)*(u03+u21);

printf(图像的几何矩为(%f,%f,%f,%f),t4,t5,t6,t7);

temp_charactor.t1=t4;

temp_charactor.t2=t5;

temp_charactor.t3=t6;

temp_charactor.t4=t7;

return temp_charactor;

}

4.5.2 手势图像的匹配

在特征匹配过程中,我们选择的是改进的欧式距离。

利用欧几里德距离,我们可以这样定义输入的手势图像与手势库中的任一手势图像之间的距离:

分别计算库中各手势图像与输入图像的距离最小的那副图像即为与输入手势匹配的手势。

其源码如下:

void match(finger_charactor temp)

{

int i;

/* temp.t1=temp.t1*100;

temp.t2=temp.t2*100000;

temp.t3=temp.t3*1000000;

temp.t4=temp.t4*100000;*/

float distance[NUMBER];

float lib[NUMBER][4]={

{0.978988,0.033434,0.041461,0.463083},//1

{0.738859,0.200313,0.008426,0.096310},//2

{0.695933,0.140033,0.004225,0.120884},//3

{0.585566,0.082715,0.014987,0.063054},//4

{0.650015,0.069188,0.013489,0.019868},//5

{0.812733,0.103417,0.054060,0.005729},//a

{1.042509,0.290926,0.031394,0.214864},//b

{0.932284,0.033224,0.030549,0.236714},//c

{0.571468,0.042114,0.011919,0.011260},//d

{1.186403,0.272240,0.330265,0.576809},//e

{0.060099,0.001802,0.000009,0.000001},//f

{0.045080,0.000206,0.000004,0.000001},//g

{0.057199,0.000116,0.000021,0.000025},//h

{0.046879,0.000133,0.000014,0.000003},//i

{0.050615,0.000029,0.000029,0.000005},//j

{0.054486,0.000735,0.000006,0.000001},//k

{0.059298,0.001286,0.000066,0.000056},//l

{0.043326,0.000131,0.000004,0.000000},//m

{0.046381,0.000206,0.000023,0.000002},//n

{0.051253,0.000032,0.000061,0.000008},//o

{0.051904,0.000511,0.000055,0.000013},//p

{0.052215,0.000403,0.000011,0.000004},//q

{0.059072,0.001608,0.000030,0.000013},//r

{0.043743,0.000254,0.000011,0.000000},//s

{0.044977,0.000256,0.000012,0.000001},//t

{0.056229,0.001272,0.000030,0.000013},//u

{0.074957,0.001632,0.000190,0.000040},//v

{0.046419,0.000015,0.000032,0.000002},//w

{0.050211,0.000031,0.000018,0.000001},//x

{0.051339,0.000011,0.000041,0.000003},//y

{0.059218,0.000423,0.000142,0.000003}//z

};

char gesture[NUMBER][2]={1,2,3,4,5,a,b,c,d,e,

f,g,h,i,j,k,l,m,n,o,

p,q,r,s,t,u,v,w,x,y,z

};

for(i=0;iNUMBER;i++)

{

distance[i]=fabs(temp.t1-lib[i][0])+fabs(temp.t2-lib[i][1])+fabs(temp.t3-lib[i][2])+fabs(temp.t4-lib[i][3]);

}

printf(\n);

printf(match distances are:);

printf(\n);

for(i=0;iNUMBER;i++)

{

Copyright © 2017-2020 微波EDA网 版权所有

网站地图

Top