sophon opencv process

PHOTO EMBED

Sun Oct 08 2023 02:09:44 GMT+0000 (Coordinated Universal Time)

Saved by @zhwalker #c++

    // 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());
    }
content_copyCOPY