I am trying just a basic face recognition program with OpenCV2.4 with the following code:
#include "stdafx.h"
#include <iostream>
#include <string>
//include opencv core
#include "opencv2\core\core.hpp"
#include "opencv2\contrib\contrib.hpp"
#include "opencv2\highgui\highgui.hpp"
#include "opencv2\objdetect\objdetect.hpp"
#include "opencv2\opencv.hpp"
//file handling
#include <fstream>
#include <sstream>
using namespace std;
using namespace cv;
static void dbread(const string& filename, vector<Mat>& images, vector<int>& labels, char separator = ';'){
std::ifstream file(filename.c_str(), ifstream::in);
if (!file){
string error = "no valid input file";
CV_Error(CV_StsBadArg, error);
}
string line, path, label;
while (getline(file, line))
{
stringstream liness(line);
getline(liness, path, separator);
getline(liness, label);
if (!path.empty() && !label.empty()){
images.push_back(imread(path, 0));
labels.push_back(atoi(label.c_str()));
}
}
}
void fisherFaceTrainer(){
/*in this two vector we put the images and labes for training*/
vector<Mat> images;
vector<int> labels;
try{
string filename = "mycsv.txt";
dbread(filename, images, labels);
cout << "size of the images is " << images.size() << endl;
cout << "size of the labes is " << labels.size() << endl;
cout << "Training begins...." << endl;
}
catch (cv::Exception& e){
cerr << " Error opening the file " << e.msg << endl;
exit(1);
}
Ptr<FaceRecognizer> model = createFisherFaceRecognizer();
model->train(images, labels);
int height = images[0].rows;
model->save("fisherface.yml");
cout << "Training finished...." << endl;
}
int _tmain(int argc, _TCHAR* argv[])
{
fisherFaceTrainer();
//int value = FaceRecognition();
return 0;
}
When I run this, I get this error(no-symbols-loaded-for-opencv_contrib2410):
*Right click on image>>open image in new tab>>to check the bigger size
Thanks for helping