C++版本OpenCV操作记录

#include <opencv2/imgcodecs.hpp>  // image文件读取与写入
#include <opencv2/highgui.hpp>  // 高等级gui
#include <opencv2/imgproc.hpp>  // 图像处理
#include <iostream>

using namespace cv;
using namespace std;


void opColorTrans(string image_filepath);  // 颜色模式转换
void opMat(string image_filepath);  // Mat学习
void matVisit(string image_filepath);  // Mat遍历
void matOperate(string image_filepath);  // Mat加减乘除
void colorStyle(string image_filepath);  // 颜色模式
void bitwise(string image_filepath);  // 像素逻辑操作
void channelOp(string image_filepath);  // 通道处理
void inrangOp(string image_filepath);  // color范围提取
void colorStatistic(string image_filepath);  // color统计信息
void drawShape(string image_filepath);  // 形状绘制
void imageNorm(string image_filepath);  // image norm
void resizeFlipRotate(string image_filepath);  // 图像缩放,插值,翻转,旋转
void videoProcess(string video_filepath);  // 视频加载
void videoProcess_2(string video_filepath);  // 处理视频
void cnnOp(string image_filepath);  // 卷积处理



int main(){

    string image_filepath = "../../resources/1.png";
    string image_filepath_4 = "../../resources/4.png";
    string video_filepath = "../../resources/1.mp4";
    string video_filepath_2 = "../../resources/save.mp4";
    
    // 输入image颜色模式的转换
    // opColorTrans(image_filepath);

    // Mat类学习
    // opMat(image_filepath);

    // Mat遍历
    // matVisit(image_filepath);

    // Mat加减乘除
    // matOperate(image_filepath);

    // 颜色模式
    // colorStyle(image_filepath);

    // 像素的逻辑操作
    // bitwise(image_filepath);

    // 通道处理
    // channelOp(image_filepath);

    // color范围提取
    // inrangOp(image_filepath_4);

    // color统计信息
    // colorStatistic(image_filepath);

    // 形状绘制
    // drawShape(image_filepath);

    // image norm
    // imageNorm(image_filepath);

    // 图像缩放,插值,翻转,旋转
    // resizeFlipRotate(image_filepath);

    // 视频加载
    // videoProcess(video_filepath_2);

    // 视频处理
    // videoProcess_2(video_filepath);

    // 卷积处理
    cnnOp(image_filepath);

    return 0;
}

void cnnOp(string image_filepath){
    Mat img = imread(image_filepath);
    imshow("img", img);

    // 均值模糊卷积核
    Mat dst;
    blur(img, dst, Size(13, 13), Point(-1. -1));  // 3x3卷积核的高斯模糊, Point默认的卷积核中心位置
    imshow("dst", dst);

    // 高斯模糊卷积核
    Mat dst2;
    GaussianBlur(img, dst2, Size(5, 5), 15, 15);  // 最后两个是告诉函数的gamma参数, size必须奇数,size为0的时候模糊程度最高(她会自动模糊)
    imshow("dst2", dst2);


    waitKey(0);
}

void videoProcess_2(string video_filepath){
    VideoCapture capture(0);  // 只有0的时候表示打开摄像头

    int frame_width = capture.get(CAP_PROP_FRAME_WIDTH);  // 宽度(同样也有set方法)
    int frame_height = capture.get(CAP_PROP_FRAME_HEIGHT);  // 宽度
    int count = capture.get(CAP_PROP_FRAME_COUNT);  // 总帧数
    int fps = capture.get(CAP_PROP_FPS);  //  fps是1s钟能处理多少张图像的能力,越多实时性越好,15/s肉眼看不出卡顿,30/
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值