美文网首页
项目实战:Qt+Arm+Fpga医疗肾镜(又名内窥镜)(实时影像

项目实战:Qt+Arm+Fpga医疗肾镜(又名内窥镜)(实时影像

作者: 红模仿_红胖子 | 来源:发表于2020-12-18 20:06 被阅读0次

若该文为原创文章,转载请注明原文出处

本文章博客地址: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

若该文为原创文章,转载请注明原文出处

本文章博客地址:https://blog.csdn.net/qq21497936/article/details/111241205

相关文章

网友评论

      本文标题:项目实战:Qt+Arm+Fpga医疗肾镜(又名内窥镜)(实时影像

      本文链接:https://www.haomeiwen.com/subject/lhufnktx.html