how to print out (display) a matrix [closed]

asked 2013-12-07 14:20:53 -0600

amin.karimi gravatar image

i create a matrix like this double a[] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 };

CvMat Ma=cvMat(3, 4, CV_64FC1, a);

and i want to print out (display) this matrix but i cant i look for on the internet and learning opencv but i cant find a procedure for print out matrix please help me about 1 day i confuse

edit retag flag offensive reopen merge delete

Closed for the following reason the question is answered, right answer was accepted by sturkmen
close date 2020-10-05 10:08:26.620083

Comments

1

(not an answer, more a hint, if you'd switch to the c++ api instead, peace of cake) :

double a[] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 };

 cv::Mat Ma(3,4,CV_64FC1, a);

cout << Ma << endl;


[1, 2, 3, 4;
 5, 6, 7, 8;
 9, 10, 11, 12]
berak gravatar imageberak ( 2013-12-07 14:41:33 -0600 )edit

how i can switch to c++ , when i write cout my visual produce error

amin.karimi gravatar imageamin.karimi ( 2013-12-07 23:57:40 -0600 )edit

need to include iostream, also using namespace std;

berak gravatar imageberak ( 2013-12-08 02:41:19 -0600 )edit

thanks alot

amin.karimi gravatar imageamin.karimi ( 2013-12-08 03:22:23 -0600 )edit

when i write this code visual produce error

include <iostream>

include<core\core_c.h>

include<core\types_c.h>

include <highgui.h>

include <conio.h>

using namespace std;

int main()

{ int b; double a[] = { 3, 3, 3, 3, 3, 3, 7, 8, 9, 10, 11, 12 };

CvMat Ma=cvMat(3, 4, CV_64FC1, a);

cout<< Ma << endl; cin>>b; return(0);

} why???????/

amin.karimi gravatar imageamin.karimi ( 2013-12-08 06:13:00 -0600 )edit

CvMat, IplImage === c-api. cv::Mat === c++; cv::Mat != cvMat

really, stick with the c++ api, the old c one won't be supported for long

berak gravatar imageberak ( 2013-12-08 06:50:38 -0600 )edit

ok because i start learning opencv with learning opencv book and this book is for c api do u know a book or site learning opencv with c++???????

amin.karimi gravatar imageamin.karimi ( 2013-12-08 07:50:38 -0600 )edit

yes, the book is nice, still maybe look at the cpp samples in your opencv folder.

and ofc, the tutorials

berak gravatar imageberak ( 2013-12-08 09:05:58 -0600 )edit