Purpose: read all images from a video, image format should be RGB arrays, add overlay to image(for some reason, I have to do the overlay on RGB array), display image. I did some research online, but there is no official or highly up-voted solution.
Currently what I do is read image as cv::Mat, then convert Mat to array, can I directly read image as RGB arrays from video?
Below is how I convert cv::Mat to RGB arrays, is it correct? Not sure if one row of data is contiguous in memory for cv::Mat? Or is all rowscolumns3 contiguous in memory for cv::Mat? Do you have better solutions?
for (int i = 0; i < Mat_frame; i++) { memcpy(array_buffer, Mat_frame.ptr(i), Mat_frame.cols * sizeof(uint8_t)); array_buffer += Mat_frame.cols; }
How can I convert RGB arrays back to cv::Mat? Is there a function I can use directly? If not, I can do the reverse of 2 code to convert.
About display, cv::waitKey(10), this means giving 10ms for image to display. If I want to display images ASAP, what the minimum value I can set? Or is it really depends on my machine's performance?
I really appreciate your comments and time.