zoukankan      html  css  js  c++  java
  • Opencv4调试摄像头参数示例

    #pragma execution_character_set("utf-8")
    #include <opencv2/opencv.hpp>
    #include <opencv2/core/core.hpp>
    
    int main()
    {
        cv::VideoCapture capDevice(0);
        capDevice.open(0);
        //设置摄像头采集图像分辨率
        capDevice.set(cv::CAP_PROP_FRAME_WIDTH, 1024.0);
        capDevice.set(cv::CAP_PROP_FRAME_HEIGHT, 960.0);
    
        capDevice.set(cv::CAP_PROP_FRAME_WIDTH, 1080);//宽度 
        capDevice.set(cv::CAP_PROP_FRAME_HEIGHT, 960);//高度
        //capDevice.set(cv::CAP_PROP_FPS, 30);//帧率 帧/秒
        capDevice.set(cv::CAP_PROP_BRIGHTNESS, 1);//亮度 1
        capDevice.set(cv::CAP_PROP_CONTRAST, 60);//对比度 40
        capDevice.set(cv::CAP_PROP_SATURATION, 64);//饱和度 50
        capDevice.set(cv::CAP_PROP_HUE, 0);//色调
        capDevice.set(cv::CAP_PROP_EXPOSURE, -7);//曝光 50
        cv::Mat srcImage;
    
        //宽度 
        double width = capDevice.get(cv::CAP_PROP_FRAME_WIDTH);
        //高度
        double height = capDevice.get(cv::CAP_PROP_FRAME_HEIGHT);
        //帧率 帧/秒
        //int fps = capDevice.get(cv::CAP_PROP_FPS);
        //亮度
        double bright = capDevice.get(cv::CAP_PROP_BRIGHTNESS);
        //对比度
        double contrast = capDevice.get(cv::CAP_PROP_CONTRAST);
        //饱和度
        double saturation = capDevice.get(cv::CAP_PROP_SATURATION);
        //色调
        double hue = capDevice.get(cv::CAP_PROP_HUE);
        //曝光时长
        double exposure = capDevice.get(cv::CAP_PROP_EXPOSURE);
    
        //设置绘制文本的相关参数
        char text[255] = "";
        int font_face = cv::FONT_HERSHEY_COMPLEX;
        double font_scale = 1;
        int thickness = 1;
    
        while (true) {
            if (capDevice.isOpened())
            {
                capDevice >> srcImage;
            }
    
            sprintf(text, "%0.1f height:%0.1f exposure:%0.1f", width, height, exposure);
            cv::putText(srcImage, text, cv::Point(20, 30), font_face, font_scale, cv::Scalar(0, 255, 255), thickness, 8, 0);
    
            sprintf(text, "bright:%0.1f contrast:%0.1f saturation:%0.1f hue:%0.1f", bright, contrast, saturation, hue);
            cv::putText(srcImage, text, cv::Point(20, 90), font_face, font_scale, cv::Scalar(0, 255, 255), thickness, 8, 0);
    
            imshow("image", srcImage);
            cv::waitKey(30);
        }
    }
    本文版权归作者和博客园共有,欢迎转载,但必须给出原文链接,并保留此段声明,否则保留追究法律责任的权利。
  • 相关阅读:
    Windows Phone 8 Wallet 手机钱包 / 电子钱包
    Windows Phone 8 In app purchase 应用内购买 / 应用内支付
    Windows Phone 8 适应多屏分辨率
    Windows phone 8 基于定位的后台应用
    Windows Phone 8 Nokia地图控件
    Windows Phone 8 MDIL编译与代码混淆工具
    Windows Phone 8 近场通信 NFC / Bluetooth Proximity
    Windows Phone 8 镜头应用 Lenses for Windows Phone 8
    Windows Phone 8 与 windows 8 开发技术概览
    嵌入式成长轨迹54 【Zigbee项目】【CC2430基础实验】【系统睡眠工作状态】
  • 原文地址:https://www.cnblogs.com/yamboo/p/13889559.html
Copyright © 2011-2022 走看看