Home > Back-end >  Can't locate the program input point @ FaceRecognizer @ face @ CV in dynamic linking. Exe
Can't locate the program input point @ FaceRecognizer @ face @ CV in dynamic linking. Exe

Time:10-18

//OpenCV3.4.1 _Test. CPP: defines the entry point of the console application,
//
# include "stdafx. H"
# include & lt; Opencv. Hpp>
# include & lt; Face. Hpp>
# include & lt; Iostream>
# include & lt; Face/facerec. Hpp>

using namespace cv;
Using the namespace CV: : face;
using namespace std;

Int main (int arg c, char * * argv) {
String filename=string (" H:/images/orl_faces/image. The CSV ");
Ifstream file (filename. C_str (), ifstream: : in);

if (! The file) {
Printf (" could not load the file correctly... \n");
return -1;
}
The string line, path, classlabel;
Vector Images;
Vector Labels.
Char separator='; ';

While (getline (file, line)) {
Stringstream liness (line);
Getline (liness, path, the separator);
Getline (liness, classlabel);
if (! Path. The empty () & amp; & ! Classlabel. Empty ()) {
Path://printf (" % s \ n ", path. The c_str ());
Images. The push_back (imread (path, 0));
Labels. The push_back (atoi (classlabel c_str ()));
}
}

If (images. The size () & lt; 1 | | labels. The size () & lt; 1) {
Printf (" invalid image path... \n");
return -1;
}

Int height=images [0]. Rows;
Int width=images [0]. Cols;
Height: printf (" % d, width: % d \ n ", height, width);

Mat testSample=images [images. The size () - 1);
Int testLabel=labels [labels. The size () - 1);
Images. Pop_back ();
Labels. Pop_back ();

//train it
Ptr The model=EigenFaceRecognizer: : create ();
The model - & gt; "Train" (images, labels);

//recognition face
Int predictedLabel=model - & gt; Predict (the testSample);
Printf (" actual label: % d, predict the label: % d \ n ", testLabel, predictedLabel);

Mat eigenvalues=model - & gt; GetEigenValues ();
Mat W=model - & gt; GetEigenVectors ();
Mat mean=model - & gt; GetMean ();
Mat meanFace=mean. Reshape (1, height);
Mat DST.
If (meanFace channels ()==1) {
The normalize (meanFace, DST, 0, 255, NORM_MINMAX, CV_8UC1);
}
Else if (meanFace channels ()==3) {
The normalize (meanFace, DST, 0, 255, NORM_MINMAX, CV_8UC3);
}
Imshow (Mean "Face", DST);








waitKey(0);
getchar();
return 0;
}














  • Related