4

Following this question, I am attempting to print out the contents of a cv::Mat to standard output:

#include <iostream>
#include <opencv/cv.h>
#include <opencv/cv.hpp>
#include <opencv/cxcore.h>
#include <opencv/cxcore.hpp>

int main() {

  cv::Mat m = cv::Mat::ones(10, 10, CV_32S);
  std::cout << m << "\n";

}

This results in the error

error: no match for ‘operator<<’ in ‘std::cout << m’

I am using gcc 4.6.1 on Ubuntu 11.10, and installed opencv, excluding the examples, following these instructions. My question is, is the operator available in 2.1 and if so, how do I get it?

Community
  • 1
  • 1
juanchopanza
  • 223,364
  • 34
  • 402
  • 480
  • If the operator is not defined, you might need to upgrade to 2.2 or above. –  Apr 04 '12 at 14:30

2 Answers2

5

Update to OpenCV 2.2 (or higher) and #include <opencv2/opencv.hpp>

It's defined at modules/core/include/opencv2/core/operations.hpp

karlphillip
  • 92,053
  • 36
  • 243
  • 426
2

If the operator is not defined, you might need to upgrade to 2.2 or above. Documented Here Its where you can find the overloaded operators code.