opencv

作者: 菜菜子MJ | 来源:发表于2020-05-18 12:22 被阅读0次

    安装

    mac

    brew install opencv

    For compilers to find openblas you may need to set:
    export LDFLAGS="-L/usr/local/opt/openblas/lib"
    export CPPFLAGS="-I/usr/local/opt/openblas/include"

    For pkg-config to find openblas you may need to set:
    export PKG_CONFIG_PATH="/usr/local/opt/openblas/lib/pkgconfig"

    格式
    注意:不需要加cv::的namespace前缀

    CV_8UC1

    颜色空间

    RGB → YUV
    目前从BGR到YUV420的颜色空间变化仅支持转换到420p的两种格式,不支持转换到420sp。

    假设src是OpenCV默认的BGR三通道图像,和420p的转换如下

    // BGR CV_8UC3 with 640x960 → I420 CV_8UC1 with 960x960

    cvtColor(src, dest, COLOR_BGR2YUV_I420);

    // BGR CV_8UC3 with 640x960 → YV12 CV_8UC1 with 960x960

    cvtColor(src, dest, COLOR_BGR2YUV_YV12);

    YUV → RGB
    支持420p或者420sp转换到BGR。

    假设src是OpenCV默认的BGR三通道图像,和420p的转换如下

    // I420 CV_8UC1 with 960x960 → BGR CV_8UC3 with 640x960

    cvtColor(src, dest, COLOR_YUV2BGR_I420);

    // YV12 CV_8UC1 with 960x960 → BGR CV_8UC3 with 640x960

    cvtColor(src, dest, COLOR_YUV2BGR_YV12);

    假设src是YUV420的420sp图像数据,到BGR的转换如下。

    // NV12 CV_8UC1 with 960x960 → BGR CV_8UC3 with 640x960

    cvtColor(src, dest, COLOR_YUV2BGR_NV12);

    // NV21 CV_8UC1 with 960x960 → BGR CV8UC3 with 640x960

    cvtColor(src, dest, COLOR_YUV2BGR_NV21);

    掩模
    简单叠加

    A在掩模C是白色的地方叠加到B

    A.copyTo(B, C);

    相关文章

      网友评论

          本文标题:opencv

          本文链接:https://www.haomeiwen.com/subject/rqruohtx.html