Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Unhandled exception at 0x65e70fcd in svm.exe: 0xC0000005: Access violation reading location 0x00000000.

guys m new to opencv and programming. i tried executing the SVM code in pdf n getting the above exception.. please help me in this..

include "stdafx.h"

include <cv.h>

include <cxcore.h>

include <highgui.h>

include <ml.h>

//#include <opencv2 core="" core.hpp=""> //#include <opencv2 highgui="" highgui.hpp=""> //#include <opencv2 ml="" ml.hpp="">

using namespace cv; using namespace std;

int main() { // 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 <2; ++i) for (int j = 0; j <2; ++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);

}

i get only 1 exception i.e mentioned above when i add ml210.lib to the linker.. if i do not add ml210.lib to d linker i get d following errors..

1>svm.obj : error LNK2019: unresolved external symbol "public: virtual __thiscall CvSVM::~CvSVM(void)" (??1CvSVM@@UAE@XZ) referenced in function _main

1>svm.obj : error LNK2019: unresolved external symbol "public: virtual float const * __thiscall CvSVM::get_support_vector(int)const " (?get_support_vector@CvSVM@@UBEPBMH@Z) referenced in function _main

1>svm.obj : error LNK2019: unresolved external symbol "public: virtual int __thiscall CvSVM::get_support_vector_count(void)const " (?get_support_vector_count@CvSVM@@UBEHXZ) referenced in function _main

1>svm.obj : error LNK2019: unresolved external symbol "public: virtual float __thiscall CvSVM::predict(class cv::Mat const &,bool)const " (?predict@CvSVM@@UBEMABVMat@cv@@_N@Z) referenced in function _main

1>svm.obj : error LNK2019: unresolved external symbol "public: virtual bool __thiscall CvSVM::train(class cv::Mat const &,class cv::Mat const &,class cv::Mat const &,class cv::Mat const &,struct CvSVMParams)" (?train@CvSVM@@UAE_NABVMat@cv@@000UCvSVMParams@@@Z) referenced in function _main

1>svm.obj : error LNK2019: unresolved external symbol "public: __thiscall CvSVM::CvSVM(void)" (??0CvSVM@@QAE@XZ) referenced in function _main

1>svm.obj : error LNK2019: unresolved external symbol "public: __thiscall CvSVMParams::CvSVMParams(void)" (??0CvSVMParams@@QAE@XZ) referenced in function _main

1>C:\Users\DELL\Desktop\svm\Debug\svm.exe : fatal error LNK1120: 7 unresolved externals

Any help would be greatly appreciated.. Thanks in advance..

click to hide/show revision 2
No.2 Revision

updated 2013-04-18 01:34:29 -0600

berak gravatar image

Unhandled exception at 0x65e70fcd in svm.exe: 0xC0000005: Access violation reading location 0x00000000.

guys m new to opencv and programming. i tried executing the SVM code in pdf n getting the above exception.. please help me in this..

include "stdafx.h"

include <cv.h>

include <cxcore.h>

include <highgui.h>

include <ml.h>

#include "stdafx.h"

#include <cv.h>
#include <cxcore.h>
#include <highgui.h>
#include <ml.h>

 //#include <opencv2 core="" core.hpp="">
<opencv2/core/core.hpp>
 //#include <opencv2 highgui="" highgui.hpp="">
<opencv2/highgui/highgui.hpp>
 //#include <opencv2 ml="" ml.hpp="">

<opencv2/ml/ml.hpp> using namespace cv; using namespace std;

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

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

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

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);

1e-6); // Train the SVM CvSVM SVM; SVM.train(trainingDataMat, labelsMat, Mat(), Mat(), params);

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

SVM.predict(sampleMat); if (response == 1) image.at<vec3b>(j, image.at<Vec3b>(j, i) = green; else if (response == -1) image.at<vec3b>(j, 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);

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

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

image imshow("SVM Simple Example", image); // show it to the user waitKey(0);

}

waitKey(0); }

i get only 1 exception i.e mentioned above when i add ml210.lib to the linker.. if i do not add ml210.lib to d linker i get d following errors..

1>svm.obj : error LNK2019: unresolved external symbol "public: virtual __thiscall CvSVM::~CvSVM(void)" (??1CvSVM@@UAE@XZ) referenced in function _main

