私のコードにリンカの問題があるようです。リンカエラーSVC用OpenCV
コードは次のとおりです。
2> SVM.obj:エラーレポートはここ
#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; }
でエラーLNK2019:未解決の外部シンボル「パブリック:無効 __thiscallのCV ::マット:関数:public:void __thiscall cv :: Mat :: release(void) "(?release @ Mat @ cv @@ QAEXXZ)で参照されているdeallocate(void)(?deallocate @ Mat @ cv @ SVM.obj:エラー LNK2019:未解決の外部シンボル "public:void __thiscall c "public: class cv :: MatConstIterator & __thiscall cv :: MatConstIterator :: operator ++("関数 "で参照される): (?seek @ MatConstIterator @ cv @@ QAEXH_N @ SVM.obj:エラーLNK2019: 未解決の外部シンボル "public:void __thiscall cv :: Mat :: copySize(クラスcv :: Mat const &) ) " __thiscall cv :: Mat :: Mat(クラスcv :: Mat const &)"(?? 0Mat @ cv @@)で参照されている " (?copySize @ Mat @ cv @@ QAEXABV12 @ QAE @ ABV01 @@ Z)2> SVM.obj:エラーLNK2019:未解決 外部シンボル "void __cdecl cv :: fastFree(void *)" (?fastFre SVM.obj:エラーLNK2019:関数「public:__thiscall cv :: Mat ::〜Mat(void)」で参照されている、 未解決の外部シンボル "public:void __thiscall cv :: Mat :: create(int、int const *、int)"(function @ public:void __thiscall で参照される SVM.obj: エラーLNK2019:未解決の外部シンボル "public:void __thiscall cv :: Mat :: create(int、int、int)"関数 で参照される " (?seek @ MatConstIterator @ cv @@ QAEXPBH_N @ Z)" public:__thiscall cv :: MatConstIterator :: MatConstIterator(クラス cv :: Mat const * ) "SVM.obj 012(SVMat @ 1 @@ Z)2 SVM.obj :エラーLNK2019:未解決の外部シンボル? "パブリック:無効__thiscall CV ::マット::にconvertTo(クラスCV :: _ OutputArray constの &、int型、ダブル、ダブル)constは" (にconvertTo @マット@ CV @@ QBEXABV_OutputArray ":クラスのcv :: Mat_ & _ thiscall CV ::マット ::演算子=(クラスCV ::マットのconst &)公共" (?? 4 $? 機能で参照Z @ HNN @ @ 2) SVM.obj:エラーLNK2019: 未解決の外部シンボル "public:__thiscall cv :: _ OutputArray :: _ OutputArray(クラスcv :: Mat &)" (?? 0_OutputArray @ cv @@ QAE @ AAVMat @ 1 @@Z)関数内で参照され、 "公共: クラスのcv :: Mat_ & _ thiscall CV ::マット ::演算子=(クラス CV ::マットのconst &)"(?? 4 $ Mat_ @ M @ CV @@ QAEAAV01? @ ABVMat @ 1 @@)2> SVM.obj: エラーLNK2019:未解決の外部シンボル "public:class cv :: Mat __thiscall cv :: Mat :: reshape(int、int、int const *)const" ?マッシュアップ@マット@ cv @@ QBE?AV12 @ HHPBH @ Z)関数で参照 "パブリック: クラスのcv :: Mat_ & _ thiscall CV ::マット ::演算子=(クラス CV ::マットのconst &)"(?? 4 $ Mat_ @? SVM.obj: エラーLNK2019:未解決の外部シンボル「public:virtual __thiscall CvSVM ::〜CvSVM(void)」(?? 1CvSVM @@ UAE @関数_mainで参照される2> SVM.obj:エラーLNK2019:関数_mainで参照される未解決の外部シンボル "int __cdecl cv :: waitKey(int)"(?waitKey @ cv @@ YAHH @ Z) 2> SVM .obj:エラーLNK2019:未解決の外部シンボル "void __cdecl cv :: imshow(クラスstd :: basic_string、クラスstd :: allocator> const &、クラス CV :: _ InputArrayのconstの&)」 (?imshowを@ CV @@ YAXABV?$のbasic_string DU @?$ char_traits @ D @のstd @@ V?$アロケータ@ D @ 2 @@のstd @@ ABV_InputArray 1を@ @@ Z) 関数_main 2> SVM.objで参照:エラーLNK2019:未解決 外部シンボル「BOOL __cdecl CV ::関数imwrite(クラス のstd ::のbasic_string、クラス のstd ::アロケータ> CONST &、クラスCV :: _をInputArray const &、クラス std :: vector> const &) " (?imwrite @ cv @@ YA_NABV?$ basic_string @ DU?$ char_traits @ D @ std @@ V?$ allocator @D @ 2 @@ std @@ $ _ @ 3 @@ Z) 関数_main 2で参照されています> SVM.obj:エラーLNK2019:未解決 e function _main 2> SVMで参照されているxternal symbol "public:__thiscall cv :: _ InputArray :: _ InputArray(クラス cv :: Mat const &)"(0hInputArray @ cv @@ QAE @ ABVMat @ 1 @ OBJ:エラーLNK2019:未解決の外部シンボル "公共:仮想フロートのconst * __thiscall CvSVM :: get_support_vector(int型)constは" (?get_support_vector @ CvSVM @@ UBEPBMH @ Z) 2> SVM.obj _main関数の中で参照:エラーLNK2019:未解決の外部シンボル "パブリック:仮想 int型__thiscall CvSVM :: get_support_vector_count(無効)constは" 2> SVM.obj _main関数内で参照さ (get_support_vector_count @ CvSVM @@ UBEHXZ?):エラーLNK2019:未解決の外部シンボル "空き_ cdecl CV ::サークル(クラスCV ::マット&、クラスCV ::ポイント、int型、クラス CV :: Scalar_のconstの&、int型、int型、int型)」 (?円@ CV @@ YAXAAVMat @ 1 @関数_main 2で参照される > SVM.obj:エラーLNK2019:未解決 外部シンボル "public:virtual float __thiscall CvSVM :: predict関数_mainで参照される cv :: Mat const &、bool)const "(?predict @ CvSVM @@ UBEMABVMat @ cv @@ _N @ Z) > SVM.obj:エラーLNK2019:未解決 外部シンボル" public :virtual bool __thiscall CvSVM :: train(クラス cv :: Mat const &、クラスcv :: Mat const &、クラスcv :: Mat con ?ST &、クラス CV ::マットのconst &、構造体CvSVMParams)」 (電車@ CvSVM @@ UAE_NABVMat @ CV @@ 000UCvSVMParams @@@ Z) 関数_main 2> SVM.objで参照:エラーLNK2019:未解決外部シンボル function _main 2> SVM.obj:エラーLNK2019:未解決の外部 シンボルで "public:__thiscall CvSVMParams ::(0CvSVM @ CQS @ XZ)"を参照している "public:__thiscall CvSVM :: CvSVM(void)関数_main 2で参照される (?? 0CvSVMParams @@ QAE @ XZ)> SVM.obj: エラーLNK2019:未解決の外部シンボル "public:static class cv :: MatExpr __cdecl cv :: Mat :: CvSVMParams(void)ゼロ(int、int、int) " (?zeros @ Mat @ cv @@ SA?link:AVMatExpr @ 2 @ HHH @ Z)私は、ウィロウガラージで利用できるWindows 7用のOpenCVの最後のすべての内蔵バージョンを持っている、と私はwikiページからこの例を実行しようとしています
_main機能で参照。私のコンパイラはVC++です。
私はすでにGoogleで検索していますが、何も問題はありません。 ( - >リンカ - 設定>入力)
おかげで同じ問題を抱えてしまう人のために