Qt之QCamera的简单使用

news2024/10/26 17:22:58

文章目录

  • 一、相机操作相关示例
    • 1.摄像头操作内容使用示例
    • 2.摄像头信息展示使用示例
    • 3.摄像头设置切换、预览操作示例
  • 二、相机使用个人操作理解
    • 1.相机类支持信息获取
    • 2.相机类曝光、焦点、图像处理控制信息获取
    • 3.快速启动相机设置(各个设备处于理想状态)
  • 三、相机Demo源码
    • mainwindow.h
    • mainwindow.cpp
    • mainwindow.ui
  • 四、总结

一、相机操作相关示例

1.摄像头操作内容使用示例

下图演示流程如下

  1. 演示未打开摄像头时的拍摄提示
  2. 选择摄像头并打开
  3. 选择保存路径并查看保存路径(保证拍摄前无图)
  4. 点击拍摄并查看保存的图片
    请添加图片描述

2.摄像头信息展示使用示例

下图演示了通过相机对象相关函数获取的相关信息展示
请添加图片描述

3.摄像头设置切换、预览操作示例

下图演示流程如下

  1. 预览当前照片(查看新拍摄前的照片)
  2. 切换相机设置信息(从设置5切换到设置0)
  3. 点击就拍摄当前照片(包含Qt 5.9的图像)
  4. 点击预览包含Qt 5.9的图像
    请添加图片描述

二、相机使用个人操作理解

1.相机类支持信息获取

没错,相机对象启动后是可以查看相机的支持信息,相机可查看的支持信息包括支持的锁类型、支持的帧率范围、支持的像素格式、支持的分辨率已经支持的设置列表。
**注:**下方可传入一个取景器设置的函数将只匹配传入设置的已有配置,然后返回对应支持的配置列表;若传入设置为空则返回所有支持列表;使用相机前推荐先查看相机支持信息再继续使用


    /**
     * @brief supportedLocks 返回相机支持的锁类型
     * @return 支持的锁类型
     */
    QCamera::LockTypes supportedLocks() const;

    /**
     * @brief supportedViewfinderFrameRateRanges 返回相机支持的帧率范围列表
     * @param settings 要匹配的取景器设置
     * @return 可适配的帧率范围列表
     */
    QList<QCamera::FrameRateRange> supportedViewfinderFrameRateRanges(const QCameraViewfinderSettings &settings = QCameraViewfinderSettings()) const;

    /**
     * @brief supportedViewfinderPixelFormats 返回相机支持的像素格式列表
     * @param settings 要匹配的取景器设置
     * @return 可适配的像素格式列表
     */
    QList<QVideoFrame::PixelFormat> supportedViewfinderPixelFormats(const QCameraViewfinderSettings &settings = QCameraViewfinderSettings()) const;

    /**
     * @brief supportedViewfinderResolutions 返回相机支持的分辨率列表
     * @param settings 要匹配的取景器设置
     * @return 可适配的分辨率列表
     */
    QList<QSize> supportedViewfinderResolutions(const QCameraViewfinderSettings &settings = QCameraViewfinderSettings()) const;

    /**
     * @brief supportedViewfinderSettings 返回相机支持的取景器设置列表
     * @param settings 要匹配的取景器设置
     * @return 可适配的取景器设置列表
     */
    QList<QCameraViewfinderSettings> supportedViewfinderSettings(const QCameraViewfinderSettings &settings = QCameraViewfinderSettings()) const;

2.相机类曝光、焦点、图像处理控制信息获取

相机可通过一下函数获取相机对于的控制对象,但是获取的控制对象是const修饰符修饰的对象,所以获取的控制对象只能查看不能修改

    /**
     * @brief exposure 返回相机的曝光控制对象
     * @return 曝光对象控制对象
     */
    QCameraExposure *exposure() const;

    /**
     * @brief focus 返回相机的焦点控制对象
     * @return 焦点控制对象
     */
    QCameraFocus *focus() const;

    /**
     * @brief imageProcessing 返回相机图像处理控制对象
     * @return 图像处理控制对象
     */
    QCameraImageProcessing *imageProcessing() const;

3.快速启动相机设置(各个设备处于理想状态)

下方代码为快速获取相机信息并启动相机的代码逻辑。

	// 创建相机显示控件
    QWidget *wgt = new QWidget;
    // 添加布局器
    wgt->setLayout(new QHBoxLayout);
    // 创建相机对象,并通过相机信息函数获取最后一个相机
    QCamera *camera = new QCamera(QCameraInfo::availableCameras().last());
    // 创建相机取景器对象
    QCameraViewfinder *viewFinder = new QCameraViewfinder(wgt);
    // 设置相机取景器到相机中
    camera->setViewfinder(viewFinder);
    // 将取景器添加到布局器中
    wgt->layout()->addWidget(viewFinder);
    // 显示控件
    wgt->show();
    // 启动相机
    camera->start();

