i want to Convert Mat to vector and Vector to mat in opencv .
my code :
void mat_to_vector(Mat in,vector &out){
for
I think my code will be useful for you:
// Generate some test data
int r=3;
int c=3;
Mat M(r,c,CV_32FC1);
for(int i=0;i(i)=i;
}
// print out matrix
cout << M << endl;
// Create vector from matrix data (data with data copying)
vector V;
V.assign((float*)M.datastart, (float*)M.dataend);
// print out vector
cout << "Vector" << endl;
for(int i=0;i