-
大小: 9.75MB文件類型: .zip金幣: 2下載: 0 次發(fā)布日期: 2024-01-24
- 語(yǔ)言: Python
- 標(biāo)簽: 手勢(shì)識(shí)別??
資源簡(jiǎn)介
包含手勢(shì)識(shí)別(拳頭)的python代碼和cpp代碼以及最重要的訓(xùn)練好的xml文件

代碼片段和文件信息
//
//??main.cpp
//??handDetection
//
//??Created?by?劉鵬?on?2016/11/27.
//??Copyright???2016年?劉鵬.?All?rights?reserved.
//
#include?
#include?
#include?
#include?
using?namespace?std;
using?namespace?cv;
//?Global?variables
//?Copy?this?file?from?opencv/data/haarscascades?to?target?folder
string?face_cascade_name?=?“/Users/liupeng/Desktop/my/handDetection/handDetection/hand.xml“;
CascadeClassifier?*face_cascade;
string?window_name?=?“Capture?-?Face?detection“;
int?filenumber;?//?Number?of?file?to?be?saved
string?filename;
//?Function?Headers
class?faceDetection
{
private:
????std::vector?faces;
public:
????faceDetection();
????~faceDetection();
????void?detectAndDisplay(Mat?frame);
};
faceDetection::faceDetection()
{
}
faceDetection::~faceDetection()
{
}
//?Function?detectAndDisplay
void?faceDetection::detectAndDisplay(Mat?frame)
{
????//?報(bào)錯(cuò)問(wèn)題所在,。
????//?std::vector?faces;
????
????Mat?frame_gray;
????Mat?crop;
????Mat?res;
????Mat?gray;
????string?text;
????stringstream?sstm;
????
????cvtColor(frame?frame_gray?COLOR_BGR2GRAY);
????equalizeHist(frame_gray?frame_gray);
????
????//?Detect?faces
????face_cascade->detectMultiScale(frame_gray?faces?1.1?2?0?|?CASCADE_SCALE_IMAGE?Size(30?30));
????
????//?Set?Region?of?Interest
????cv::Rect?roi_b;
????cv::Rect?roi_c;
????
????size_t?ic?=?0;?//?ic?is?index?of?current?element
????int?ac?=?0;?//?ac?is?area?of?current?element
????
????size_t?ib?=?0;?//?ib?is?index?of?biggest?element
????int?ab?=?0;?//?ab?is?area?of?biggest?element
????
????for?(ic?=?0;?ic?????????
????{
????????roi_c.x?=?faces[ic].x;
????????roi_c.y?=?faces[ic].y;
????????roi_c.width?=?(faces[ic].width);
????????roi_c.height?=?(faces[ic].height);
????????
????????ac?=?roi_c.width?*?roi_c.height;?//?Get?the?area?of?current?element?(detected?face)
????????
????????roi_b.x?=?faces[ib].x;
????????roi_b.y?=?faces[ib].y;
????????roi_b.width?=?(faces[ib].width);
????????roi_b.height?=?(faces[ib].height);
????????
????????ab?=?roi_b.width?*?roi_b.height;?//?Get?the?area?of?biggest?element?at?beginning?it?is?same?as?“current“?element
????????
????????if?(ac?>?ab)
????????{
????????????ib?=?ic;
????????????roi_b.x?=?faces[ib].x;
????????????roi_b.y?=?faces[ib].y;
????????????roi_b.width?=?(faces[ib].width);
????????????roi_b.height?=?(faces[ib].height);
????????}
????????
????????crop?=?frame(roi_b);
????????resize(crop?res?Size(128?128)?0?0?INTER_LINEAR);?//?This?will?be?needed?later?while?saving?images
????????cvtColor(crop?gray?CV_BGR2GRAY);?//?Convert?cropped?image?to?Grayscale
????????
????????//?Form?a?filename
????????filename?=?““;
????????stringstream?ssfn;
????????ssfn?<????????filename?=?ssfn.str();
????????filenumber++;
????????
????????//?imwrite(filename?gray);
????????
????????Point?pt1(faces[ic].x?faces[ic].y);?//?Disp
?屬性????????????大小?????日期????時(shí)間???名稱
-----------?---------??----------?-----??----
?????目錄???????????0??2017-07-17?22:31??手勢(shì)識(shí)別(拳頭)\
?????目錄???????????0??2017-07-17?22:22??手勢(shì)識(shí)別(拳頭)\__MACOSX\
?????文件?????????263??2016-11-27?14:53??手勢(shì)識(shí)別(拳頭)\__MACOSX\._hand.mp4
?????文件?????????175??2011-11-29?14:19??手勢(shì)識(shí)別(拳頭)\__MACOSX\._hand.xm
?????文件?????????504??2016-11-27?14:55??手勢(shì)識(shí)別(拳頭)\__MACOSX\._main.cpp
?????文件????10261034??2016-11-27?14:53??手勢(shì)識(shí)別(拳頭)\hand.mp4
?????文件???????72462??2011-11-29?14:19??手勢(shì)識(shí)別(拳頭)\hand.xm
?????文件????????4643??2016-11-27?14:55??手勢(shì)識(shí)別(拳頭)\main.cpp
?????文件?????????825??2017-07-17?22:31??手勢(shì)識(shí)別(拳頭)\video_demo.py
?????文件?????????824??2017-07-17?22:29??手勢(shì)識(shí)別(拳頭)\video_demo.py~
評(píng)論
共有 條評(píng)論