三、相机Demo源码

mainwindow.h

#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>
#include <QCameraViewfinder>
#include <QCameraInfo>

QT_BEGIN_NAMESPACE
namespace Ui { class MainWindow; }
QT_END_NAMESPACE

class QCamera;
class MainWindow : public QMainWindow
{
    Q_OBJECT
public:
    MainWindow(QWidget *parent = nullptr);
    ~MainWindow();

    /**
     * @brief initUi 初始化UI界面信息
     */
    void initUi();

    /**
     * @brief initCamera 初始化相机信息
     */
    void initCamera();

    /**
     * @brief updateCameraSupportInfo 更新相机支持信息
     */
    void updateCameraSupportInfo();

    /**
     * @brief updateCameraSupportSettingsInfo 更新相机支持的设置信息
     */
    void updateCameraSupportSettingsInfo();

    /**
     * @brief updateCameraSupportSettingsInfoBySetting 基于传入相机取景器设置对象的更新相机支持的设置信息
     * @param setting 传入相机取景器设置对象
     */
    void updateCameraSupportSettingsInfoBySetting(const QCameraViewfinderSettings &setting);

private slots:
    /**
     * @brief on_btnOpenCloseCamera_clicked 打开/关闭摄像头
     */
    void on_btnOpenCamera_clicked();

    /**
     * @brief on_btnCaptureImg_clicked 拍照槽函数
     */
    void on_btnCaptureImg_clicked();

    /**
     * @brief on_btnBaseInfo_clicked 展示基础信息
     */
    void on_btnBaseInfo_clicked();

    /**
     * @brief on_btnExposureInfo_clicked 展示曝光信息
     */
    void on_btnExposureInfo_clicked();

    /**
     * @brief on_btnCameraFocusInfo_clicked 展示相机焦点信息
     */
    void on_btnCameraFocusInfo_clicked();

    /**
     * @brief on_btnImageProcessingInfo_clicked
     */
    void on_btnImageProcessingInfo_clicked();

    /**
     * @brief on_btnUseCurrentSettings_clicked 使用当前设置信息
     */
    void on_btnUseCurrentSettings_clicked();

    /**
     * @brief on_comboBoxSettings_currentIndexChanged 设置信息下拉框项更新槽函数
     * @param index 更新索引位置
     */
    void on_comboBoxSettings_currentIndexChanged(int index);

    /**
     * @brief on_btnSelSavePath_clicked 选择图片保存路径
     */
    void on_btnSelSavePath_clicked();

    /**
     * @brief on_btnPreviewImg_clicked 图片预览按钮
     * @param checked 按钮选中状态,预览状态
     */
    void on_btnPreviewImg_clicked(bool checked);

private:
    Ui::MainWindow *ui;

    QCamera                     *m_camera = Q_NULLPTR;  // 相机对象

    QCameraViewfinder           m_cameraViewfinder;     // 相机取景器对象

    QHash<QString, QCameraInfo> m_hashCameraInfos;      // 相机信息容器
};
#endif // MAINWINDOW_H

mainwindow.cpp

#include "mainwindow.h"
#include "ui_mainwindow.h"

#include <QCamera>
#include <QCameraInfo>
#include <QMessageBox>
#include <QDateTime>
#include <QFileDialog>
#include <QTimer>

#include <QCameraFocus>
#include <QCameraExposure>
#include <QCameraImageCapture>
#include <QCameraImageProcessing>

MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent)
    , ui(new Ui::MainWindow)
    , m_camera(new QCamera(this))
{
    ui->setupUi(this);

    // 初始化ui界面
    initUi();
    // 初始化相机信息
    initCamera();
}

MainWindow::~MainWindow()
{
    delete ui;
}

void MainWindow::initUi()
{
    // 默认显示预览窗口
    ui->stackedWidget->setCurrentIndex(1);

    // 添加相机取景器到布局器中
    ui->layoutCamera->addWidget(&m_cameraViewfinder);

    // 添加提示信息
    ui->btnBaseInfo->setToolTip(u8"相机对象可直接获取的信息");
    ui->btnExposureInfo->setToolTip(u8"相机曝光信息:使用相机对象通过exposure函数获取QCameraExposure对象中拿到的信息");
    ui->btnCameraFocusInfo->setToolTip(u8"相机聚焦信息:使用相机对象通过focus函数获取QCameraFocus对象中拿到的信息");
    ui->btnImageProcessingInfo->setToolTip(u8"相机图片处理信息:使用相机对象通过imageProcessing函数获取QCameraImageProcessing对象中拿到的信息");
}

