Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/visual-studio-2012/2.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/cmake/2.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/heroku/2.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
Visual studio 2012 如何解决错误LNK2019:imwrite()函数的未解析外部符号?_Visual Studio 2012_Cmake_Opencv3.0 - Fatal编程技术网

Visual studio 2012 如何解决错误LNK2019:imwrite()函数的未解析外部符号?

Visual studio 2012 如何解决错误LNK2019:imwrite()函数的未解析外部符号?,visual-studio-2012,cmake,opencv3.0,Visual Studio 2012,Cmake,Opencv3.0,我在c://../opencv 3.0和ms visual studio 2012上安装(提取)了opencv。我使用cmake创建库。cmake->c:/opencv/build custom/中生成二进制文件的路径,与opencv路径不同。我在cmake中选择visual studio 11 2012。 还要设置环境路径。 在property manager中,我设置c/c++>general>AdditionalIncludeDirectories: C:\lazy\opencv\buil

我在c://../opencv 3.0和ms visual studio 2012上安装(提取)了opencv。我使用cmake创建库。cmake->c:/opencv/build custom/中生成二进制文件的路径,与opencv路径不同。我在cmake中选择visual studio 11 2012。 还要设置环境路径。 在property manager中,我设置c/c++>general>AdditionalIncludeDirectories:
C:\lazy\opencv\build\include;% 链接器>常规>附加库目录:C:\opencv\build\u custom\lib\Debug;%

链接器>输入>附加依赖项:opencv_calib300d.lib;opencv_core300d.lib;opencv_特性2d300d.lib;opencv_flann300d.lib;opencv_highgui300d.lib;opencv_imgproc300d.lib;opencv_ml300d.lib;opencv_objdetect300d.lib;opencv_photo300d.lib;opencv_stitching300d.lib;opencv_superres300d.lib;opencv_ts300d.lib;opencv_video300d.lib;opencv_videostab300d.lib

我在ms visual studio中为svm使用以下代码:

#include <stdio.h>
#include <math.h>
#include <opencv\cv.h>
#include <opencv\highgui.h>
#include <opencv2\objdetect\objdetect.hpp>
#include <opencv2\highgui\highgui.hpp>
#include <opencv2\imgproc\imgproc.hpp>
#include <vector>
#include <windows.h>
#include <atlstr.h>
#include <iostream>
#include <sstream>
#include <iomanip>
//#include <opencv2\imgproc\imgproc.hpp>
#include <opencv2\core\core.hpp>
//#include <opencv2\highgui\highgui.hpp>
#include <opencv\cvaux.hpp>

using namespace cv;
using namespace std;

#include <opencv2\ml.hpp>

using namespace cv;

int main()
{
    // Data for visual representation
    int width = 512, height = 512;
    Mat image = Mat::zeros(height, width, CV_8UC3);


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

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

    // Set up SVM's parameters

    Ptr<ml::SVM> svm = ml::SVM::create();
    // edit: the params struct got removed,
    // we use setter/getter now:
    svm->setType(ml::SVM::C_SVC);
    svm->setKernel(ml::SVM::LINEAR);
    svm->setGamma(3);

    svm->train(trainingDataMat, ml::ROW_SAMPLE, labelsMat);

    Mat res;   // output

    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) << j, i);
        float response = svm->predict(sampleMat, res);

        if (response == 1)
            image.at<Vec3b>(i, j) = green;
        else if (response == -1)
            image.at<Vec3b>(i, j) = 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;
    Mat sv = svm->getSupportVectors();

    for (int i = 0; i < sv.rows; ++i)
    {
        const float* v = sv.ptr<float>(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);

}
#包括
#包括
#包括
#包括
#包括
#包括
#包括
#包括
#包括
#包括
#包括
#包括
#包括
//#包括
#包括
//#包括
#包括
使用名称空间cv;
使用名称空间std;
#包括
使用名称空间cv;
int main()
{
//用于视觉表示的数据
整数宽度=512,高度=512;
材料图像=材料::零(高度、宽度、CV_8UC3);
//建立培训数据
int标签[4]={1,-1,-1};
Mat标签Mat(4,1,CV_32FC1,标签);
float trainingData[4][2]={{501,10},{255,10},{501255},{10501};
Mat培训数据Mat(4,2,CV_32FC1,培训数据);
//建立支持向量机的参数
Ptr-svm=ml::svm::create();
//编辑:已删除params结构,
//我们现在使用setter/getter:
svm->setType(ml::svm::C_SVC);
svm->setKernel(ml::svm::LINEAR);
svm->setGamma(3);
svm->train(trainingDataMat,ml::ROW_样本,labelsMat);
Mat res;//输出
Vec3b绿色(0,255,0),蓝色(255,0,0);
//显示SVM给出的决策区域
对于(int i=0;igetSupportVectors();
对于(int i=0;i
调试时,我发现了一个错误。 这是我在运行程序时遇到的错误


如何解决它?

函数位于
opencv\u imgcodecs300d.lib
中,将其添加到其他依赖项中

查看LNK2019和opencv的所有其他问题:可能您正在混合不同的配置和/或平台。实际上:如果opencv是为调试/Win32而构建的,那么您的项目应该是我们的也可以。所以没有发行版/x64左右。还要确保添加了所有必需的库。我使用32位pc,也使用调试/win32模式。如果可能,请给我重新配置opencv的链接。哇,老实说,我没想到在opencv中,如果你想在调试模式下编译代码,你必须使用调试库,因为通常情况下,当我不需要li时bs的调试信息我只是将它们保持在发布模式,这没有问题,对于Windows库,您别无选择,只能使用发布库。