手势识别
Posted cv.exp
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了手势识别相关的知识,希望对你有一定的参考价值。
手势检测:
手势分割:
Selective search生成建议框
function [boxes blobIndIm blobBoxes hierarchy priority] = Image2HierarchicalGrouping(im, sigma, k, minSize, colourType, functionHandles)
% function [boxes blobIndIm blobBoxes hierarchy] = Image2HierarchicalGrouping
% (im, sigma, k, minSize, colourType, functionHandles)
%
% Creates hierarchical grouping from an image
%
% im: Image
% sigma (= 0.8): Smoothing for initial segmentation (Felzenszwalb 2004)
% k (= 100): Threshold for initial segmentation
% minSize (= 100): Minimum size of segments for initial segmentation
% colourType: ColourType in which to do grouping (see Image2ColourSpace)
% functionHandles: Similarity functions which are called. Function
% creates as many hierarchies as there are functionHandles
%
% boxes: N x 4 array with boxes of all hierarchical groupings
% blobIndIm: Index image with the initial segmentation
% blobBoxes: Boxes belonging to the indices in blobIndIm
% hierarchy: M x 1 cell array with hierarchies. M =
% length(functionHandles)
%
% Jasper Uijlings - 2013
% Change colour space
[colourIm imageToSegment] = Image2ColourSpace(im, colourType);
% Get initial segmentation, boxes, and neighbouring blobs
[blobIndIm blobBoxes neighbours] = mexFelzenSegmentIndex(imageToSegment, sigma, k, minSize);
numBlobs = size(blobBoxes,1);
% Skip hierarchical grouping if segmentation results in single region only
if numBlobs == 1
warning('Oversegmentation results in a single region only');
boxes = blobBoxes;
hierarchy = [];
priority = 1; % priority is legacy
return;
end
%%% Calculate histograms and sizes as prerequisite for grouping procedure
% Get colour histogram
[colourHist blobSizes] = BlobStructColourHist(blobIndIm, colourIm);
% Get texture histogram
textureHist = BlobStructTextureHist(blobIndIm, colourIm);
% textureHist = BlobStructTextureHistLBP(blobIndIm, colourIm);
% Allocate memory for complete hierarchy.
blobStruct.colourHist = zeros(size(colourHist,2), numBlobs * 2 - 1);
blobStruct.textureHist = zeros(size(textureHist,2), numBlobs * 2 - 1);
blobStruct.size = zeros(numBlobs * 2 -1, 1);
blobStruct.boxes = zeros(numBlobs * 2 - 1, 4);
% Insert calculated histograms, sizes, and boxes
blobStruct.colourHist(:,1:numBlobs) = colourHist';
blobStruct.textureHist(:,1:numBlobs) = textureHist';
blobStruct.size(1:numBlobs) = blobSizes ./ 3;
blobStruct.boxes(1:numBlobs,:) = blobBoxes;
blobStruct.imSize = size(im,1) * size(im,2);
%%% If you want to use original blobs in similarity functions, uncomment
%%% these lines.
% blobStruct.blobs = cell(numBlobs * 2 - 1, 1);
% initialBlobs = SegmentIndices2Blobs(blobIndIm, blobBoxes);
% blobStruct.blobs(1:numBlobs) = initialBlobs;
% Loop over all merging strategies. Perform them one by one.
boxes = cell(1, length(functionHandles)+1);
priority = cell(1, length(functionHandles) + 1);
hierarchy = cell(1, length(functionHandles));
for i=1:length(functionHandles)
[boxesi hierarchyi blobStructT mergeThreshold] = BlobStruct2HierarchicalGrouping(blobStruct, neighbours, numBlobs, functionHandlesi);
boxesi = boxesi(numBlobs+1:end,:);
priorityi = (size(boxesi, 1):-1:1)';
end
% Also save the initial boxes
i = i+1;
boxesi = blobBoxes;
priorityi = ones(size(boxesi, 1), 1) * (size(boxes1, 1)+1);
% Concatenate boxes and priorities resulting from the different merging
% strategies
boxes = cat(1, boxes:);
priority = cat(1, priority:);
[priority ids] = sort(priority, 'ascend');
boxes = boxes(ids,:);
手势识别:
深度学习与手势检测:
Optical Flow ConvNets(光流卷积网络):
http://blog.csdn.net/forest_world/article/details/53965567 行为识别研究摘录
部分参考源码:
#include "stdafx.h"
#include "cv.h"
#include "highgui.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include <math.h>
#include <float.h>
#include <limits.h>
#include <time.h>
#include <ctype.h>
#ifdef _EiC
#define WIN32
#endif
static CvMemStorage* storage = 0;
static CvHaarClassifierCascade* cascade = 0;
void detect_and_draw( IplImage* image );
const char* cascade_name;
int main( int argc, char** argv )
cascade_name = "palm.xml";
cascade = (CvHaarClassifierCascade*)cvLoad( cascade_name, 0, 0, 0 );
if( !cascade )
fprintf( stderr, "ERROR: Could not load classifier cascade\\n" );
return -1;
storage = cvCreateMemStorage(0);
cvNamedWindow( "result", 1 );
const char* filename = "step3.JPG";
IplImage* image = cvLoadImage( filename, 1 );
if( image )
detect_and_draw( image );
cvWaitKey(0);
cvReleaseImage( &image );
cvDestroyWindow("result");
return 0;
void detect_and_draw(IplImage* img )
double scale=1.2;
static CvScalar colors[] =
0,0,255,0,128,255,0,255,255,0,255,0,
255,128,0,255,255,0,255,0,0,255,0,255
;//Just some pretty colors to draw with
IplImage* gray = cvCreateImage(cvSize(img->width,img->height),8,1);
IplImage* small_img=cvCreateImage(cvSize(cvRound(img->width/scale),cvRound(img->height/scale)),8,1);
cvCvtColor(img,gray, CV_BGR2GRAY);
cvResize(gray, small_img, CV_INTER_LINEAR);
cvEqualizeHist(small_img,small_img); //直方图均衡
//Detect objects if any
cvClearMemStorage(storage);
double t = (double)cvGetTickCount();
CvSeq* objects = cvHaarDetectObjects(small_img,
cascade,
storage,
1.1,
2,
0/*CV_HAAR_DO_CANNY_PRUNING*/,
cvSize(30,30));
t = (double)cvGetTickCount() - t;
printf( "detection time = %gms\\n", t/((double)cvGetTickFrequency()*1000.) );
//Loop through found objects and draw boxes around them
for(int i=0;i<(objects? objects->total:0);++i)
CvRect* r=(CvRect*)cvGetSeqElem(objects,i);
cvRectangle(img, cvPoint(r->x*scale,r->y*scale), cvPoint((r->x+r->width)*scale,(r->y+r->height)*scale), colors[i%8]);
for( int i = 0; i < (objects? objects->total : 0); i++ )
CvRect* r = (CvRect*)cvGetSeqElem( objects, i );
CvPoint center;
int radius;
center.x = cvRound((r->x + r->width*0.5)*scale);
center.y = cvRound((r->y + r->height*0.5)*scale);
radius = cvRound((r->width + r->height)*0.25*scale);
cvCircle( img, center, radius, colors[i%8], 3, 8, 0 );
cvShowImage( "result", img );
cvReleaseImage(&gray);
cvReleaseImage(&small_img);
Hand segmentation with structured convolutional learning
肤色检测:
int isSkin(int R,int G,int B)
if(R>95&&G>40&&B>20&&R>G&&R>B&&
(MAX(R,G,B)-MIN(R,G,B)>15)&&abs(R-G)>15)
return 1;
else
return 0;
手势样本库下载
http://download.csdn.net/detail/forest_world/9666342
http://download.csdn.net/detail/forest_world/9666349
参考资料:
http://www.zhihu.com/question/20131478
http://www.cnblogs.com/CVArt/archive/2011/07/20/2111676.html 抗遮挡手势跟踪算法研究
http://blog.sina.com.cn/s/blog_5d3402010100s0tr.html camshift结合kalman预测对特定颜色的跟踪
http://blog.csdn.net/myarrow/article/details/51933651 [置顶] 手势估计- Hand Pose Estimation
以上是关于手势识别的主要内容,如果未能解决你的问题,请参考以下文章
基于YOLOv5的手势识别系统(含手势识别数据集+训练代码)
基于YOLOv5的手势识别系统(含手势识别数据集+训练代码)
Android手部检测和手势识别(含训练代码+Android源码+手势识别数据集)
Android手部检测和手势识别(含训练代码+Android源码+手势识别数据集)