void MainWindow::initCamera()
{
    // 清空相机信息容器
    m_hashCameraInfos.clear();
    // 获取可用的相机信息容器
    const QList<QCameraInfo> &cameras = QCameraInfo::availableCameras();
    // 遍历可用相机信息容器,将相机信息存储并添加在相机信息下拉框中
    foreach (const QCameraInfo &cameraInfo, cameras) {
        m_hashCameraInfos[cameraInfo.description()] = cameraInfo;
        ui->comboBoxCameraInfo->addItem(cameraInfo.description());
    }

    // 未检测到相机的提示
    if(0 == ui->comboBoxCameraInfo->count()) {
        QMessageBox::information(this, u8"提示", u8"未检索到摄像头!");
    }
}

void MainWindow::updateCameraSupportInfo()
{
    // 支持信息容器清空
    ui->textBrowserSupportInfo->clear();
    // 摄像头未启动提示
    if(QCamera::ActiveState != m_camera->state()) {
        QMessageBox::information(this, u8"提示", u8"摄像头未启动,无法获取支持信息");
        return;
    }

    //! 添加相机基础信息
    // 支持的锁定信息
    QString locksStr = u8"锁类型:";
    locksStr += QString("%1 ").arg(m_camera->supportedLocks());
    ui->textBrowserSupportInfo->append(locksStr);

    // 支持的帧率范围
    QString frameRateRangesStr = u8"帧率范围:";
    foreach(auto rangeInfo, m_camera->supportedViewfinderFrameRateRanges()) {
        frameRateRangesStr += QString("(%1, %2) ").arg(rangeInfo.minimumFrameRate).arg(rangeInfo.maximumFrameRate);
    }
    ui->textBrowserSupportInfo->append(frameRateRangesStr);

    // 支持的像素格式
    QString pixelFormatsStr = u8"像素格式:";
    foreach(auto pixelFormatInfo, m_camera->supportedViewfinderPixelFormats()) {
        pixelFormatsStr += QString("%1 ").arg(pixelFormatInfo);
    }
    ui->textBrowserSupportInfo->append(pixelFormatsStr);

    // 支持的分辨率
    QString resolutionsStr = u8"分辨率:";
    foreach(auto resolutionInfo, m_camera->supportedViewfinderResolutions()) {
        resolutionsStr += QString("(%1, %2) ").arg(resolutionInfo.width()).arg(resolutionInfo.height());
    }
    ui->textBrowserSupportInfo->append(resolutionsStr);
}

void MainWindow::updateCameraSupportSettingsInfo()
{
    // 设置列表下拉框清空
    ui->comboBoxSettings->clear();
    if(QCamera::ActiveState != m_camera->state()) {
        QMessageBox::information(this, u8"提示", u8"摄像头支持的设置列表获取失败");
        return;
    }
    // 获取当前设置信息
    QCameraViewfinderSettings setting = m_camera->viewfinderSettings();
    // 更新当前设置信息容器
    updateCameraSupportSettingsInfoBySetting(setting);

    // 遍历支持的设置容器,并在设置细腻些下拉框中添加索引
    for(int idx = 0; idx < m_camera->supportedViewfinderSettings().size(); ++idx) {
        ui->comboBoxSettings->addItem(u8"设置" + QString::number(idx));
    }
    // 将设置下拉框设置为默认设置信息对于的选项
    ui->comboBoxSettings->setCurrentIndex(m_camera->supportedViewfinderSettings().indexOf(setting));
}

void MainWindow::updateCameraSupportSettingsInfoBySetting(const QCameraViewfinderSettings &setting)
{
    // 设置信息显示清空
    ui->textBrowserSettingInfo->clear();
    // 分别添加分辨率、像素光谱比、帧率、像素格式数据
    QString resolutionStr = QString(u8"分辨率:%1, %2 ").arg(setting.resolution().width()).arg(setting.resolution().height());
    QString pixelAspectRatioStr = QString(u8"像素光谱比:%1, %2 ").arg(setting.pixelAspectRatio().width()).arg(setting.pixelAspectRatio().height());
    QString frameRateStr = QString(u8"帧率:(%1, %2) ").arg(setting.maximumFrameRate()).arg(setting.minimumFrameRate());
    QString pixelFormatStr = QString(u8"像素格式:%1 ").arg(setting.pixelFormat());
    // 信息追加显示
    ui->textBrowserSettingInfo->append(resolutionStr);
    ui->textBrowserSettingInfo->append(pixelAspectRatioStr);
    ui->textBrowserSettingInfo->append(frameRateStr);
    ui->textBrowserSettingInfo->append(pixelFormatStr);

}

void MainWindow::on_btnOpenCamera_clicked()
{
    // 当打开新相机时,释放原有相机对象,再重新创建
    if(Q_NULLPTR != m_camera) {
        delete m_camera;
        m_camera = new QCamera(m_hashCameraInfos[ui->comboBoxCameraInfo->currentText()], this);
        m_camera->setViewfinder(&m_cameraViewfinder);
        // 将栈窗口设置为相机窗口
        ui->stackedWidget->setCurrentIndex(0);
    }

    // 判断摄像头是否链接成功
    if(QCamera::NoError != m_camera->error()) {
        QMessageBox::warning(this, u8"警告", m_camera->errorString());
    }
    else {

        // 外部接入的摄像头输出“failed to find the video proc amp”
        m_camera->start();
        if(QCamera::ActiveState == m_camera->state()) {
            updateCameraSupportInfo();
            updateCameraSupportSettingsInfo();
        }
    }
}

