关于qt:项目实战QtArmFpga医疗肾镜又名内窥镜实时影像冻结拍照白平衡九宫格

35次阅读

共计 22203 个字符,预计需要花费 56 分钟才能阅读完成。

若该文为原创文章,转载请注明原文出处
本文章博客地址:https://blog.csdn.net/qq21497936/article/details/111241205
长期继续带来更多我的项目与技术分享,征询请加 QQ:21497936、微信:yangsir198808
红瘦子 (红模拟) 的博文大全:开发技术汇合(蕴含 Qt 实用技术、树莓派、三维、OpenCV、OpenGL、ffmpeg、OSG、单片机、软硬联合等等)继续更新中…(点击传送门)

开发专栏:我的项目实战

需要

  1. 屏幕分辨率 1920 x 1080;
  2. 白平衡、解冻、主动背光、主动光源等性能;’
  2. 拍照性能,可设置拍照门路(U 盘,SD 卡,内置存储);
  3. 录像性能,可设置录像门路(U 盘,SD 卡,内置存储);
  4. 亮度调整,摄像头光源亮度调整;
  5. 物理按键,包含拍照、录像、上下左右、菜单、默认亮度、抉择等等;
  6. 定制开机界面;
  7. 照片、视频九宫格浏览控件;
  8. 照片浏览器;
  9. 视频播放器;
  10. 可查看照片、视频同时反对按键对照片和视频的操作;
  11. 对存储控件的资源浏览器控件’,并可对其复制、粘贴、删除等操作;
  12. 设置工夫日期,仿苹果滑动成果;
  13. 其余各种定制控件;

留神

  受限于老本(计划整体老本,较同行业最低),一直压缩的老本,导致该产品的呈现要害难点,其在于 fpga 上的仿 arm 跑 linux 的芯片性能等同于 2011 年的 arm 程度,通过 fpga+arm+qt 三方的代码优化和内存优化。’

Demo

  

  
  
  
  
  

软件界面

  

  

  

  
  

物理按键

  须要模仿物理按键,在整个零碎运行时对所有按键进行对应的业务解决,按键如下图:

要害代码

EndoscopeWidget.h

#ifndef ENDOSCOPEWIDGET_H
#define ENDOSCOPEWIDGET_H

#include <QWidget>
#include <QButtonGroup>
#include <QThread>
#include <QLabel>

#ifdef LINUX
#include "X264Manager.h"
extern "C" {
    #include "fpga_comm_app.h"
    #include "common.h"
}

#endif

#ifndef LINUX

#define LOCAL_DIR       ("local")
#define USB1_DIR        ("usb1")        // usb
#define USB2_DIR        ("usb2")        // usb 默认门路
#endif

#define PICTURE_DIR     ("Picture")
#define VIDEO_DIR       ("Video")

#define DEBUG_X264_SRC   (1)    // 1 - 模仿数据源测试 x264,0 - 应用 fpga 数据源操作 x264 库
#define DEBUG_SAVE_PATH  (1)    // 1 - 存储到利用目录下(arm、pc 均可用),0 - 存储到 U 盘(必须在 arm 上)#define MKDIR_USE_SHELL  (1)    // 1 - 应用 mkdir 创立目录,0 - 应用 qt 自带的创立目录(倡议应用 1)#define SKIP_FRAMES      (0)    // 1 - 是跳帧编码, 0 - 不跳帧
#define SKIP_NUM         (0)    // 跳帧时有用,以后帧数 % SKIP_NUM== 0 时跳帧

#define X264_USE_THREAD  (0)    // 1 - x264 编码应用另外的线程(须要拷贝缓存),0 - 主线程间接调用

#define CFG_FILE         ("cfg") // 配置文件

namespace Ui {class EndoscopeWidget;}