_main 1>svm.obj : error LNK2019: unresolved external symbol "public: virtual float const * __thiscall CvSVM::get_support_vector(int)const " (?get_support_vector@CvSVM@@UBEPBMH@Z) referenced in function _main

_main 1>svm.obj : error LNK2019: unresolved external symbol "public: virtual int __thiscall CvSVM::get_support_vector_count(void)const " (?get_support_vector_count@CvSVM@@UBEHXZ) referenced in function _main

_main 1>svm.obj : error LNK2019: unresolved external symbol "public: virtual float __thiscall CvSVM::predict(class cv::Mat const &,bool)const " (?predict@CvSVM@@UBEMABVMat@cv@@_N@Z) referenced in function _main

_main 1>svm.obj : error LNK2019: unresolved external symbol "public: virtual bool __thiscall CvSVM::train(class cv::Mat const &,class cv::Mat const &,class cv::Mat const &,class cv::Mat const &,struct CvSVMParams)" (?train@CvSVM@@UAE_NABVMat@cv@@000UCvSVMParams@@@Z) referenced in function _main

_main 1>svm.obj : error LNK2019: unresolved external symbol "public: __thiscall CvSVM::CvSVM(void)" (??0CvSVM@@QAE@XZ) referenced in function _main

_main 1>svm.obj : error LNK2019: unresolved external symbol "public: __thiscall CvSVMParams::CvSVMParams(void)" (??0CvSVMParams@@QAE@XZ) referenced in function _main

_main 1>C:\Users\DELL\Desktop\svm\Debug\svm.exe : fatal error LNK1120: 7 unresolved externals

externals

Any help would be greatly appreciated.. Thanks in advance..

Error when trying to execute the SVM example code

Guys, I am new to openCV and programming. I tried executing the SVM code in PDF and I am getting the above exception.

Unhandled exception at 0x65e70fcd in svm.exe: 0xC0000005: Access violation reading location 0x00000000. 
0x00000000.

guys m new to opencv and programming. i tried executing the SVM code in pdf n getting the above exception.. Can someone please help me in this..out with this?

#include "stdafx.h"

#include <cv.h>
#include <cxcore.h>
#include <highgui.h>
#include <ml.h>

 //#include <opencv2/core/core.hpp>
 //#include <opencv2/highgui/highgui.hpp>
 //#include <opencv2/ml/ml.hpp>

 using namespace cv;
 using namespace std;

 int main()
 {
 // 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 <2; ++i)
 for (int j = 0; j <2; ++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);

 }

i get only 1 exception i.e mentioned above when i add ml210.lib to the linker.. if i do not add ml210.lib to d linker i get d following errors..

1>svm.obj : error LNK2019: unresolved external symbol "public: virtual __thiscall CvSVM::~CvSVM(void)" (??1CvSVM@@UAE@XZ) referenced in function _main

1>svm.obj : error LNK2019: unresolved external symbol "public: virtual float const * __thiscall CvSVM::get_support_vector(int)const " (?get_support_vector@CvSVM@@UBEPBMH@Z) referenced in function _main

1>svm.obj : error LNK2019: unresolved external symbol "public: virtual int __thiscall CvSVM::get_support_vector_count(void)const " (?get_support_vector_count@CvSVM@@UBEHXZ) referenced in function _main

1>svm.obj : error LNK2019: unresolved external symbol "public: virtual float __thiscall CvSVM::predict(class cv::Mat const &,bool)const " (?predict@CvSVM@@UBEMABVMat@cv@@_N@Z) referenced in function _main

1>svm.obj : error LNK2019: unresolved external symbol "public: virtual bool __thiscall CvSVM::train(class cv::Mat const &,class cv::Mat const &,class cv::Mat const &,class cv::Mat const &,struct CvSVMParams)" (?train@CvSVM@@UAE_NABVMat@cv@@000UCvSVMParams@@@Z) referenced in function _main

1>svm.obj : error LNK2019: unresolved external symbol "public: __thiscall CvSVM::CvSVM(void)" (??0CvSVM@@QAE@XZ) referenced in function _main

1>svm.obj : error LNK2019: unresolved external symbol "public: __thiscall CvSVMParams::CvSVMParams(void)" (??0CvSVMParams@@QAE@XZ) referenced in function _main

1>C:\Users\DELL\Desktop\svm\Debug\svm.exe : fatal error LNK1120: 7 unresolved externals

Any help would be greatly appreciated.. Thanks in advance..