void MainWindow::on_btnCaptureImg_clicked()
{
    // 判断摄像头状态
    if(QCamera::ActiveState != m_camera->state()) {
        QMessageBox::information(this, u8"提示", u8"摄像头未启动");
        return;
    }
    else if(!QDir().exists(ui->lineEditSavePath->text())) { // 当前设置路径不存在则提示返回
        QMessageBox::information(this, u8"提示", u8"指定保存路径无效");
        return;
    }

    // 创建相机图像捕捉对象并传入当前摄像头对象
    QCameraImageCapture imageCapture(m_camera);
    // 判断错误信息
    if(QCameraImageCapture::NoError != imageCapture.error()) {
        QMessageBox::warning(this, u8"警告", u8"出错了:" + imageCapture.errorString());
        return;
    }

    // 锁定相机配置:锁定所有支持的相机设置
    m_camera->searchAndLock();
    // 通过选择的路径和当前时间,拼接出图片保存文件路径及文件名
    QString imgFileName = ui->lineEditSavePath->text() + QDateTime::currentDateTime().toString("/yyyyMMdd-hhmmss(z)");
    // 图像截取
    if( -1 == imageCapture.capture(imgFileName)) {
        QMessageBox::information(this, u8"提示", u8"图片捕获失败 " + m_camera->errorString());
    }
    else {
        // 将保存的图片添加到右下角的图片标签中
        QTimer::singleShot(200, this, [this, imgFileName]()
        {
            // 设置图片保持比例及无锯齿效果
            ui->labelImg->setPixmap(QPixmap(imgFileName)
                                    .scaled(ui->labelImg->size(), Qt::KeepAspectRatio, Qt::SmoothTransformation));
            // 更新缩略图的路径
            ui->labelImg->setWhatsThis(imgFileName);
        });

    }
    // 解锁所有请求的摄像头锁
    m_camera->unlock();
}

void MainWindow::on_btnBaseInfo_clicked()
{
    if(QCamera::ActiveState != m_camera->state()) {
        QMessageBox::information(this, u8"提示", u8"摄像头未启动,无法获取基础信息");
        return;
    }
    // 信息容器
    QStringList infoStrList;
    // 相机基础信息依次添加
    infoStrList.append(u8"错误码:" + QString::number(m_camera->error()));
    infoStrList.append(QString(u8"错误描述:\"%1\"").arg(m_camera->errorString()));
    infoStrList.append(u8"锁定状态:" + QString::number(m_camera->lockStatus()));
    infoStrList.append(u8"当前状态1:" + QString::number(m_camera->state()));
    infoStrList.append(u8"当前状态2:" + QString::number(m_camera->status()));

    // 展示相机基础信息
    QMessageBox msg(u8"提示", infoStrList.join("\n"), QMessageBox::NoIcon
                    , QMessageBox::Ok, QMessageBox::NoButton, QMessageBox::NoButton);
    msg.exec();
}

void MainWindow::on_btnExposureInfo_clicked()
{
    if(QCamera::ActiveState != m_camera->state()) {
        QMessageBox::information(this, u8"提示", u8"摄像头未启动,无法获取曝光信息");
        return;
    }
    // 信息容器
    QStringList infoStrList;
    // 获取相机曝光对象
    QCameraExposure *exposure = m_camera->exposure();

    // 曝光信息依次添加
    infoStrList.append(u8"光圈:" + QString::number(exposure->aperture()));
    infoStrList.append(u8"曝光补偿:" + QString::number(exposure->exposureCompensation()));
    infoStrList.append(u8"等灵敏度:" + QString::number(exposure->isoSensitivity()));
          infoStrList.append(u8"快门速度:" + QString::number(exposure->shutterSpeed()));
    infoStrList.append(u8"点测量点:" + QString::number(exposure->spotMeteringPoint().x())
                   + "," + QString::number(exposure->spotMeteringPoint().y()));

    // 展示曝光信息
    QMessageBox msg(u8"提示", infoStrList.join("\n"), QMessageBox::NoIcon
                    , QMessageBox::Ok, QMessageBox::NoButton, QMessageBox::NoButton);
    msg.exec();
}