class EndoscopeWidget : public QWidget
{
    Q_OBJECT
public:
    enum LANGUAGE_TYPE {        // 语言类型
        LANGUAGE_TYPE_CHINESE_SIMPLE = 0x00,
        LANGUAGE_TYPE_ENGLISH,
        LANGUAGE_TYPE_CHINESE_TRADITION
    };
    enum SAVE_LOCATION {        // 存储地位
        SAVE_LOCATION_LOCAL = 0x00,
        SAVE_LOCATION_USB1,
        SAVE_LOCATION_USB2
    };
    enum FUNCTION_TYPE {        // 性能类型
        FUNCTION_TYPE_NO_USE = 0x00,
        FUNCTION_TYPE_PHTOTO,
        FUNCTION_TYPE_RECORD,
        FUNCTION_TYPE_FREEZE,
        FUNCTION_TYPE_WHITE_BALANCE_CORRECT
    };

public:
    explicit EndoscopeWidget(QWidget *parent = 0);
    ~EndoscopeWidget();

signals:
    void signal_recvYuv(QByteArray byteArray);

protected:
    void addFont();                                             // 增加字体
    void loadCfg();                                             // 加载配置文件
    void saveCfg();                                             // 存储配置文件
    void updateDate();                                          // 更新日期
    void updateLocateState();                                   // 更新本地 local 地位使能
    void mkdir(QString currentDir);                             // 切换存储的时候须要创立文件夹

protected:
    void paintEvent(QPaintEvent *event);
    void resizeEvent(QResizeEvent *event);

protected slots:
    void slot_labelInfoTimeOut();

protected slots:
    void slot_backgroundLightBrightnessValueChanged(int value);
    void slot_lightSourceBrightnessValueChanged(int value);

protected slots:
    void slot_dateChanged();                                    // 日期扭转更新
    void slot_languageButtonClicked(QAbstractButton *pBtn);     // 语言按钮(中文简体、English、中文繁体)
    void slot_locateLocationClicked(QAbstractButton *pBtn);     // 存储地位(本机、USB1,USB2)
    void slot_key1ButtonClicked(QAbstractButton *pBtn);         // 按键一性能(不必、拍照、录像、解冻、白平衡校对)void slot_key2ButtonClicked(QAbstractButton *pBtn);         // 按键二性能(不必、拍照、录像、解冻、白平衡校对)void slot_doubleClickedVideoFile(QString filePath);         // 双击选中视频文件

private slots:                                                  // 左侧菜单
    void on_pushButton_photograph_clicked();                    // 拍照
    void on_pushButton_record_clicked(bool checked);            // 录像
    void on_pushButton_freezeScreen_clicked(bool checked);      // 解冻
    void on_pushButton_whiteBalanceCorrect_clicked();           // 白平衡校对
    void on_pushButton_defaultLight_clicked();                  // 默认亮度
    void on_pushButton_photoSee_clicked();                      // 图片查看

private slots:                                                  // 右侧菜单
    void on_pushButton_lightSourceSet_clicked();                // 光源亮度设置
    void on_pushButton_dateSet_clicked();                       // 工夫日期设置
    void on_pushButton_languageSet_clicked();                   // 语言设置
    void on_pushButton_key1Set_clicked();                       // 按键一设置
    void on_pushButton_key2Set_clicked();                       // 按键二设置
    void on_pushButton_backgroundLightSet_clicked();            // 背光亮度设置
    void on_pushButton_photoVideoSet_clicked();                 // 照片 / 录像文件设置
    void on_pushButton_set_clicked(bool checked);               // 设置返回

private slots:                                                  // 文件操作:左侧操作图片菜单
    void on_pushButton_delete_clicked();                        // 文件操作:删除
    void on_pushButton_selectAll_clicked();                     // 文件操作:抉择所有
    void on_pushButton_copy_clicked();                          // 文件操作:复制
    void on_pushButton_paste_clicked();                         // 文件操作:粘贴
    void on_pushButton_back_clicked();                          // 文件操作:返回

private slots:
    void on_pushButton_startPlay_clicked();                     // 播放器:播放
    void on_pushButton_pause_clicked();                         // 播放器:暂停
    void on_pushButton_resume_clicked();                        // 播放器:复原
    void on_pushButton_stop_clicked();                          // 播放器:进行
    void on_pushButton_playerBack_clicked();                    // 播放器:返回


private:
    Ui::EndoscopeWidget *ui;

    QList<QString> _listCopyFile;                               // 复制的文件列表
    QButtonGroup _buttonGroupLanguage;                          // 语言选择
    QButtonGroup _buttonGroupKey1Function;                      // 按键 1 性能
    QButtonGroup _buttonGroupKey2Function;                      // 按键 2 性能
    QButtonGroup _buttonLocation;                               // 存储地位

    QString _filePath;                                          // 播放地址

    bool _isLoopSaveImageIndex;
    int _imageIndex;                                            // 当天拍照的序号(从 0 开始)bool _isLoopSaveVideoIndex;
    int _videoIndex;                                            // 当天录像的序号(从 0 开始)QString _cfgFile;                                           // 配置文件

