Ask Your Question

nolan's profile - activity

2019-03-10 09:22:58 -0600 received badge  Popular Question (source)
2016-06-12 15:24:58 -0600 commented answer error LNK2019: unresolved external symbol "class cv::Mat __cdecl result(void)"

Thank you very much, it didn't work for Mat result; but worked in this format float result=0;

2016-06-12 15:23:59 -0600 received badge  Scholar (source)
2016-06-11 11:31:14 -0600 commented answer error LNK2019: unresolved external symbol "class cv::Mat __cdecl result(void)"

there is Mat result(); only, and i will add the whole Classifier.cpp code

2016-06-11 01:41:50 -0600 commented question error LNK2019: unresolved external symbol "class cv::Mat __cdecl result(void)"

yes it is the first time, how can i alter it?

2016-06-11 01:30:33 -0600 commented answer error LNK2019: unresolved external symbol "class cv::Mat __cdecl result(void)"

yes this is Classifier.h, and there is a Classifier.cpp file. Both are in the project.

2016-06-11 01:04:52 -0600 received badge  Editor (source)
2016-06-11 00:51:34 -0600 asked a question error LNK2019: unresolved external symbol "class cv::Mat __cdecl result(void)"

i am trying to make this code work, but i cannot solve that error

Error 1 error LNK2019: unresolved external symbol "class cv::Mat __cdecl result(void)" (?result@@YA?AVMat@cv@@XZ) referenced in function "public: void __cdecl Classifier::TestData(float * *,int,int)" (?TestData@Classifier@@QEAAXPEAPEAMHH@Z)

i am linking libraries by name from the directory i included, in both debug (xxxd) and release (xxx).

OpenCV2.4.13 and visual studio 2013, i tried to use OpenCV3.1 but i couldn't change the SVM syntax because it is changed in the 3.1 version

  #ifndef CLASSIFIER_H
  #define   CLASSIFIER_H

  #include <cstdlib>
#include <vector>
#include <iostream>
#include <math.h>
#include <opencv2/ml/ml.hpp>

 using namespace std;
using namespace cv;

 class Classifier {
 public:
 Classifier();
void Normalize(float **data_mat, int row, int col);
void TrainSVMClassifier(float **training_data, float* labels, int row, int col);
void TrainClassifier(float **training_data, int row, int col);
void TestData(float **testing_data, int row, int col);
void ClassifyData(float** testing_data, int row, int col);
void normalizeFV(float **data_mat, int row, int col);
virtual ~Classifier();
  private:
CvSVMParams params;
CvSVM SVM;
float *ref_mean;
float *ref_std_deviation;
float *calculateMean(float** data_mat, int row, int col);
float *calculateStdDeviation(float **data_mat, int row, int col, float *mean);
 };

 #endif /* CLASSIFIER_H */

Classifier.cpp

  #include "Classifier.h"

   Classifier::Classifier() {
   //Setting up SVM's parameters
    params.svm_type = CvSVM::C_SVC;
   params.kernel_type = CvSVM::LINEAR;
   params.gamma = 20;

    params.term_crit.type = CV_TERMCRIT_ITER | CV_TERMCRIT_EPS;
    params.term_crit.max_iter = 1000;
    params.term_crit.epsilon = 1e-6;

     }

      float *Classifier::calculateStdDeviation(float **data_mat, int row, int col, float *mean) {
      float *std_deviation = (float *)calloc(col,sizeof(float));

       for(int i=0;i<row;i++){
       for(int j=0;j<col;j++){
         std_deviation[j] = std_deviation[j] + pow(data_mat[i][j]-mean[j],2);
      }
   }

   for(int j=0; j<col;j++){
      std_deviation[j] = sqrt(std_deviation[j]/row);
   }
     return std_deviation;
    }

    float *Classifier::calculateMean(float** data_mat, int row, int col) {
     float *mean = (float *)calloc(col, sizeof(float));

      for (int i = 0; i < row; i++) {
           for (int j = 0; j < col; j++) {
               mean[j] = mean[j] + data_mat[i][j];
          }
         }
       for (int j=0; j < col; j++) {
         mean[j] = mean[j] / row;
        }
       return mean;
        }

         void displayVector(float *v, int n){
                for(int i=0; i<n; i++){
                   cout<<v[i]<<" ";
               }
                  }

               void Classifier::normalizeFV(float **data_mat, int row, int col){
                for(int i=0;i<row;i++){
               float mean =0;
                 float std_deviation = 0;
                for(int j=0;j<col;j++){
                  mean += data_mat[i][j];
                 }
                  mean /= col;
                 for(int j=0;j<col;j++){
               std_deviation = std_deviation + pow(data_mat[i][j]-mean,2);
                }
                std_deviation /= col-1;
               for(int j=0;j<col;j++){
                    data_mat[i][j] = (data_mat[i][j]-mean)/std_deviation;
               }
                 }
              }

           void Classifier::Normalize(float** data_mat, int row, int col) {
        float *mean;
           float *std_deviation;
        mean = calculateMean(data_mat, row, col);
         std_deviation = calculateStdDeviation(data_mat, row, col, mean);
          for(int i=0;i<row;i++){
             for(int j=0; j<col;j++){
          data_mat[i][j] = (data_mat[i][j]-mean[j])/std_deviation[j];
             }
           }
        }

         void Classifier::TrainClassifier(float** training_data, int row, int col){
          ref_mean = calculateMean(training_data, row, col);
          ref_std_deviation = calculateStdDeviation(training_data, row, col, ref_mean ...
(more)