void MainWindow::on_btnCameraFocusInfo_clicked()
{
    if(QCamera::ActiveState != m_camera->state()) {
        QMessageBox::information(this, u8"提示", u8"摄像头未启动,无法获取聚焦信息");
        return;
    }
    // 信息容器
    QStringList infoStrList;
    // 获取相机聚焦对象
    QCameraFocus *focus = m_camera->focus();

    // 聚焦信息依次添加
    infoStrList.append(u8"自定义焦点:" + QString::number(focus->customFocusPoint().x())
                   + "," + QString::number(focus->customFocusPoint().y()));
    infoStrList.append(u8"数码变焦:" + QString::number(focus->digitalZoom()));
    infoStrList.append(u8"最大数码变焦:" + QString::number(focus->maximumDigitalZoom()));
    infoStrList.append(u8"光学变焦:" + QString::number(focus->opticalZoom()));
    infoStrList.append(u8"最大光学变焦:" + QString::number(focus->maximumOpticalZoom()));

    // 展示聚焦信息
    QMessageBox msg(u8"提示", infoStrList.join("\n"), QMessageBox::NoIcon
                    , QMessageBox::Ok, QMessageBox::NoButton, QMessageBox::NoButton);
    msg.exec();
}

void MainWindow::on_btnImageProcessingInfo_clicked()
{
    if(QCamera::ActiveState != m_camera->state()) {
        QMessageBox::information(this, u8"提示", u8"摄像头未启动,无法获取图片处理信息");
        return;
    }
    // 信息容器
    QStringList infoStrList;
    // 获取相机图片处理对象
    QCameraImageProcessing *focus = m_camera->imageProcessing();

    // 图片处理信息依次添加
    infoStrList.append(u8"亮度:" + QString::number(focus->brightness()));
    infoStrList.append(u8"对比度:" + QString::number(focus->contrast()));
    infoStrList.append(u8"降噪级别:" + QString::number(focus->denoisingLevel()));
    infoStrList.append(u8"手动白平衡:" + QString::number(focus->manualWhiteBalance()));
    infoStrList.append(u8"饱和度:" + QString::number(focus->saturation()));
    infoStrList.append(u8"锐化级别:" + QString::number(focus->sharpeningLevel()));

    // 展示图片处理信息
    QMessageBox msg(u8"提示", infoStrList.join("\n"), QMessageBox::NoIcon
                    , QMessageBox::Ok, QMessageBox::NoButton, QMessageBox::NoButton);
    msg.exec();
}

void MainWindow::on_btnUseCurrentSettings_clicked()
{
    if(QCamera::ActiveState != m_camera->state()) {
        QMessageBox::information(this, u8"提示", u8"摄像头未启动,无法更新设置");
    }
    else if(m_camera->viewfinderSettings()
            != m_camera->supportedViewfinderSettings().at(ui->comboBoxSettings->currentIndex())) {  // 判断当前取景器设置和将要设置的取景器设置不一致则进入
        // 根据当前取景器设置下拉框索引位置获取设置
        m_camera->setViewfinderSettings(m_camera
                                        ->supportedViewfinderSettings().at(ui->comboBoxSettings->currentIndex()));
    }
}

void MainWindow::on_comboBoxSettings_currentIndexChanged(int index)
{
    if(-1 != index) {
        // 根据设置信息下拉框切换后的索引位置获取对应的设置并更新相机设置信息
        updateCameraSupportSettingsInfoBySetting(m_camera->supportedViewfinderSettings().at(index));
    }
}

void MainWindow::on_btnSelSavePath_clicked()
{
    // 获取保存目录
    QString savePath = QFileDialog::getExistingDirectory();
    // 保存路径不为空则进入设置
    if(!savePath.isEmpty()) {
        ui->lineEditSavePath->setText(savePath);
    }
}

void MainWindow::on_btnPreviewImg_clicked(bool checked)
{
    // 更新按钮文本
    if(!checked) {
        ui->btnPreviewImg->setText(u8"预览");
        // 切换到相机窗口
        ui->stackedWidget->setCurrentIndex(0);
    }
    else if(checked && !ui->labelImg->whatsThis().isEmpty()) { // 判断是否存在可预览图像
        // 将图像显示到预览标签中并设置图片保持比例及无锯齿效果
        ui->labelImgPreview->setPixmap(QPixmap(ui->labelImg->whatsThis()).scaled(ui->labelImgPreview->size(), Qt::KeepAspectRatio, Qt::SmoothTransformation));
        ui->btnPreviewImg->setText(u8"返回");
        // 切换到预览窗口
        ui->stackedWidget->setCurrentIndex(1);
    }
    else {
        ui->btnPreviewImg->setChecked(!checked);
        QMessageBox::information(this, u8"提示", u8"暂无可预览图片");
    }
}


mainwindow.ui