    LANGUAGE_TYPE _language;                                    // 以后语言
    SAVE_LOCATION _saveLocation;                                // 以后存储地位
    FUNCTION_TYPE _key1Function;                                // 按键 1 性能
    FUNCTION_TYPE _key2Function;                                // 按键 2 性能
    int _backgroundLightBrightness;                             // 背光亮度
    int _lightSourceBrightness;                                 // 光源亮度

    QString _storeDir;
    QString _photoDir;                                          // 辅助变量:以后拍照文件夹
    QString _videoDir;                                          // 辅助变量:以后视频文件夹
    QString _fileName;                                          // 辅助变量:存储文件名称

#ifdef LINUX
    static QThread *_pX264ManagerThread;                        // x264 视频编码线程
    static X264Manager *_pX264Manager;                          // x264 治理类
    static int _index;
private:
    QTimer *_pTimer;
protected slots:
    void slot_timeOut();
public:
    static bool _recording;
    static int fpga_com_read_record_data_handler_t(char *buffer, int length);
#endif

    QTimer *_pTimerInfo;                                        // 计时器用于显示
    QLabel *_pLabelRecIcon;                                     // 图标
    QLabel *_pLabelRecord;                                      // 图标
    QLabel *_pLabelInfo;                                        // 提醒 Label

};

#endif // ENDOSCOPEWIDGET_H

EndoscopeWidget.cpp

#include "EndoscopeWidget.h"
#include "ui_EndoscopeWidget.h"

#include <QStyleOption>
#include <QPaintEvent>
#include <QPainter>
#include <QDebug>
#include <QDate>
#include <QFontDatabase>
#include <QButtonGroup>
#include <QProcess>
#include <QMessageBox>
#include "DateTime2Widget.h"

//#include "JpegManager.h"

#ifdef LINUX
QThread *EndoscopeWidget::_pX264ManagerThread = 0;
X264Manager *EndoscopeWidget::_pX264Manager = 0;
bool EndoscopeWidget::_recording = false;
int EndoscopeWidget::_index = 0;
#endif

EndoscopeWidget::EndoscopeWidget(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::EndoscopeWidget),
    _imageIndex(1),
    _isLoopSaveImageIndex(false),
    _videoIndex(1),
    _cfgFile(CFG_FILE),                     // 配置文件
    _language(LANGUAGE_TYPE_CHINESE_SIMPLE),// 默认语言(未加载配置文件之前)
    _saveLocation(SAVE_LOCATION_LOCAL),     // 默认存储在本地(未加载配置文件之前)
    _key1Function(FUNCTION_TYPE_NO_USE),    // 默认按键 1 无性能(未加载配置文件之前)
    _key2Function(FUNCTION_TYPE_NO_USE),    // 默认按键 2 无性能(未加载配置文件之前)
    _backgroundLightBrightness(3),
    _lightSourceBrightness(9),
    _pLabelRecIcon(0),
    _pLabelRecord(0),
    _pLabelInfo(0),
    _pTimerInfo(0),
#ifdef LINUX
    _pTimer(0),
