打印出OpenCV C ++中(Mat)矩阵的值 [英] Print out the values of a (Mat) matrix in OpenCV C++

查看:4786
本文介绍了打印出OpenCV C ++中(Mat)矩阵的值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用cout将OpenCV中的矩阵值转储到控制台。我很快就知道,我不明白OpenvCV的类型系统和C ++模板足以完成这个简单的任务。



读者请张贴(或指向我)函数或代码片段打印Mat?



尊敬的,
Aaron



使用新的C ++ Mat接口而不是较旧的CvMat接口是优先的。

解决方案

http://stackoverflow.com/questions/1844736/accesing-a-matrix-element-in-the-mat-object-not-the-cvmat-object-in-opencv-c\">在矩阵元素中获取Mat OpenCV C ++中的对象(而不是CvMat对象)

然后只需循环 cout中的所有元素< <0>



或者更好地使用新的C ++界面(感谢 SSteve

  cv :: Mat M; 

cout<< M =<< endl<< < M < endl<< endl;


I want to dump the values of a matrix in OpenCV to the console using cout. I quickly learned that I do not understand OpenvCV's type system nor C++ templates well enough to accomplish this simple task.

Would a reader please post (or point me to) a little function or code snippet that prints a Mat?

Regards, Aaron

PS: Code that uses the newer C++ Mat interface as opposed to the older CvMat interface is preferential.

解决方案

See the first answer to Accesing a matrix element in the "Mat" object (not the CvMat object) in OpenCV C++
Then just loop over all the elements in cout << M.at<double>(0,0); rather than just 0,0

Or better still with the new C++ interface (thanks to SSteve)

cv::Mat M;

cout << "M = "<< endl << " "  << M << endl << endl;

这篇关于打印出OpenCV C ++中(Mat)矩阵的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