如何将opencv图像(8UC3)转换为char *数组

时间:2015-12-19 05:34:08

标签: opencv

我有一张RGB图像。我使用:

在opencv中加载它
Mat image;
image = imread(argv[1], CV_LOAD_IMAGE_COLOR);   // Read the file

现在我需要从图像数据创建一个uchar *数组。 我该怎么做?

1 个答案:

答案 0 :(得分:1)

uchar* cv::Mat::data

pointer to the data

并且不要忘记Mat实际行大小可能与width * sizeof(element)不同:

 cv::Mat::step is needed because the matrix can be a part of another matrix
 or because there can some padding space in the end of each row for a proper 
 alignment.