图像基础

Mat类解析(实际是一种矩阵)

class  Mat
{
 
public/*
         flag: 
         1.数字签名 
         2.维度
         3.通道数
         4.连续性
     */
    int flags;                    
    int dims;                     //数据维数
    int rows,cols;                 //数据行列
    uchar *data;                //存储的数据        
    const uchar* datastart;        //数据开始
    const uchar* dataend;        //数据结束
    const uchar* datalimit;        //数据边界
    //其他成员  
     //.....
     //其他方法
     //.....
 public:         //构造方式
    // 默认构造函数 Mat A;
    Mat ()
    // 常用构造函数 Mat A(10,10,CV_8UC3);
    Mat (int rows, int cols, int type)
    //Mat A(300, 400, CV_8UC3,Scalar(255,255,255));
    Mat (int ndims, const int *sizes, int type, const Scalar &s)
    Mat (Size size, int type)
    Mat (int rows, int cols, int type, const Scalar &s)
    Mat (Size size, int type, const Scalar &s)
    Mat (int ndims, const int *sizes, int type)
    Mat (const Mat &m)
    Mat (int rows, int cols, int type, void *data, size_t step=AUTO_STEP)
    Mat (Size size, int type, void *data, size_t step=AUTO_STEP)
    Mat (int ndims, const int *sizes, int type, void *data, const size_t *steps=0)
    Mat (const Mat &m, const Range &rowRange, const Range &colRange=Range::all())
    //Mat D (A, Rect(10, 10, 100, 100) );
    Mat (const Mat &m, const Rect &roi)
    Mat (const Mat &m, const Range *ranges)
    
};

CV_8UC3系列解读

CV_<bit_depth>(S|U|F)C<number_of_channels>
/*
    1.bit_depth: 像素点占用空间大小 bit
    2.S|U|F:
        S:signed int   -->有符号
        U:unsigned int -->无符号
        F:float           -->单精度浮点
    3.number_of_channels
        3.1 单通道图像,即为灰度图像
        3.2 双通道图像
        3.3 3通道图像
        4.4 带Alpha通道的彩色图像,4通道图像
*/

 视频

视频时一连串的图片,所以只需要连续遍历即可

#include <opencv2/core/core.hpp>
#include <opencv2/imgproc.hpp>
#include <opencv2/opencv.hpp>
#include <iostream>

using namespace cv;
using namespace std;

int main()

{
    string path="Resources/hangzhou1.mp4";
    VideoCapture cap(0);//不是相机就填视频路径
    Mat img ;
    while (1)
    {

        cap.read(img);
        
        imshow("img", img);
        waitKey(20);
    }
    
    return 0;
}

 

posted @ 2023-04-17 16:13  hbhhbh  阅读(12)  评论(0)    收藏  举报