• 大小: 5.69MB
    文件类型: .zip
    金币: 1
    下载: 0 次
    发布日期: 2023-11-12
  • 语言: 其他
  • 标签: opencv  手势识别  

资源简介

一个实现石头剪刀布的小程序,基于opencv,在vs2010和opencv2.4.4下可以完美运行。

资源截图

代码片段和文件信息

// @Author:onezeros@yahoo.cn
// @Date:10/8/2010

//abstract features:width/height white pixels ratio
#include 
#include 
#include 

#include 
#include 
#include 
#include 
#include 
#include 
using namespace std;

void featrue(IplImage* imgfloat& widHeiRatiofloat& whitePixelRatio)
{
assert(img->nChannels==1);
unsigned long whitePixelNum=0;

int top=img->height;
int bottom=-1;
int right=0;
for (int w=0;wwidth;w++){
bool isBlack=true;
int b=-1;
int t=-1;
unsigned char* pline=(unsigned char*)(img->imageData);
for (int h=0;hheight;h++pline+=img->widthStep){
if (*(pline+w)>100){
isBlack=false;
whitePixelNum++;
if (t<0){
t=h;
b=h;
}else{
b=h;
}
}
}
if (isBlack){
break;
}
if (top>t){
top=t;
}
if (bottom bottom=b;
}

right=w;
}
widHeiRatio=(float)right/(bottom-top);
whitePixelRatio=(float)whitePixelNum/right/(bottom-top);

}
int main( int argc char** argv )
{
IplImage* pImg;
char strBuff[3][100];
fstream filefeature1(“feature-widthHeight.txt“ios::out);
fstream filefeature2(“feature-whiteRatio.txt“ios::out);
float widHeiRatio=0;
float whiteRatio=0;
for(int counter=0;counter<100;counter++){
sprintf(strBuff[0]“images-train/stone-%03d.bmp“counter);
sprintf(strBuff[1]“images-train/scissors-%03d.bmp“counter);
sprintf(strBuff[2]“images-train/cloth-%03d.bmp“counter);
for (int i=0;i<3;i++){
pImg=cvLoadImage(strBuff[i]CV_LOAD_IMAGE_GRAYSCALE);
if (pImg==NULL){
cout<<“error happened while loading image:“< cvWaitKey(0);
}
featrue(pImgwidHeiRatiowhiteRatio);
cvReleaseImage(&pImg);
filefeature1< filefeature2< cout< }
filefeature1< filefeature2<
}
filefeature1.close();
filefeature2.close();

return 0;
}

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2013-11-12 21:56  opencv实现的手势识别,石头剪刀布的实现\
     目录           0  2013-11-21 23:00  opencv实现的手势识别,石头剪刀布的实现\StoneScissorsCloth\
     目录           0  2013-11-21 22:48  opencv实现的手势识别,石头剪刀布的实现\StoneScissorsCloth\Release\
     文件       41068  2013-11-19 21:44  opencv实现的手势识别,石头剪刀布的实现\StoneScissorsCloth\Release\CL.read.1.tlog
     文件        1448  2013-11-19 21:44  opencv实现的手势识别,石头剪刀布的实现\StoneScissorsCloth\Release\CL.write.1.tlog
     文件       26624  2013-11-21 22:38  opencv实现的手势识别,石头剪刀布的实现\StoneScissorsCloth\Release\StoneScissorsCloth.exe
     文件         381  2013-11-21 22:38  opencv实现的手势识别,石头剪刀布的实现\StoneScissorsCloth\Release\StoneScissorsCloth.exe.intermediate.manifest
     文件         150  2013-11-21 22:48  opencv实现的手势识别,石头剪刀布的实现\StoneScissorsCloth\Release\StoneScissorsCloth.lastbuildstate
     文件        1218  2013-11-21 22:48  opencv实现的手势识别,石头剪刀布的实现\StoneScissorsCloth\Release\StoneScissorsCloth.log
     文件     1027072  2013-11-21 22:38  opencv实现的手势识别,石头剪刀布的实现\StoneScissorsCloth\Release\StoneScissorsCloth.pdb
     文件        1320  2013-11-19 15:36  opencv实现的手势识别,石头剪刀布的实现\StoneScissorsCloth\Release\StoneScissorsCloth.res
     文件     1745641  2013-11-19 21:44  opencv实现的手势识别,石头剪刀布的实现\StoneScissorsCloth\Release\StoneScissorsCloth_recognize.obj
     文件        1910  2013-11-19 21:44  opencv实现的手势识别,石头剪刀布的实现\StoneScissorsCloth\Release\cl.command.1.tlog
     文件           2  2013-11-21 22:38  opencv实现的手势识别,石头剪刀布的实现\StoneScissorsCloth\Release\link-cvtres.read.1.tlog
     文件           2  2013-11-21 22:38  opencv实现的手势识别,石头剪刀布的实现\StoneScissorsCloth\Release\link-cvtres.write.1.tlog
     文件        5674  2013-11-21 22:38  opencv实现的手势识别,石头剪刀布的实现\StoneScissorsCloth\Release\link.command.1.tlog
     文件        8166  2013-11-21 22:38  opencv实现的手势识别,石头剪刀布的实现\StoneScissorsCloth\Release\link.read.1.tlog
     文件        1236  2013-11-21 22:38  opencv实现的手势识别,石头剪刀布的实现\StoneScissorsCloth\Release\link.write.1.tlog
     文件         718  2013-11-21 22:38  opencv实现的手势识别,石头剪刀布的实现\StoneScissorsCloth\Release\mt.command.1.tlog
     文件        1632  2013-11-21 22:38  opencv实现的手势识别,石头剪刀布的实现\StoneScissorsCloth\Release\mt.read.1.tlog
     文件         516  2013-11-21 22:38  opencv实现的手势识别,石头剪刀布的实现\StoneScissorsCloth\Release\mt.write.1.tlog
     文件        1610  2013-11-19 15:36  opencv实现的手势识别,石头剪刀布的实现\StoneScissorsCloth\Release\rc.command.1.tlog
     文件        5576  2013-11-19 15:36  opencv实现的手势识别,石头剪刀布的实现\StoneScissorsCloth\Release\rc.read.1.tlog
     文件         934  2013-11-19 15:36  opencv实现的手势识别,石头剪刀布的实现\StoneScissorsCloth\Release\rc.write.1.tlog
     文件      765952  2013-11-19 21:44  opencv实现的手势识别,石头剪刀布的实现\StoneScissorsCloth\Release\vc100.pdb
     文件      823548  2010-10-10 08:22  opencv实现的手势识别,石头剪刀布的实现\StoneScissorsCloth\StoneScissorsCloth-images.zip
     文件       19532  2013-11-20 09:57  opencv实现的手势识别,石头剪刀布的实现\StoneScissorsCloth\StoneScissorsCloth.aps
     文件        1964  2010-10-08 21:19  opencv实现的手势识别,石头剪刀布的实现\StoneScissorsCloth\StoneScissorsCloth.rc
     文件    13979648  2013-11-21 23:01  opencv实现的手势识别,石头剪刀布的实现\StoneScissorsCloth\StoneScissorsCloth.sdf
     文件         902  2013-11-19 11:05  opencv实现的手势识别,石头剪刀布的实现\StoneScissorsCloth\StoneScissorsCloth.sln
     文件       30208  2013-11-21 23:00  opencv实现的手势识别,石头剪刀布的实现\StoneScissorsCloth\StoneScissorsCloth.suo
............此处省略30个文件信息

评论

共有 条评论