#endif
    _isLoopSaveVideoIndex(false)
{ui->setupUi(this);

    // 加载配置文件
    loadCfg();

    // 退出自带的字体“Roboto-Condensed”addFont();

    // rec 图标和提示信息
    {_pLabelRecIcon = new QLabel(this);
        _pLabelRecIcon->setStyleSheet("border-image: url(:/images/recIcon.png);");
        _pLabelRecIcon->show();
        _pLabelRecord = new QLabel(this);
        _pLabelRecord->setStyleSheet("border-image: url(:/images/rec.png);");
        _pLabelRecord->show();
        _pLabelInfo = new QLabel(this);
        _pLabelInfo->setStyleSheet("font: 14px \" 思源黑体 \"; color: rgb(210,210,210);");
        _pLabelInfo->setAlignment(Qt::AlignVCenter | Qt::AlignLeft);
        _pLabelInfo->hide();
        _pTimerInfo = new QTimer();
        _pTimerInfo->setInterval(1500);
        connect(_pTimerInfo, SIGNAL(timeout()), this, SLOT(slot_labelInfoTimeOut()));
    }

    // 初始化图像控件的默认存储地址(无需加载)
    {//        ui->widget_camera->setPhotoDir(QString("%1/%2").arg(LOCAL_DIR).arg(PICTURE_DIR));
//        ui->widget_camera->setRecordDir(QString("%1/%2").arg(LOCAL_DIR).arg(VIDEO_DIR));
    }

    // 初始化按钮(拍照、录像、触屏解冻、白平衡校对、默认亮度、照片查看)
    {
        // 初始化按钮的图标区域
        int iconWidth = 60;
        int iconHeight = 60;
        int iconCenterX = 46;
        int iconCenterY = 63;
        QRect iconRect(iconCenterX - iconWidth / 2, iconCenterY - iconHeight / 2, iconWidth, iconHeight);
        // 初始化按钮的文字区域
        int textWidht = 236;
        int textheight = 60;
        int textCenterX = 168;
        int textCenterY = 63;
        QRect textRect(textCenterX - textWidht / 2, textCenterY - textheight / 2, textWidht, textheight);
        // 初始化按钮的字体
        QFont font = QFont();
        font.setFamily("思源黑体 CN Normal");
        font.setPixelSize(36);
        // 拍照
        ui->pushButton_photograph->setIconPixmap(QPixmap(":/images/photograph.png"));
        ui->pushButton_photograph->setIconPixmapPressed(QPixmap(":/images/photograph_pressed.png"));
        ui->pushButton_photograph->setIconPixmapDisable(QPixmap(":/images/photograph_disabled.png"));
        ui->pushButton_photograph->setIconPixmapRect(iconRect);
        ui->pushButton_photograph->setText(tr("拍照"));
        ui->pushButton_photograph->setTextRect(textRect);
        ui->pushButton_photograph->setFont(font);
        // 录像
        ui->pushButton_record->setIconPixmap(QPixmap(":/images/record.png"));
        ui->pushButton_record->setIconPixmapPressed(QPixmap(":/images/record_pressed.png"));
        ui->pushButton_record->setIconPixmapDisable(QPixmap(":/images/record_disabled.png"));
        ui->pushButton_record->setIconPixmapRect(iconRect);
        ui->pushButton_record->setText(tr("录像"));
        ui->pushButton_record->setTextRect(textRect);
        ui->pushButton_record->setFont(font);
        // 触屏解冻
        ui->pushButton_freezeScreen->setIconPixmap(QPixmap(":/images/freezeScreen.png"));
        ui->pushButton_freezeScreen->setIconPixmapPressed(QPixmap(":/images/freezeScreen_pressed.png"));
        ui->pushButton_freezeScreen->setIconPixmapDisable(QPixmap(":/images/freezeScreen_disabled.png"));
        ui->pushButton_freezeScreen->setIconPixmapRect(iconRect);
        ui->pushButton_freezeScreen->setText(tr("触屏解冻"));
        ui->pushButton_freezeScreen->setTextRect(textRect);
        ui->pushButton_freezeScreen->setFont(font);
        // 白平衡校对
        ui->pushButton_whiteBalanceCorrect->setIconPixmap(QPixmap(":/images/whiteBalanceCorrect.png"));
        ui->pushButton_whiteBalanceCorrect->setIconPixmapPressed(QPixmap(":/images/whiteBalanceCorrect_pressed.png"));
        ui->pushButton_whiteBalanceCorrect->setIconPixmapDisable(QPixmap(":/images/whiteBalanceCorrect_disabled.png"));
        ui->pushButton_whiteBalanceCorrect->setIconPixmapRect(iconRect);
        ui->pushButton_whiteBalanceCorrect->setText(tr("白平衡校对"));
        ui->pushButton_whiteBalanceCorrect->setTextRect(textRect);
        ui->pushButton_whiteBalanceCorrect->setFont(font);
        // 默认亮度
        ui->pushButton_defaultLight->setIconPixmap(QPixmap(":/images/defaultLight.png"));
        ui->pushButton_defaultLight->setIconPixmapPressed(QPixmap(":/images/defaultLight_pressed.png"));
        ui->pushButton_defaultLight->setIconPixmapDisable(QPixmap(":/images/defaultLight_disabled.png"));
        ui->pushButton_defaultLight->setIconPixmapRect(iconRect);
        ui->pushButton_defaultLight->setText(tr("默认亮度"));
        ui->pushButton_defaultLight->setTextRect(textRect);
        ui->pushButton_defaultLight->setFont(font);
        // 照片查看
        ui->pushButton_photoSee->setIconPixmap(QPixmap(":/images/photoSee.png"));
        ui->pushButton_photoSee->setIconPixmapPressed(QPixmap(":/images/photoSee_pressed.png"));
        ui->pushButton_photoSee->setIconPixmapDisable(QPixmap(":/images/photoSee_disabled.png"));
        ui->pushButton_photoSee->setIconPixmapRect(iconRect);
        ui->pushButton_photoSee->setText(tr("照片查看"));
        ui->pushButton_photoSee->setTextRect(textRect);
        ui->pushButton_photoSee->setFont(font);
    }

    // 初始化按钮(删除、复制、粘贴、抉择、返回)
    {
        int iconWidth2 = 40;
        int iconHeight2 = 40;
        int iconCenterX2 = 80;
        int iconCenterY2 = 63;
        QRect iconRect2(iconCenterX2 - iconWidth2 / 2, iconCenterY2 - iconHeight2 / 2, iconWidth2, iconHeight2);
        // 初始化按钮的文字区域
        int textWidht = 236;
        int textheight = 60;
        int textCenterX = 170;
        int textCenterY = 63;
        QRect textRect(textCenterX - textWidht / 2, textCenterY - textheight / 2, textWidht, textheight);
        // 初始化按钮的字体
        QFont font = QFont();
        font.setFamily("思源黑体 CN Normal");
        font.setPixelSize(32);
        // 删除
        ui->pushButton_delete->setIconPixmap(QPixmap(":/images/delete.png"));
        ui->pushButton_delete->setIconPixmapPressed(QPixmap(":/images/delete_pressed.png"));
        ui->pushButton_delete->setIconPixmapDisable(QPixmap(":/images/delete_disabled.png"));
        ui->pushButton_delete->setIconPixmapRect(iconRect2);
        ui->pushButton_delete->setText(tr("删 除"));
        ui->pushButton_delete->setTextRect(textRect);
        ui->pushButton_delete->setFont(font);
        // 全选
        ui->pushButton_selectAll->setIconPixmap(QPixmap(":/images/selectAll.png"));
        ui->pushButton_selectAll->setIconPixmapPressed(QPixmap(":/images/selectAll_pressed.png"));
        ui->pushButton_selectAll->setIconPixmapDisable(QPixmap(":/images/selectAll_disabled.png"));
        ui->pushButton_selectAll->setIconPixmapRect(iconRect2);
        ui->pushButton_selectAll->setText(tr("全 选"));
        ui->pushButton_selectAll->setTextRect(textRect);
        ui->pushButton_selectAll->setFont(font);
        // 复制
        ui->pushButton_copy->setIconPixmap(QPixmap(":/images/copy.png"));
        ui->pushButton_copy->setIconPixmapPressed(QPixmap(":/images/copy_pressed.png"));
        ui->pushButton_copy->setIconPixmapDisable(QPixmap(":/images/copy_disabled.png"));
        ui->pushButton_copy->setIconPixmapRect(iconRect2);
        ui->pushButton_copy->setText(tr("复 制"));
        ui->pushButton_copy->setTextRect(textRect);
        ui->pushButton_copy->setFont(font);
        // 粘贴
        ui->pushButton_paste->setIconPixmap(QPixmap(":/images/paste.png"));
        ui->pushButton_paste->setIconPixmapPressed(QPixmap(":/images/paste_pressed.png"));
        ui->pushButton_paste->setIconPixmapDisable(QPixmap(":/images/paste_disabled.png"));
        ui->pushButton_paste->setIconPixmapRect(iconRect2);
        ui->pushButton_paste->setText(tr("粘 贴"));
        ui->pushButton_paste->setTextRect(textRect);
        ui->pushButton_paste->setFont(font);
        // 返回
        ui->pushButton_back->setIconPixmap(QPixmap(":/images/back.png"));
        ui->pushButton_back->setIconPixmapPressed(QPixmap(":/images/back_pressed.png"));
        ui->pushButton_back->setIconPixmapDisable(QPixmap(":/images/delete_disabled.png"));
        ui->pushButton_back->setIconPixmapRect(iconRect2);
        ui->pushButton_back->setText(tr("返 回"));
        ui->pushButton_back->setTextRect(textRect);
        ui->pushButton_back->setFont(font);
    }

    // 初始化按钮(播放、暂停、复原、进行、返回)
    {
        // 初始化按钮的文字区域
        int textWidht = 236;
        int textheight = 60;
        int textCenterX = 170;
        int textCenterY = 63;
        QRect textRect(textCenterX - textWidht / 2, textCenterY - textheight / 2, textWidht, textheight);
        // 初始化按钮的字体
        QFont font = QFont();
        font.setFamily("思源黑体 CN Normal");
        font.setPixelSize(32);
        // 播放
        ui->pushButton_startPlay->setText(tr("播 放"));
        ui->pushButton_startPlay->setTextRect(textRect);
        ui->pushButton_startPlay->setFont(font);
        // 暂停
        ui->pushButton_pause->setText(tr("暂 停"));
        ui->pushButton_pause->setTextRect(textRect);
        ui->pushButton_pause->setFont(font);
        // 复原
        ui->pushButton_resume->setText(tr("恢 复"));
        ui->pushButton_resume->setTextRect(textRect);
        ui->pushButton_resume->setFont(font);
        // 进行
        ui->pushButton_stop->setText(tr("停 止"));
        ui->pushButton_stop->setTextRect(textRect);
        ui->pushButton_stop->setFont(font);
        // 返回
        ui->pushButton_playerBack->setText(tr("返 回"));
        ui->pushButton_playerBack->setTextRect(textRect);
        ui->pushButton_playerBack->setFont(font);
    }

    // 初始化按钮(设置){
        int iconWidth2 = 34;
        int iconHeight2 = 34;
        int iconCenterX2 = 256;
        int iconCenterY2 = 46;
        QRect iconRect2(iconCenterX2 - iconWidth2 / 2, iconCenterY2 - iconHeight2 / 2, iconWidth2, iconHeight2);
        // 初始化按钮的文字区域
        QRect textRect = ui->pushButton_set->rect();
        // 初始化按钮的字体
        QFont font = QFont();
        font.setFamily("思源黑体 CN Normal");
        font.setPixelSize(36);
        ui->pushButton_set->setIconPixmap(QPixmap(":/images/back.png"));
        ui->pushButton_set->setIconPixmapPressed(QPixmap(":/images/back_pressed.png"));
        ui->pushButton_set->setIconPixmapDisable(QPixmap(":/images/back_pressed.png"));
        ui->pushButton_set->setIconPixmapRect(iconRect2);
        ui->pushButton_set->setText(tr("设置选项"));
        ui->pushButton_set->setTextRect(textRect);
        ui->pushButton_set->setFont(font);
    }
    // 初始化各区域显示界面
    {ui->stackedWidget_leftKeys->setCurrentIndex(0);
        ui->stackedWidget_center->setCurrentIndex(0);
        ui->stackedWidget_rightKeys->setCurrentIndex(0);
    }

    // 用于模仿,关上 usb 摄像头
    {ui->widget_camera->open(0);
    }

    // 背景亮度改为 4 级(0,1,2,3)(默认为 9 级,0~8){QFont font = ui->widget_backgroundLightSlider->getFont();
        font.setFamily("思源黑体 CN Normal");
        font.setPixelSize(32);
        ui->widget_backgroundLightSlider->setAddPixmap(QPixmap(":/images/add.png"));
        ui->widget_backgroundLightSlider->setAddPixmapPressed(QPixmap(":/images/add_pressed.png"));
        ui->widget_backgroundLightSlider->setDecPixmap(QPixmap(":/images/dec.png"));
        ui->widget_backgroundLightSlider->setDecPixmapPressed(QPixmap(":/images/dec_pressed.png"));
        ui->widget_backgroundLightSlider->setFont(font);
        ui->widget_backgroundLightSlider->setMinValue(0);
        ui->widget_backgroundLightSlider->setMaxValue(3);
        ui->widget_backgroundLightSlider->setValue(_backgroundLightBrightness);
        ui->widget_backgroundLightSlider->setBackgroundPixmap(QPixmap(":/sliderWidget/images/background.png"));
        connect(ui->widget_backgroundLightSlider, SIGNAL(signal_valueChanged(int)),
                this, SLOT(slot_backgroundLightBrightnessValueChanged(int)));
    }

    // 光源亮度 9 级别(0,1,2,3,4,5,6,7,8,9)
    {QFont font = ui->widget_backgroundLightSlider->getFont();
        font.setFamily("思源黑体 CN Normal");
        font.setPixelSize(32);
        ui->widget_lightSourceSlider->setAddPixmap(QPixmap(":/images/add.png"));
        ui->widget_lightSourceSlider->setAddPixmapPressed(QPixmap(":/images/add_pressed.png"));
        ui->widget_lightSourceSlider->setDecPixmap(QPixmap(":/images/dec.png"));
        ui->widget_lightSourceSlider->setDecPixmapPressed(QPixmap(":/images/dec_pressed.png"));
        ui->widget_lightSourceSlider->setFont(font);
        ui->widget_lightSourceSlider->setMinValue(0);
        ui->widget_lightSourceSlider->setMaxValue(9);
        ui->widget_lightSourceSlider->setValue(_lightSourceBrightness);
        ui->widget_lightSourceSlider->setBackgroundPixmap(QPixmap(":/sliderWidget/images/ligthSourceBackground.png"));
        connect(ui->widget_lightSourceSlider, SIGNAL(signal_valueChanged(int)),
                this, SLOT(slot_lightSourceBrightnessValueChanged(int)));
    }

    // 语言选择
    {_buttonGroupLanguage.addButton(ui->pushButton_chineseSimple);
        _buttonGroupLanguage.addButton(ui->pushButton_english);
        _buttonGroupLanguage.addButton(ui->pushButton_chineseTradition);
        connect(&_buttonGroupLanguage, SIGNAL(buttonClicked(QAbstractButton*)), this, SLOT(slot_languageButtonClicked(QAbstractButton*)));
        switch (_language)
        {
        case LANGUAGE_TYPE_CHINESE_SIMPLE:
            ui->pushButton_chineseSimple->setChecked(true);
            break;
        case LANGUAGE_TYPE_ENGLISH:
            ui->pushButton_english->setChecked(true);
            break;
        case LANGUAGE_TYPE_CHINESE_TRADITION:
            ui->pushButton_chineseTradition->setChecked(true);
            break;
        default:
            break;
        }
    }

    // 按键 1 和 2 的性能
    {
        // 按键 1 的性能按钮
        {ui->pushButton_key1NoUse->setText(tr("不应用"));
            ui->pushButton_key1Photo->setText(tr("拍照"));
            ui->pushButton_key1Record->setText(tr("录像"));
            ui->pushButton_key1Freeze->setText(tr("解冻"));
            ui->pushButton_key1WhiteBalanceCorrect->setText(tr("白平衡校准"));

            _buttonGroupKey1Function.addButton(ui->pushButton_key1NoUse);
            _buttonGroupKey1Function.addButton(ui->pushButton_key1Photo);
            _buttonGroupKey1Function.addButton(ui->pushButton_key1Record);
            _buttonGroupKey1Function.addButton(ui->pushButton_key1Freeze);
            _buttonGroupKey1Function.addButton(ui->pushButton_key1WhiteBalanceCorrect);

            connect(&_buttonGroupKey1Function, SIGNAL(buttonClicked(QAbstractButton*)), this, SLOT(slot_key1ButtonClicked(QAbstractButton*)));

            switch (_key1Function)
            {
            case FUNCTION_TYPE_NO_USE:
                ui->pushButton_key1NoUse->setChecked(true);
                break;
            case FUNCTION_TYPE_PHTOTO:
                ui->pushButton_key1Photo->setChecked(true);
                break;
            case FUNCTION_TYPE_RECORD:
                ui->pushButton_key1Record->setChecked(true);
                break;
            case FUNCTION_TYPE_FREEZE:
                ui->pushButton_key1Freeze->setChecked(true);
                break;
            case FUNCTION_TYPE_WHITE_BALANCE_CORRECT:
                ui->pushButton_key1WhiteBalanceCorrect->setChecked(true);
                break;
            default:
                break;
            }
        }
        // 按键 2 的性能按钮
        {ui->pushButton_key2NoUse->setText(tr("不应用"));
            ui->pushButton_key2Photo->setText(tr("拍照"));
            ui->pushButton_key2Record->setText(tr("录像"));
            ui->pushButton_key2Freeze->setText(tr("解冻"));
            ui->pushButton_key2WhiteBalanceCorrect->setText(tr("白平衡校准"));

            _buttonGroupKey2Function.addButton(ui->pushButton_key2NoUse);
            _buttonGroupKey2Function.addButton(ui->pushButton_key2Photo);
            _buttonGroupKey2Function.addButton(ui->pushButton_key2Record);
            _buttonGroupKey2Function.addButton(ui->pushButton_key2Freeze);
            _buttonGroupKey2Function.addButton(ui->pushButton_key2WhiteBalanceCorrect);

            connect(&_buttonGroupKey2Function, SIGNAL(buttonClicked(QAbstractButton*)), this, SLOT(slot_key2ButtonClicked(QAbstractButton*)));

            switch (_key1Function)
            {
            case FUNCTION_TYPE_NO_USE:
                ui->pushButton_key2NoUse->setChecked(true);
                break;
            case FUNCTION_TYPE_PHTOTO:
                ui->pushButton_key2Photo->setChecked(true);
                break;
            case FUNCTION_TYPE_RECORD:
                ui->pushButton_key2Record->setChecked(true);
                break;
            case FUNCTION_TYPE_FREEZE:
                ui->pushButton_key2Freeze->setChecked(true);
                break;
            case FUNCTION_TYPE_WHITE_BALANCE_CORRECT:
                ui->pushButton_key2WhiteBalanceCorrect->setChecked(true);
                break;
            default:
                break;
            }
        }
    }

    // 存储地位抉择
    {
        // 存储地位抉择
        {ui->label_locateLocal->setText(tr("本机"));
            ui->label_locateUsb1->setText(tr("USB1"));
            ui->label_locateUsb2->setText(tr("USB2"));

            ui->label_locateLocal->setParent(ui->pushButton_locateLocal);
            ui->label_locateUsb1->setParent(ui->pushButton_locateUsb1);
            ui->label_locateUsb2->setParent(ui->pushButton_locateUsb2);

            ui->label_locateLocal->move(0, 0);
            ui->label_locateUsb1->move(0, 0);
            ui->label_locateUsb2->move(0, 0);

            ui->label_locateLocalStore->setText(QString("%1MB%2").arg(320).arg(tr("残余")));
            ui->label_locateUsb1Store->setText(QString("%1MB%2").arg(320).arg(tr("残余")));
            ui->label_locateUsb2Store->setText(QString("%1MB%2").arg(0).arg(tr("残余")));

            ui->label_locateLocalStore->setParent(ui->pushButton_locateLocal);
            ui->label_locateUsb1Store->setParent(ui->pushButton_locateUsb1);
            ui->label_locateUsb2Store->setParent(ui->pushButton_locateUsb2);

            ui->label_locateLocalStore->move(ui->pushButton_locateLocal->width() / 2, 0);
            ui->label_locateUsb1Store->move(ui->pushButton_locateUsb1->width() / 2, 0);
            ui->label_locateUsb2Store->move(ui->pushButton_locateUsb2->width() / 2, 0);

            _buttonLocation.addButton(ui->pushButton_locateLocal);
            _buttonLocation.addButton(ui->pushButton_locateUsb1);
            _buttonLocation.addButton(ui->pushButton_locateUsb2);

            connect(&_buttonLocation, SIGNAL(buttonClicked(QAbstractButton*)), this, SLOT(slot_locateLocationClicked(QAbstractButton*)));

            switch (_saveLocation)
            {
            case SAVE_LOCATION_LOCAL:
                ui->pushButton_locateLocal->setChecked(true);
                break;
            case SAVE_LOCATION_USB1:
                ui->pushButton_locateUsb1->setChecked(true);
                break;
            case SAVE_LOCATION_USB2:
                ui->pushButton_locateUsb2->setChecked(true);
                break;
            default:
                break;
            }
        }
        // 更新一下门路
        updateLocateState();}


    // 文件浏览器信号
    {ui->widget_resourceBrowser->setCols(4);
        ui->widget_resourceBrowser->setRows(4);
        connect(ui->widget_resourceBrowser, SIGNAL(signal_doubleClickedVideoFile(QString)), this, SLOT(slot_doubleClickedVideoFile(QString)));
    }


    // 工夫控件关联日期控件
    {ui->widget_time->setBackgroundPixmap(QPixmap(":/images/timeBackground.png"));
        connect(ui->widget_time, SIGNAL(signal_dateChanged()), this, SLOT(slot_dateChanged()));
    }

    // 日期控件初始化
    {QFont font = ui->widget_dateSet->getFont();
        font.setPixelSize(44);
        ui->widget_dateSet->setFont(font);
        ui->widget_dateSet->setBackgroundPixmap(QPixmap(":/images/setTimeBackground.png"));
    }

    // 工夫控件初始化
    {QFont font = ui->widget_timeSet->getFont();
        font.setPixelSize(32);
        ui->widget_timeSet->setFont(font);
        ui->widget_timeSet->setBackgroundPixmap(QPixmap(":/images/setTimeBackground.png"));
    }

    // 刷新日期
    updateDate();

#ifdef LINUX
    // 注册录像回调函数
//    fpga_comm_init(&fpga_com_read_record_data_handler_t);
    fpga_comm_init(0);
    // 初始化编码过程
    {//        _pX264ManagerThread = new QThread();
        _pX264Manager = new X264Manager();
        connect(this, SIGNAL(signal_recvYuv(QByteArray)), _pX264Manager, SLOT(slot_recvYuv(QByteArray)), Qt::QueuedConnection);
//        _pX264Manager->moveToThread(_pX264ManagerThread);
//        _pX264ManagerThread->start();}
#endif

}

EndoscopeWidget::~EndoscopeWidget()
{delete ui;}
...
#endif

正文完
 0