Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/opencv/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
支持向量机的链接器错误OpenCV_Opencv_Linker_Svm - Fatal编程技术网

支持向量机的链接器错误OpenCV

支持向量机的链接器错误OpenCV,opencv,linker,svm,Opencv,Linker,Svm,我的代码中似乎有链接器问题 代码是: #include <stdio.h> #include <stdlib.h> #include <string.h> #include <assert.h> #include <math.h> #include <float.h> #include <limits.h> #include <time.h> #include <ctype.h> #inc

我的代码中似乎有链接器问题

代码是:

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include <math.h>
#include <float.h>
#include <limits.h>
#include <time.h>
#include <ctype.h>
#include <iostream>
#include <vector>

#include "opencv/ml.h"
#include "opencv/cvaux.h"
#include "opencv/highgui.h"
#include "opencv/cxcore.h"
#include "opencv/cv.h"
#include "opencv/highgui.h"

using namespace cv;
int main (int argc, char* argv[])
{
// Data for visual representation
    int width = 512, height = 512;
    Mat image = Mat::zeros(height, width, CV_8UC3);

    // Set up training data
    float labels[4] = {1.0, -1.0, -1.0, -1.0};
    Mat labelsMat(3, 1, CV_32FC1, labels);

    float trainingData[4][2] = { {501, 10}, {255, 10}, {501, 255}, {10, 501} };
    Mat trainingDataMat(3, 2, CV_32FC1, trainingData);

    // Set up SVM's parameters
    CvSVMParams params;
    params.svm_type    = CvSVM::C_SVC;
    params.kernel_type = CvSVM::LINEAR;
    params.term_crit   = cvTermCriteria(CV_TERMCRIT_ITER, 100, 1e-6);

    // Train the SVM
    CvSVM SVM;
    SVM.train(trainingDataMat, labelsMat, Mat(), Mat(), params);

    Vec3b green(0,255,0), blue (255,0,0);
    // Show the decision regions given by the SVM
    for (int i = 0; i < image.rows; ++i)
        for (int j = 0; j < image.cols; ++j)
        {
            Mat sampleMat = (Mat_<float>(1,2) << i,j);
            float response = SVM.predict(sampleMat);

            if (response == 1)
                image.at<Vec3b>(j, i)  = green;
            else if (response == -1) 
                 image.at<Vec3b>(j, i)  = blue;
        }

    // Show the training data
    int thickness = -1;
    int lineType = 8;
    circle( image, Point(501,  10), 5, Scalar(  0,   0,   0), thickness, lineType);
    circle( image, Point(255,  10), 5, Scalar(255, 255, 255), thickness, lineType);
    circle( image, Point(501, 255), 5, Scalar(255, 255, 255), thickness, lineType);
    circle( image, Point( 10, 501), 5, Scalar(255, 255, 255), thickness, lineType);

    // Show support vectors
    thickness = 2;
    lineType  = 8;
    int c     = SVM.get_support_vector_count();

    for (int i = 0; i < c; ++i)
    {
        const float* v = SVM.get_support_vector(i);
        circle( image,  Point( (int) v[0], (int) v[1]),   6,  Scalar(128, 128, 128), thickness, lineType);
    }

    imwrite("result.png", image);        // save the image 

    imshow("SVM Simple Example", image); // show it to the user
    waitKey(0);
return EXIT_SUCCESS;
}
#包括
#包括
#包括
#包括。我的编译器是VC++

我已经搜索过谷歌了,但我没有发现任何有用的东西


感谢那些有同样问题的人,确保你有所有正确的链接器输入(配置->链接器->输入),包括DLL,如opencv、highgui等。

对于那些有同样问题的人,确保你有所有正确的链接器输入(配置->链接器->输入),包括DLL,如opencv,highgui等。

对于那些想要一些输入列表的人:

opencv_core412.lib
opencv_imgcodecs412.lib
opencv_imgproc412.lib
opencv_highgui412.lib
opencv_ml412.lib
opencv_video412.lib
opencv_features2d412.lib
opencv_calib3d412.lib
opencv_objdetect412.lib
opencv_flann412.lib

412是版本,在本例中,由于它处于发布模式,因此在最后没有d,否则对于那些想要一些输入列表的人来说,它将是
opencv\u flann412d.lib

opencv_core412.lib
opencv_imgcodecs412.lib
opencv_imgproc412.lib
opencv_highgui412.lib
opencv_ml412.lib
opencv_video412.lib
opencv_features2d412.lib
opencv_calib3d412.lib
opencv_objdetect412.lib
opencv_flann412.lib
412就是这个版本,在本例中,由于它处于发布模式,所以在最后没有d,否则它将是
opencv\u flann412d.lib