資源簡介
一個實現石頭剪刀布的小程序,基于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\li
?????文件???????????2??2013-11-21?22:38??opencv實現的手勢識別,石頭剪刀布的實現\StoneScissorsCloth\Release\li
?????文件????????5674??2013-11-21?22:38??opencv實現的手勢識別,石頭剪刀布的實現\StoneScissorsCloth\Release\li
?????文件????????8166??2013-11-21?22:38??opencv實現的手勢識別,石頭剪刀布的實現\StoneScissorsCloth\Release\li
?????文件????????1236??2013-11-21?22:38??opencv實現的手勢識別,石頭剪刀布的實現\StoneScissorsCloth\Release\li
?????文件?????????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個文件信息
評論
共有 條評論