Ask Your Question
0

Convert Mat 5x5 to Vector

asked 2017-01-25 04:12:35 -0600

belan gravatar image

updated 2017-01-25 04:30:05 -0600

berak gravatar image

This is Matrix 5x5 , I want to convert it to vector. But it failed. I use reshape(0,1) and the error says bad number of row.

 [ 3.76666679e+001, -1., 40., -1., 3.06666660e+001, -1.,3.06666660e+001, -1., 27., -1., 
40., -1., 4.46666679e+001, -1.,3.53333321e+001, -1., 3.43333321e+001, -1., 30., -1.,
3.06666660e+001, -1., 3.53333321e+001, -1., 3.03333340e+001, -1.,28., -1., 24., -1., 
3.06666660e+001, -1., 3.43333321e+001, -1., 28., -1., 29., -1., 25., -1., 
27., -1., 30., -1., 24., -1., 25.,-1., 2.23333340e+001, -1. ]

Any somebody knows my problem? My code always difficult to reshape. Thank you

edit retag flag offensive close merge delete

Comments

why does your 5x5 mat has 50 elements ?

berak gravatar imageberak ( 2017-01-25 04:31:24 -0600 )edit

It contains matrix (x,y). is that wrong?

belan gravatar imagebelan ( 2017-01-25 04:36:01 -0600 )edit

1 answer

Sort by ยป oldest newest most voted
0

answered 2017-01-25 12:35:23 -0600

matman gravatar image

From a Mat 5x5 i would expect 25 elements. By the way you can pass the pointer to a vector for example:

cv::Mat mat(5, 5, CV_64FC1);
std::vector<double> vecMat(mat.begin<double>(), mat.end<double>());
edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2017-01-25 04:12:35 -0600

Seen: 152 times

Last updated: Jan 25 '17