zoukankan      html  css  js  c++  java
  • 【opencv基础】cv::Mat::type() 返回值

    前言

    opencv中Mat存在各种类型,其中mat有一个type()的函数可以返回该Mat的类型。类型表示了矩阵中元素的类型以及矩阵的通道个数,它是一系列的预定义的常量,其命名规则为CV_(位数)+(数据类型)+(通道数)。U表示无符号整数,S表示有符号整数,F表示浮点数。

    具体的有以下值: 

     err:

    OpenCV Error: Assertion failed (type == B.type()) in gemm, file /home/nvidia/build-opencv/opencv/modules/core/src/matmul.cpp, line 1558
    terminate called after throwing an instance of 'cv::Exception'
      what():  /home/nvidia/build-opencv/opencv/modules/core/src/matmul.cpp:1558: error: (-215) type == B.type() in function gemm
    
    Aborted (core dumped)

    code:

        cv::Mat rot_tmp;
        rot.convertTo(rot_tmp, CV_32FC1);
        cv::Mat P = (cv::Mat_<float>(3,4) <<
            0, lineL, 0,  0,
            0, 0, -lineL, 0,
            0, 0, 0, -lineL);
        std::cout << "rot.type: " << rot.type()<< std::endl;
        std::cout << "rot_tmp.type: " << rot_tmp.type()<< std::endl;
        std::cout << "P.type: " << P.type()<< std::endl;
        P = rot_tmp.rowRange(0,2)*P;

    注意

    矩阵乘法,AB = A * B,

    三者中A的列数与B的行数相等,且三者的数据类型必须完全一致, 且只能是CV_32F、 CV_64FC1、 CV_32FC2、 CV_64FC2四种数据类型中其一,否则会出错。

    terminate called after throwing an instance of 'cv::Exception'
    what(): OpenCV(3.4.3) /***/modules/core/src/matmul.cpp:1558: error: (-215:Assertion failed) (type == (((5) & ((1 << 3) - 1)) + (((1)-1) << 3)) || type == (((6) & ((1 << 3) - 1)) + (((1)-1) << 3)) || type == (((5) & ((1 << 3) - 1)) + (((2)-1) << 3)) || type == (((6) & ((1 << 3) - 1)) + (((2)-1) << 3))) in function 'gemm'
    Aborted

    参考

    1. OpenCV中Mat的type

    2. opencv_mat;

  • 相关阅读:
    菜鸡学习之路之并查集
    Leetcode 28. 实现 strStr() python3
    Leedcode 67. 二进制求和 python3
    2020 高校战“疫”网络安全分享赛 misc ez_mem&dump & 隐藏的信息
    leetcode 709.转换成小写字母
    2020 MetasequoiaCTF 部分misc
    Linux任务在后台运行
    Linux网络监控(netstat)
    Linux中wget资源下载
    Linux远程登录+远程发送文件
  • 原文地址:https://www.cnblogs.com/happyamyhope/p/9958018.html
Copyright © 2011-2022 走看看