Is there anyway to convert Mat into array in opencv? (c++) I need to copy a matrix (which is output of a function) into where a pointer points to. Format of the output is Mat and pointer is float. How do I copy it?
Thanks in advance
Is there anyway to convert Mat into array in opencv? (c++) I need to copy a matrix (which is output of a function) into where a pointer points to. Format of the output is Mat and pointer is float. How do I copy it?
Thanks in advance
Mat is also two dimensional array covered by class. If you need data in it, you can access it with Mat::at(int x, int y) method. Or copy raw data:
cv::Mat matrix;
float *new_data = new float[matrix.rows*matrix.cols];
float *p = new_data;
for(int i = 0; i < matrix.rows; i++){
memcpy(p, matrix.ptr(i), matrix.cols*sizeof(float));
p += matrix.cols;
}