<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
 <class>MainWindow</class>
 <widget class="QMainWindow" name="MainWindow">
  <property name="geometry">
   <rect>
    <x>0</x>
    <y>0</y>
    <width>1117</width>
    <height>857</height>
   </rect>
  </property>
  <property name="windowTitle">
   <string>MainWindow</string>
  </property>
  <widget class="QWidget" name="centralwidget">
   <layout class="QGridLayout" name="gridLayout_2" rowstretch="1,0,1,1,1" columnstretch="1,0">
    <item row="0" column="0" rowspan="5">
     <widget class="QWidget" name="widgetCamera" native="true">
      <property name="styleSheet">
       <string notr="true">border:2px solid rgb(112, 112, 112);</string>
      </property>
      <layout class="QVBoxLayout" name="layoutStacked">
       <property name="leftMargin">
        <number>0</number>
       </property>
       <property name="topMargin">
        <number>0</number>
       </property>
       <property name="rightMargin">
        <number>0</number>
       </property>
       <property name="bottomMargin">
        <number>0</number>
       </property>
       <item>
        <widget class="QStackedWidget" name="stackedWidget">
         <widget class="QWidget" name="page">
          <layout class="QVBoxLayout" name="layoutCamera"/>
         </widget>
         <widget class="QWidget" name="page_2">
          <layout class="QHBoxLayout" name="horizontalLayout_2">
           <item>
            <widget class="QLabel" name="labelImgPreview">
             <property name="sizePolicy">
              <sizepolicy hsizetype="Expanding" vsizetype="Expanding">
               <horstretch>0</horstretch>
               <verstretch>0</verstretch>
              </sizepolicy>
             </property>
             <property name="styleSheet">
              <string notr="true">border:none;</string>
             </property>
             <property name="text">
              <string/>
             </property>
             <property name="alignment">
              <set>Qt::AlignCenter</set>
             </property>
            </widget>
           </item>
          </layout>
         </widget>
        </widget>
       </item>
      </layout>
     </widget>
    </item>
    <item row="0" column="1">
     <widget class="QGroupBox" name="groupBox_2">
      <property name="title">
       <string>摄像头操作</string>
      </property>
      <layout class="QVBoxLayout" name="verticalLayout">
       <item>
        <widget class="QComboBox" name="comboBoxCameraInfo"/>
       </item>
       <item>
        <widget class="QPushButton" name="btnOpenCamera">
         <property name="text">
          <string>打开摄像头</string>
         </property>
        </widget>
       </item>
       <item>
        <layout class="QHBoxLayout" name="horizontalLayout">
         <item>
          <widget class="QLineEdit" name="lineEditSavePath">
           <property name="placeholderText">
            <string>请选择保存路径</string>
           </property>
          </widget>
         </item>
         <item>
          <widget class="QPushButton" name="btnSelSavePath">
           <property name="text">
            <string>选择路径</string>
           </property>
          </widget>
         </item>
        </layout>
       </item>
       <item>
        <widget class="QPushButton" name="btnCaptureImg">
         <property name="text">
          <string>拍摄</string>
         </property>
        </widget>
       </item>
      </layout>
     </widget>
    </item>
    <item row="1" column="1">
     <widget class="QGroupBox" name="groupBox">
      <property name="title">
       <string>信息展示</string>
      </property>
      <layout class="QGridLayout" name="gridLayout">
       <item row="0" column="0">
        <widget class="QPushButton" name="btnBaseInfo">
         <property name="text">
          <string>基础信息</string>
         </property>
        </widget>
       </item>
       <item row="0" column="1">
        <widget class="QPushButton" name="btnExposureInfo">
         <property name="text">
          <string>曝光信息</string>
         </property>
        </widget>
       </item>
       <item row="1" column="0">
        <widget class="QPushButton" name="btnCameraFocusInfo">
         <property name="text">
          <string>相机聚焦信息</string>
         </property>
        </widget>
       </item>
       <item row="1" column="1">
        <widget class="QPushButton" name="btnImageProcessingInfo">
         <property name="text">
          <string>图像处理信息</string>
         </property>
        </widget>
       </item>
      </layout>
     </widget>
    </item>
    <item row="2" column="1">
     <widget class="QGroupBox" name="groupBox_3">
      <property name="title">
       <string>相机支持信息</string>
      </property>
      <layout class="QGridLayout" name="gridLayout_3">
       <item row="0" column="0">
        <widget class="QTextBrowser" name="textBrowserSupportInfo"/>
       </item>
      </layout>
     </widget>
    </item>
    <item row="4" column="1">
     <widget class="QGroupBox" name="groupBox_4">
      <property name="title">
       <string>图片预览</string>
      </property>
      <layout class="QGridLayout" name="gridLayout_5">
       <item row="1" column="0">
        <widget class="QPushButton" name="btnPreviewImg">
         <property name="text">
          <string>预览</string>
         </property>
         <property name="checkable">
          <bool>true</bool>
         </property>
        </widget>
       </item>
       <item row="0" column="0">
        <widget class="QLabel" name="labelImg">
         <property name="sizePolicy">
          <sizepolicy hsizetype="Expanding" vsizetype="Expanding">
           <horstretch>0</horstretch>
           <verstretch>0</verstretch>
          </sizepolicy>
         </property>
         <property name="text">
          <string/>
         </property>
         <property name="alignment">
          <set>Qt::AlignCenter</set>
         </property>
        </widget>
       </item>
      </layout>
     </widget>
    </item>
    <item row="3" column="1">
     <widget class="QGroupBox" name="groupBox_5">
      <property name="title">
       <string>相机支持的取景器设置列表</string>
      </property>
      <layout class="QGridLayout" name="gridLayout_6">
       <item row="1" column="0">
        <widget class="QTextBrowser" name="textBrowserSettingInfo"/>
       </item>
       <item row="0" column="0">
        <widget class="QComboBox" name="comboBoxSettings"/>
       </item>
       <item row="2" column="0">
        <widget class="QPushButton" name="btnUseCurrentSettings">
         <property name="text">
          <string>使用设置</string>
         </property>
        </widget>
       </item>
      </layout>
     </widget>
    </item>
   </layout>
  </widget>
  <widget class="QMenuBar" name="menubar">
   <property name="geometry">
    <rect>
     <x>0</x>
     <y>0</y>
     <width>1117</width>
     <height>26</height>
    </rect>
   </property>
  </widget>
  <widget class="QStatusBar" name="statusbar"/>
 </widget>
 <resources/>
 <connections/>
