Ask Your Question

KBregnhoved's profile - activity

2016-11-15 10:46:30 -0500 received badge  Notable Question (source)
2015-07-09 23:06:33 -0500 received badge  Popular Question (source)
2012-12-03 06:52:06 -0500 asked a question Eigenfaces face recognizer gives error: unresolved external symbols

Hej - I'm having probems with making the Eigenface-part of this turtorial: http://docs.opencv.org/modules/contrib/doc/facerec/facerec_tutorial.html#eigenfaces

When I try to run it I get these errors:

1>main.obj : error LNK2019: unresolved external symbol "class cv::Mat __cdecl cv::subspaceReconstruct(class cv::_InputArray const &,class cv::_InputArray const &,class cv::_InputArray const &)" (?subspaceReconstruct@cv@@YA?AVMat@1@ABV_InputArray@1@00@Z) referenced in function __catch$_main$0 1>main.obj : error LNK2019: unresolved external symbol "class cv::Mat __cdecl cv::subspaceProject(class cv::_InputArray const &,class cv::_InputArray const &,class cv::_InputArray const &)" (?subspaceProject@cv@@YA?AVMat@1@ABV_InputArray@1@00@Z) referenced in function __catch$_main$0 1>main.obj : error LNK2019: unresolved external symbol "void __cdecl cv::applyColorMap(class cv::_InputArray const &,class cv::_OutputArray const &,int)" (?applyColorMap@cv@@YAXABV_InputArray@1@ABV_OutputArray@1@H@Z) referenced in function __catch$_main$0 1>main.obj : error LNK2019: unresolved external symbol "class cv::Ptr<class cv::facerecognizer=""> __cdecl cv::createEigenFaceRecognizer(int,double)" (?createEigenFaceRecognizer@cv@@YA?AV?$Ptr@VFaceRecognizer@cv@@@1@HN@Z) referenced in function __catch$_main$0

Is there someone who can help me with this? I cannot figure out what I'm doing wrong...

The actual code look like this:

#include "opencv2/core/core.hpp"
#include "opencv2/contrib/contrib.hpp"
#include "opencv2/highgui/highgui.hpp"
#include <iostream>
#include <fstream>
using namespace cv;
using namespace std;    
// Function, which creates a normalized image

static Mat norm_0_255(InputArray _src) {
    Mat src = _src.getMat();
    // Create and return normalized image:
    Mat dst;
    switch(src.channels()) {
    case 1:
    cv::normalize(_src, dst, 0, 255, NORM_MINMAX, CV_8UC1);
    break;
case 3:
    cv::normalize(_src, dst, 0, 255, NORM_MINMAX, CV_8UC3);
    break;
default:
    src.copyTo(dst);
    break;
}
return dst;
}        

// Reads the csv-file in, which includes the images from the image-database:        


static void read_csv(const string& filename, vector<Mat>& images, vector<int>& labels, char separator = ';') {
//
std::ifstream file(filename.c_str(), ifstream::in);
// If there is no file, then it comes out with an error message:
if (!file) {
    string error_message = "No valid input file was given, please check the given filename.";
    CV_Error(CV_StsBadArg, error_message);
}
string line, path, classlabel;
// As long as there is lines in the file, the program takes in the next line in the csv-file:
while (getline(file, line)) {
    stringstream liness(line);
    getline(liness, path, separator);
    getline(liness, classlabel);
    // If there is no more lines:
    if(!path.empty() && !classlabel.empty()) {
        images.push_back(imread(path, 0));
        labels.push_back(atoi(classlabel.c_str()));
    }
}
 }        


int main(int argc, const char *argv[]) {
// Check for valid command line arguments, print usage
// if no arguments were given.
if (argc < 2) {
    //cout this and exit the program
    cout << "usage: " << argv[0] << " <csv.ext> <output_folder> " << endl;
    exit(1);
}
string output_folder;
// if there are 3 arguments given:
if (argc == 3) {
    output_folder = string(argv[2]);
   }        


// Get the path to the CSV-file.
string fn_csv = string(argv[1]); //"...\attFaceDatabaseText.csv"; 

// These vectors hold the images and corresponding labels.
vector<Mat> images;
vector<int> labels;

// Read in the data. This can fail if no valid ...
(more)