anyuan9

基于PCA和SVM的人脸识别系统-error修改

-------------------------------------------------
Undefined function or variable \'W\'.
Error in classify (line 18)
xNewFace = xNewFace*W; % 经过pca变换降维
Error in GUIRecgFaceImage (line 3)
nClass = classify(filepath); 
Error while evaluating uicontrol Callback
-------------------------------------------------
xNewFace = xNewFace*W; % 经过pca变换降维
  classify.m函数的一句语句做修改,修改为
  xNewFace =  (xNewFace-meanVec)*V; % 经过pca变换降维


-------------------------------------------------
Error using svmclassify (line 53)
The first input should be a struct generated by SVMTRAIN.
Error in multiSVMClassify (line 29)
        classes = svmclassify(CASVMStruct{iIndex}{jIndex},TestFace);
Error in test (line 36)
classes = multiSVMClassify(TestFace);
Error while evaluating uicontrol Callback
-------------------------------------------------
在运行程序之前,必须运行pathtool设置路径,添加根路径下的exportLibSVM,Kernel,PCA,SVM几个文件夹。并且remove原来自己的libSVM。
matlab工具箱中svmtrain的用法

原来用的是libsvm的工具包,感觉很好用。
最近应为用到的核函数需要自己设定,所以转到了matlab的自带的svm函数。
目前用到的主要有两个:
svmtrain和svmclassify。
其中具体的参数可以参考help。
有几点应用的时候需要注意:
1.如果你原来安装过libsvm需要先卸载掉。
方法是:在command window中输入pathtool,在弹出的框中去掉libsvm的文件夹。
2.svmtrain的语法示例:
svmStruct = svmtrain(data(train,:),groups(train),\'showplot\',true,\'Kernel_Function\',‘rbf’ );
或:
svmStruct = svmtrain(data(train,:),groups(train),\'showplot\',true,\'Kernel_Function\',\'rbf\' ,\'RBF_Sigma\',1.5);
但是如果用的是自编的函数的话,则为:
svmStruct = svmtrain(data(train,:),groups(train),\'showplot\',true,\'Kernel_Function\',@kfun);
最后的参数为自己设计的核函数,函数名字是kfun,作为参数不加引号。

分类:

技术点:

相关文章:

  • 2022-12-23
  • 2021-08-25
  • 2021-06-21
  • 2021-10-16
  • 2021-07-09
  • 2021-06-08
  • 2021-10-16
  • 2021-10-19
猜你喜欢
  • 2021-12-10
  • 2021-11-30
  • 2021-11-30
  • 2021-08-01
相关资源
相似解决方案