</ui>

四、总结

  1. 需要修改相机参数,使用相机前请参考相机支持函数信息。
  2. 相机提供的几个控制对象获取函数都是只能查看不能修改。
  3. 同时,相机对象发出的信号信息也值得关注。

友情提示——哪里看不懂可私哦,让我们一起互相进步吧
(创作不易,请留下一个免费的赞叭 谢谢 ^o^/)

注:文章为作者编程过程中所遇到的问题和总结,内容仅供参考,若有错误欢迎指出。
注:如有侵权,请联系作者删除

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/2224089.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

内网穿透:如何借助Cloudflare连接没有公网的电脑的远程桌面(RDP)

内网穿透&#xff1a;如何借助Cloudflare连接没有公网的电脑的远程桌面(RDP)-含详细原理配置说明介绍 前言 远程桌面协议(RDP, Remote Desktop Protocol)可用于远程桌面连接&#xff0c;Windows系统&#xff08;家庭版除外&#xff09;也是支持这种协议的&#xff0c;无需安装…

基础数据结构——队列(链表实现,数组实现)

1.概述 计算机科学中&#xff0c;queue 是以顺序的方式维护的一组数据集合&#xff0c;在一端添加数据&#xff0c;从另一端移除数据。习惯来说&#xff0c;添加的一端称为尾&#xff0c;移除的一端称为头&#xff0c;就如同生活中的排队买商品 接口信息如下 public interfa…

Java如何实现PDF转高质量图片

大家好&#xff0c;我是 V 哥。在Java中&#xff0c;将PDF文件转换为高质量的图片可以使用不同的库&#xff0c;其中最常用的库之一是 Apache PDFBox。通过该库&#xff0c;你可以读取PDF文件&#xff0c;并将每一页转换为图像文件。为了提高图像的质量&#xff0c;你可以指定分…

卷积神经网络评价指标

1.评价指标的作用 1. 性能评估&#xff1a;评价指标提供了一种量化的方式来衡量CNN模型的性能。通过这些指标&#xff0c;我们可以了解模型在特定任务上的表现&#xff0c;比如图像分类、目标检测或图像分割等。 2. 模型比较&#xff1a;不同的模型架构或训练策略可能会产生不…

Pytest-Bdd-Playwright 系列教程(2):支持在多浏览器、多环境中执行测试

Pytest-Bdd-Playwright 系列教程&#xff08;2&#xff09;&#xff1a;支持在多浏览器、多环境中执行测试 前言一、 修改 conftest.py 文件二、创建配置文件三、修改search_steps.py文件四、运行测试 前言 学会本文教程内容后&#xff0c;你将掌握&#xff1a; 通过本文的学…

重构案例:将纯HTML/JS项目迁移到Webpack

我们已经了解了许多关于 Webpack 的知识&#xff0c;但要完全熟练掌握它并非易事。一个很好的学习方法是通过实际项目练习。当我们对 Webpack 的配置有了足够的理解后&#xff0c;就可以尝试重构一些项目。本次我选择了一个纯HTML/JS的PC项目进行重构&#xff0c;项目位于 GitH…

深度学习案例:带有一个隐藏层的平面数据分类

该案例来自吴恩达深度学习系列课程一《神经网络和深度学习》第三周编程作业&#xff0c;作业内容是设计带有一个隐藏层的平面数据分类。作业提供的资料包括测试实例&#xff08;testCases.py&#xff09;和任务功能包&#xff08;planar_utils.py&#xff09;&#xff0c;下载请…

Jetpack架构组件_LiveData组件

1.LiveData初识 LiveData:ViewModel管理要展示的数据&#xff08;VM层类似于原MVP中的P层&#xff09;&#xff0c;处理业务逻辑&#xff0c;比如调用服务器的登陆接口业务。通过LiveData观察者模式&#xff0c;只要数据的值发生了改变&#xff0c;就会自动通知VIEW层&#xf…

