Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

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.

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.