As already mentioned, you should use the data cv::Mat member:
cv::Mat m; ... uchar *data = m.data;
About your second question: first of all, when converting from double to float you lose some data. And there is no ready-made solution for this, so just use a simple loop and copy the vector into the array pointer:
float* toArray(vector<vector<double> >& arr) { if (arr.empty()) { return NULL; } else { //I assume that each vector (element of arr) has the same size int m = arr.size(); int n = arr[0].size(); float *res = new float[m * n]; int count = 0; for (int i=0; i<m; i++) { for (int j=0; j<n; j++) { res[count++] = (float) arr[i][j]; } } return res; } }
ArtemStorozhuk
source share