Replies: 2 comments 1 reply
-
@hcgprague Hi!, thank you for proposing a useful code. I guess the But I believe that as long as your code is valid it can help other people who want to do the same. I will look at applying Convert to discussion feature to this issue. |
Beta Was this translation helpful? Give feedback.
-
This code is ok! uint8_t* Mat_to_array(const cv::Mat input) use it just like below: |
Beta Was this translation helpful? Give feedback.
-
could it add a convert function() which make input is a Mat format ?
a convert function() which make input is a Mat format as :
void Mat2DWimage( Mat matImage, vector &directShowImage )
{
int width = matImage.cols;
int height = matImage.rows;
int channels = matImage.channels();
std::vector directShowImage(width * height * 3);
if (matImage.isContinuous()) {
memcpy(directShowImage.data(), matImage.data, directShowImage.size());
} else {
// If the image is not stored continuously in memory, copy row by row
for (int row = 0; row < height; ++row) {
memcpy(&directShowImage[row * width * 3], matImage.ptr(row), width * 3);
}
}
}
Beta Was this translation helpful? Give feedback.
All reactions