I'd suggest to try to use <pre>std::cout &lt;&lt; mat</pre> one more time. You print not only double-precision, but also integer matrices. The built-in OpenCV operator could do all of this.