Ask Your Question
0

How to append a Mat to another Mat

asked 2018-06-21 07:07:45 -0600

Macho gravatar image

updated 2018-06-21 07:08:27 -0600

I have the following two Matrices

Mat [ 1764*1*CV_32FC1 ]
Mat [ 2*4*CV_32FC1]

I want to append them in one Mat so that it will have only one row so i can train SVM

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
0

answered 2018-06-21 07:53:58 -0600

berak gravatar image

updated 2018-06-21 09:18:08 -0600

you need to do this in 2 steps:

Mat m1 = new Mat(515,2,5);
Mat m2 = new Mat(17,12,5);


// 1. make a single *colum* of m1:
m1 = m1.reshape(1, (int)m1.total());
// same for m2: 
m2 = m2.reshape(1, (int)m2.total());

m1.push_back(m2);
Mat final_row = m1.reshape(1,1);
edit flag offensive delete link more

Comments

Core.hconcat produces and error Not applicable for arguments (Mat, Mat, Mat) as it takes list <Mat>, Mat

What i have used is this

 Core.transpose(Mat1.reshape(1,1), Mat1);
 Mat2.push_back(Mat1);
Macho gravatar imageMacho ( 2018-06-21 09:02:41 -0600 )edit

apologies, saw the java tag too late, and did not test.

please seee update !

berak gravatar imageberak ( 2018-06-21 09:16:16 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2018-06-21 07:07:45 -0600

Seen: 3,444 times

Last updated: Jun 21 '18