using cout with Mat object
Hi.. I needed to print my Mat object and the programm throws an exception... The project is really simply: creating Mat object and printing by using cout - just like in OpenCV tutorial:
#include <core/core.hpp>
#include <highgui/highgui.hpp>
#include <iostream>
using namespace std;
using namespace cv;
int main(int argc, char *argv[])
{
Mat O = Mat::ones(2, 2, CV_32F);
cout << "O = " << endl << " " << O << endl << endl;
// Point2f P(5, 1);
// cout << "Point (2D) = " << P << endl << endl;
return 0;
}
The exception says: Unhandled exception at 0x59430671 (msvcp100d.dll) in printingTest.exe: 0xC0000005: Access violation reading location 0x00000000. Console shows only
O = [
Precisely it stops on "operations.hpp" at:
static inline std::ostream& operator << (std::ostream& out, const Mat& mtx) { Formatter::get()->write(out, mtx); return out; } It seems "out" to be empty, but does someone know why? Tutorial says it should work...
I had earlier similar problem with throwing exception and I solved it here:
http://answers.opencv.org/question/5113/problem-with-reading-image-to-mat/
Is it possible that there is another environmental variable conflict? or maybe a collision 'cause I'm using VS2012 and there's OpenCV only for v10?
The thing with Point2f which is commented works normally.
Ok, it's working. For Visual Studio 2012 you have to make a build of OpenCV in CMake and change of course the path to the libs in Linker properties and also change the environmental variable PATH.
What version of OpenCV was this with? I have this problem with OpenCV 2.4.4 and it seems it does support VS2012 (it has stuff in a vc11 folder at least and everything else works). Maybe I whould rebuild opencv?
I have pointed the path variable to vc10 currently. Should I make a build of OpenCV 2.4.7 (version I am using) for VS2012 and point the path to it. I am curious as how you figured out what was causing the problem.