// for sophon opencv, the memory is not continuous if the width of image is not 64 bytes aligned
uint8_t continous_data[cvmat.cols * cvmat.rows * cvmat.channels()];
if (!cvmat.isContinuous())
{
std::cout << "cvmat is not continuous" << std::endl;
for (int i = 0; i < cvmat.rows; i++)
{
std::memcpy(continous_data + i * cvmat.cols * cvmat.channels(), cvmat.ptr(i), cvmat.cols * cvmat.channels());
}
}
else
{
std::memcpy(continous_data, cvmat.data, cvmat.cols * cvmat.rows * cvmat.channels());
}
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter