user27665
user27665

Reputation: 683

how to convert opencv image(8UC3) to a char * array

I have a RGB image. I load it in opencv using:

Mat image;
image = imread(argv[1], CV_LOAD_IMAGE_COLOR);   // Read the file

Now I need to create an uchar *array from the image data. How do i do it?

Upvotes: 0

Views: 795

Answers (1)

MBo
MBo

Reputation: 80187

uchar* cv::Mat::data

pointer to the data

And don't forget that Mat actual row size might differ from 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.

Upvotes: 1

Related Questions