Flutter TextField和Button组件开发登录页面案例

In this section, we’ll go through building a basic login screen using the Button and TextField widgets. We’ll follow a step-bystep approach, allowing you to code along and understand each part of the process. Let’s get started! 在本节中&#xff0c;我们…

【Python爬虫系列】_031.Scrapy_模拟登陆中间件

课 程 推 荐我 的 个 人 主 页:👉👉 失心疯的个人主页 👈👈入 门 教 程 推 荐 :👉👉 Python零基础入门教程合集 👈👈虚 拟 环 境 搭 建 :👉👉 Python项目虚拟环境(超详细讲解) 👈👈PyQt5 系 列 教 程:👉👉 Python GUI(PyQt5)教程合集 👈👈…

ArcGIS001:ArcGIS10.2安装教程

摘要&#xff1a;本文详细介绍arcgis10.2的安装、破解、汉化过程。 一、软件下载 安装包链接&#xff1a;https://pan.baidu.com/s/1T3UJ7t_ELZ73TH2wGOcfpg?pwd08zk 提取码&#xff1a;08zk 二、安装NET Framework 3.5 双击打开控制面板&#xff0c;点击【卸载程序】&…

World of Warcraft [CLASSIC][80][the Ulduar]

Ulduar 奥杜尔副本介绍 奥杜尔共计14个BOSS&#xff0c;通常说的10H就是10个苦难模式就是全通&#xff0c;9H就是除了【观察者奥尔加隆】&#xff0c;特别说明开启【观察者奥尔加隆】&#xff0c;是需要打掉困难模式4个守护者的。 所以人们经常说的类似“10H 观察者”、“10H…

Python开发日记 -- 实现bin文件的签名

目录 1.数据的不同表现形式签名值不一样&#xff1f; 2.Binascii模块简介 3.问题定位 4.问题总结 1.数据的不同表现形式签名值不一样&#xff1f; Happy Muscle试运行了一段时间&#xff0c;组内同事再一次提出了新的需求&#xff1a;需要对bin文件签名。 PS&#xff1a;服…

react18中的函数组件底层渲染原理分析

react 中的函数组件底层渲染原理 react组件没有局部与全局之分&#xff0c;它是一个整体。这点跟vue的组件化是不同的。要实现 react 中的全局组件&#xff0c;可以将组件挂在react上&#xff0c;这样只要引入了react&#xff0c;就可以直接使用该组件。 函数式组件的创建 …

Kafka之消费者客户端

1、历史上的二个版本 与生产者客户端一样&#xff0c;在Kafka的发展过程当中&#xff0c;消费者客户端主要有两个大的版本&#xff1a; 旧消费者客户端&#xff08;Old Consumer&#xff09;&#xff1a;基于Scala语言开发的版本&#xff0c;又称为Scala消费者客户端。新消费…

【力扣】GO解决子序列相关问题

文章目录 一、引言二、动态规划方法论深度提炼子序列问题的通用解法模式 三、通用方法论应用示例&#xff1a;最长递增子序列&#xff08;LeetCode题目300&#xff09;Go 语言代码实现 四、最长连续递增序列&#xff08;LeetCode题目674&#xff09;Go 语言代码实现 五、最长重…

ffmpeg视频滤镜:定向模糊-dblur

滤镜简述 dblur 官网链接 > https://ffmpeg.org/ffmpeg-filters.html#dblur 有一个模糊滤镜&#xff0c;我试了一下&#xff0c;没有感觉到它的特殊之处, 这里简单介绍一下。 滤镜使用 滤镜的参数 angle <float> ..FV.....T. set angle (from 0 t…

找不到包的老版本???scikit-learn,numpy,scipy等等!!

废话不多说 直接上链接了&#xff1a; https://pypi.tuna.tsinghua.edu.cn/simple/https://pypi.tuna.tsinghua.edu.cn/simple/https://pypi.tuna.tsinghua.edu.cn/simple/xxx/ 后面的这个xxx就是包的名字 大家需要什么包的版本&#xff0c;直接输进去就可以啦 举个栗子&#…

零基础Java第十期:类和对象(一)

目录 一、拜访对象村 1.1. 什么是面向对象 1.2. 面向对象与面向过程 二、类定义和使用 2.1. 类的定义格式 2.2. 类的定义练习 三、类的实例化 3.1. 什么是实例化 3.2. 类和对象的说明 四、this引用 4.1. 什么是this引用 4.2. this引用的特性 一、拜访对象村 在…

<项目代码>YOLOv8路面病害识别<目标检测>

YOLOv8是一种单阶段&#xff08;one-stage&#xff09;检测算法&#xff0c;它将目标检测问题转化为一个回归问题&#xff0c;能够在一次前向传播过程中同时完成目标的分类和定位任务。相较于两阶段检测算法&#xff08;如Faster R-CNN&#xff09;&#xff0c;YOLOv8具有更高的…