0
点赞
收藏
分享

微信扫一扫

【手势识别】基于 PCA+LDA实现手势检测识别含Matlab源码

八卦城的酒 2022-03-12 阅读 90

1 简介

手势识别算法在人工智能方向逐渐成为热点,在人机交互领域具有很大的研究意义.本文通过使用主成分分析和支持向量机算法,先利用主成分分析算法对手势图片进行降维处理,再通过支持向量机算法分类识别.通过Matlab对算法进行仿真实验,结果表明该方法具有一定的应用价值.​

2 部分代码

% Sign Language Detectionclc;clear all;close all;%% Add training and test directories to pathaddpath('./Training/A');addpath('./Training/B');addpath('./Training/C');addpath('./Training/Five');addpath('./Training/Point');addpath('./Training/V');addpath('./Testing/A');addpath('./Testing/B');addpath('./Testing/C');addpath('./Testing/Five');addpath('./Testing/Point');addpath('./Testing/V');%% Input ImageSymbol = input('Enter the symbol you want to test for (A,B,C,Five,Point,V)-','s');Num = input('Enter the no of the image you want to test for(1-435)-');InputImage = strcat(Symbol,'-train',num2str(Num),'.jpg');%Read input imageimg1 = imread(InputImage);%% Define variablescAlpha = [{'A'},{'B'},{'C'},{'Five'},{'Point'},{'V'}];%No of alphabet usednTrainingSamples = 1;%No of training Images we are using.nRows = 76;%No of rows for the imagesnColumns = 66;%No of columns for the imagesImgMat = zeros(nRows*nColumns,size(cAlpha,2)*nTrainingSamples);%Initialize image matrixShowOutput = 0;%Keyword to display images, 1-display 2-suppress displayif (nTrainingSamples ~= 1)    ShowOutput = 0;%No output if no of samples > 1endnEigValThres = 0.0001;%Threshold below which to ignore eigen vectorsthreshold = -2;%Threshold for skin detection%% Perform preprocessing of Training imagesll = 1;for ii = 1:size(cAlpha,2)    for jj = 1:nTrainingSamples         sFilename = strcat(cAlpha(ii),'-test',int2str(jj),'.jpg');%Form filename         ColorImg = imread(char(sFilename));%RGB 24 bit image        FinalImg = preprocessing(ColorImg,nRows,nColumns,threshold,0);%Find skin thresholded regions                ImgMat(:,ll) = FinalImg;%Store image as column matrix in ImgMat        ll = ll + 1;%Move on to next column    endend%% Train image[PCAfeatures omega] = PCATraining(ImgMat,nRows,nColumns,ShowOutput,nEigValThres);[V_Fisher ProjectedImages_Fisher] = ASLfisher(ImgMat,PCAfeatures,nRows,nColumns,omega,size(cAlpha,2),nTrainingSamples,ShowOutput);%% Perform preprocessing of input imageProcImg = preprocessing(img1,nRows,nColumns,threshold,ShowOutput);InImWeight = PCAget(ProcImg,PCAfeatures);InImWeight2 = Fisherget(ProcImg,PCAfeatures,V_Fisher);%% Perform KNN and SVM classificationClass = ASlknn(cAlpha,nTrainingSamples,InImWeight,omega);Ind = ASLsvm(cAlpha,nTrainingSamples,InImWeight,omega);Class2 = ASlknn(cAlpha,nTrainingSamples,InImWeight2',ProjectedImages_Fisher);Ind2 = ASLsvm(cAlpha,nTrainingSamples,InImWeight2',ProjectedImages_Fisher);%% Display Input and Matched Outputf = figure();set(gca, 'fontsize', 28);            set(f,'name','KNN')subplot (1,3,1)imshow(img1); title('Input image','fontsize', 20)subplot (1,3,2)RecongImg = strcat(cAlpha(Class),'-test1.jpg');imshow(char(RecongImg)); title(strcat('Recognized Letter using PCA-',cAlpha(Class)),'fontsize',20);subplot (1,3,3)RecongImg = strcat(cAlpha(Class2),'-test1.jpg');imshow(char(RecongImg)); title(strcat('Recognized Letter using FLD-',cAlpha(Class2)),'fontsize',20);f = figure();set(gca, 'fontsize', 28);            set(f,'name','SVM')subplot (1,3,1)imshow(img1);title('Input image','fontsize', 20)subplot (1,3,2)RecongImg = strcat(cAlpha(Ind),'-test1.jpg');imshow(char(RecongImg)); title(strcat('Recognized Letter using PCA-',cAlpha(Ind)),'fontsize', 20);subplot (1,3,3)RecongImg = strcat(cAlpha(Ind2),'-test1.jpg');imshow(char(RecongImg)); title(strcat('Recognized Letter using FLD-',cAlpha(Ind2)),'fontsize', 20);

3 仿真结果

4 参考文献

[1]孙鹏. 基于pca+svm算法实现手势识别[J]. 中国新通信, 2019(7):1.

博主简介:擅长智能优化算法、神经网络预测、信号处理、元胞自动机、图像处理、路径规划、无人机等多种领域的Matlab仿真,相关matlab代码问题可私信交流。

部分理论引用网络文献,若有侵权联系博主删除。

举报

相关推荐

0 条评论