-
大小: 1.53MB文件類(lèi)型: .rar金幣: 2下載: 1 次發(fā)布日期: 2023-11-21
- 語(yǔ)言: 其他
- 標(biāo)簽: OpenNI??kinect??手勢(shì)識(shí)別??
資源簡(jiǎn)介
因?yàn)镺penNI可以獲取到kinect的深度信息,而深度信息在手勢(shì)識(shí)別中有很大用處,因此本文就來(lái)使用OpenNI自帶的類(lèi)來(lái)做簡(jiǎn)單的手勢(shì)識(shí)別。識(shí)別的動(dòng)作為4種,揮手,手移動(dòng),舉手,往前推手。通過(guò)后面的實(shí)驗(yàn)可以發(fā)現(xiàn),其實(shí)提供的類(lèi)的效果非常不好。
開(kāi)發(fā)環(huán)境:QtCreator2.5.1+OpenNI1.5.4.0+Qt4.8.2+OpenCV2.4.2

代碼片段和文件信息
#include?
#include?
#include?
using?namespace?xn;
using?namespace?std;
class?COpenNI
{
public:
????~COpenNI()?{
????????context.Release();//釋放空間
????}
????bool?Initial()?{
????????//初始化
????????status?=?context.Init();
????????if(CheckError(“Context?initial?failed!“))?{
????????????return?false;
????????}
????????context.SetGlobalMirror(true);//設(shè)置鏡像
????????//產(chǎn)生圖片node
????????status?=?image_generator.Create(context);
????????if(CheckError(“Create?image?generator??error!“))?{
????????????return?false;
????????}
????????//產(chǎn)生深度node
????????status?=?depth_generator.Create(context);
????????if(CheckError(“Create?depth?generator??error!“))?{
????????????return?false;
????????}
????????//視角校正
????????status?=?depth_generator.GetAlternativeViewPointCap().SetViewPoint(image_generator);
????????if(CheckError(“Can‘t?set?the?alternative?view?point?on?depth?generator!“))?{
????????????return?false;
????????}
????????status?=?gesture_generator.Create(context);
????????if(CheckError(“Create?gesture?generator?error!“))?{
????????????return?false;
????????}
????????/*添加手勢(shì)識(shí)別的種類(lèi)*/
????????gesture_generator.AddGesture(“Wave“?NULL);
????????gesture_generator.AddGesture(“click“?NULL);
????????gesture_generator.AddGesture(“RaiseHand“?NULL);
????????gesture_generator.AddGesture(“MovingHand“?NULL);
????????return?true;
????}
????bool?Start()?{
????????status?=?context.StartGeneratingAll();
????????if(CheckError(“Start?generating?error!“))?{
????????????return?false;
????????}
????????return?true;
????}
????bool?UpdateData()?{
????????status?=?context.WaitNoneUpdateAll();
????????if(CheckError(“Update?date?error!“))?{
????????????return?false;
????????}
????????//獲取數(shù)據(jù)
????????image_generator.GetmetaData(image_metadata);
????????depth_generator.GetmetaData(depth_metadata);
????????return?true;
????}
public:
????DepthmetaData?depth_metadata;
????ImagemetaData?image_metadata;
????GestureGenerator?gesture_generator;//外部要對(duì)其進(jìn)行回調(diào)函數(shù)的設(shè)置,因此將它設(shè)為public類(lèi)型
private:
????//該函數(shù)返回真代表出現(xiàn)了錯(cuò)誤,返回假代表正確
????bool?CheckError(const?char*?error)?{
????????if(status?!=?XN_STATUS_OK?)?{
????????????QMessageBox::critical(NULL?error?xnGetStatusString(status));
????????????cerr?<????????????return?true;
????????}
????????return?false;
????}
private:
????XnStatus????status;
????Context?????context;
????DepthGenerator??depth_generator;
????ImageGenerator??image_generator;
};
?屬性????????????大小?????日期????時(shí)間???名稱(chēng)
-----------?---------??----------?-----??----
?????文件?????351744??2012-10-02?08:41??Kinect+OpenNI學(xué)習(xí)筆記之5(使用OpenNI自帶的類(lèi)進(jìn)行簡(jiǎn)單手勢(shì)識(shí)別).pdf
?????文件???????2640??2012-10-01?22:28??hand_detect\copenni.cpp
?????文件??????62464??2012-10-02?00:33??hand_detect\debug\hand_detect.exe
?????文件?????526156??2012-10-02?00:33??hand_detect\debug\hand_detect.ilk
?????文件????????638??2012-10-02?00:33??hand_detect\debug\hand_detect.intermediate.manifest
?????文件????2550784??2012-10-02?00:33??hand_detect\debug\hand_detect.pdb
?????文件?????310706??2012-10-02?00:33??hand_detect\debug\main.obj
?????文件????????992??2012-10-01?22:31??hand_detect\hand_detect.pro
?????文件??????17553??2012-10-02?08:41??hand_detect\hand_detect.pro.user
?????文件???????2548??2012-10-02?00:33??hand_detect\main.cpp
?????文件???????7059??2012-10-01?22:31??hand_detect\Makefile
?????文件???????6176??2012-10-01?22:31??hand_detect\Makefile.Debug
?????文件???????6166??2012-10-01?22:31??hand_detect\Makefile.Release
?????文件????2174976??2012-10-02?00:33??hand_detect\vc100.pdb
?????目錄??????????0??2012-10-02?08:42??hand_detect\debug
?????目錄??????????0??2012-10-02?08:42??hand_detect\release
?????目錄??????????0??2012-10-02?08:42??hand_detect
-----------?---------??----------?-----??----
??????????????6020602????????????????????17
評(píng)論
共有 條評(píng)論