医工互联

 找回密码
 注册[Register]

手机动态码快速登录

手机号快速登录

微信登录

微信扫一扫,快速登录

QQ登录

只需一步,快速开始

查看: 120|回复: 0
收起左侧

案例分享:Qt+Arm+Fpga医疗肾镜(又名内窥镜)(实时影像、冻结、拍照、白

[复制链接]

  离线 

发表于 2022-11-17 23:24:43 | 显示全部楼层 |阅读模式 <
若该文为原创文章,转载请注明原文出处
本文章博客地址:https://blog.csdn.net/qq21497936/article/details/111241205
长期持续带来更多项目与技术分享,咨询请加QQ:21497936、微信:yangsir198808
红胖子(红模仿)的博文大全:开发技术集合(包含Qt实用技术、树莓派、三维、OpenCV、OpenGL、ffmpeg、OSG、单片机、软硬结合等等)持续更新中…(点击传送门)
合作案例专栏:案例分享(体验Demo可下载,只定制)


需求

  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三方的代码优化和内存优化。’

相关博客

  《案例分享:Qt+Arm基于RV1126平台的内窥镜软硬整套解决方案(实时影像、冻结、拍照、录像、背光调整、硬件光源调整,其他产品也可使用该平台,如视频监控,物联网产品等等)》

关于定制

  支持相关的软硬shang业定制(非shang业勿扰,无ye务不讨论技术细节)

Demo

  
1.gif

  
2.gif

  
3.png

  
4.png

  
5.png

软件界面
  
6.png

  
7.png

  
8.png

  
9.png

  
10.png


关键代码

EndoscopeWidget.h
  1. #ifndef ENDOSCOPEWIDGET_H
  2. #define ENDOSCOPEWIDGET_H
  3. #include <QWidget>
  4. #include <QButtonGroup>
  5. #include <QThread>
  6. #include <QLabel>
  7. #ifdef LINUX
  8. #include "X264Manager.h"
  9. extern "C" {
  10.     #include "fpga_comm_app.h"
  11.     #include "common.h"
  12. }
  13. #endif
  14. #ifndef LINUX
  15. #define LOCAL_DIR       ("local")
  16. #define USB1_DIR        ("usb1")        // usb
  17. #define USB2_DIR        ("usb2")        // usb默认路径
  18. #endif
  19. #define PICTURE_DIR     ("Picture")
  20. #define VIDEO_DIR       ("Video")
  21. #define DEBUG_X264_SRC   (1)    // 1 - 模拟数据源测试x264, 0 - 使用fpga数据源操作x264库
  22. #define DEBUG_SAVE_PATH  (1)    // 1 - 存储到应用目录下(arm、pc均可用), 0 - 存储到U盘(必须在arm上)
  23. #define MKDIR_USE_SHELL  (1)    // 1 - 使用mkdir创建目录, 0 - 使用qt自带的创建目录(建议使用1)
  24. #define SKIP_FRAMES      (0)    // 1 - 是跳帧编码, 0 - 不跳帧
  25. #define SKIP_NUM         (0)    // 跳帧时有用,当前帧数 % SKIP_NUM== 0时跳帧
  26. #define X264_USE_THREAD  (0)    // 1 - x264编码使用另外的线程(需要拷贝缓存), 0 - 主线程直接调用
  27. #define CFG_FILE         ("cfg") // 配置文件
  28. namespace Ui {
  29. class EndoscopeWidget;
  30. }
  31. class EndoscopeWidget : public QWidget
  32. {
  33.     Q_OBJECT
  34. public:
  35.     enum LANGUAGE_TYPE {        // 语言类型
  36.         LANGUAGE_TYPE_CHINESE_SIMPLE = 0x00,
  37.         LANGUAGE_TYPE_ENGLISH,
  38.         LANGUAGE_TYPE_CHINESE_TRADITION
  39.     };
  40.     enum SAVE_LOCATION {        // 存储位置
  41.         SAVE_LOCATION_LOCAL = 0x00,
  42.         SAVE_LOCATION_USB1,
  43.         SAVE_LOCATION_USB2
  44.     };
  45.     enum FUNCTION_TYPE {        // 功能类型
  46.         FUNCTION_TYPE_NO_USE = 0x00,
  47.         FUNCTION_TYPE_PHTOTO,
  48.         FUNCTION_TYPE_RECORD,
  49.         FUNCTION_TYPE_FREEZE,
  50.         FUNCTION_TYPE_WHITE_BALANCE_CORRECT
  51.     };
  52. public:
  53.     explicit EndoscopeWidget(QWidget *parent = 0);
  54.     ~EndoscopeWidget();
  55. signals:
  56.     void signal_recvYuv(QByteArray byteArray);
  57. protected:
  58.     void addFont();                                             // 添加字体
  59.     void loadCfg();                                             // 加载配置文件
  60.     void saveCfg();                                             // 存储配置文件
  61.     void updateDate();                                          // 更新日期
  62.     void updateLocateState();                                   // 更新本地local位置使能
  63.     void mkdir(QString currentDir);                             // 切换存储的时候需要创建文件夹
  64. protected:
  65.     void paintEvent(QPaintEvent *event);
  66.     void resizeEvent(QResizeEvent *event);
  67. protected slots:
  68.     void slot_labelInfoTimeOut();
  69. protected slots:
  70.     void slot_backgroundLightBrightnessValueChanged(int value);
  71.     void slot_lightSourceBrightnessValueChanged(int value);
  72. protected slots:
  73.     void slot_dateChanged();                                    // 日期改变更新
  74.     void slot_languageButtonClicked(QAbstractButton *pBtn);     // 语言按钮(中文简体、English、中文繁体)
  75.     void slot_locateLocationClicked(QAbstractButton *pBtn);     // 存储位置(本机、USB1,USB2)
  76.     void slot_key1ButtonClicked(QAbstractButton *pBtn);         // 按键一功能(不用、拍照、录像、冻结、白平衡校正)
  77.     void slot_key2ButtonClicked(QAbstractButton *pBtn);         // 按键二功能(不用、拍照、录像、冻结、白平衡校正)
  78.     void slot_doubleClickedVideoFile(QString filePath);         // 双击选中视频文件
  79. private slots:                                                  // 左侧菜单
  80.     void on_pushButton_photograph_clicked();                    // 拍照
  81.     void on_pushButton_record_clicked(bool checked);            // 录像
  82.     void on_pushButton_freezeScreen_clicked(bool checked);      // 冻结
  83.     void on_pushButton_whiteBalanceCorrect_clicked();           // 白平衡校正
  84.     void on_pushButton_defaultLight_clicked();                  // 默认亮度
  85.     void on_pushButton_photoSee_clicked();                      // 图片查看
  86. private slots:                                                  // 右侧菜单
  87.     void on_pushButton_lightSourceSet_clicked();                // 光源亮度设置
  88.     void on_pushButton_dateSet_clicked();                       // 时间日期设置
  89.     void on_pushButton_languageSet_clicked();                   // 语言设置
  90.     void on_pushButton_key1Set_clicked();                       // 按键一设置
  91.     void on_pushButton_key2Set_clicked();                       // 按键二设置
  92.     void on_pushButton_backgroundLightSet_clicked();            // 背光亮度设置
  93.     void on_pushButton_photoVideoSet_clicked();                 // 照片/录像文件设置
  94.     void on_pushButton_set_clicked(bool checked);               // 设置返回
  95. private slots:                                                  // 文件操作:左侧操作图片菜单
  96.     void on_pushButton_delete_clicked();                        // 文件操作:删除
  97.     void on_pushButton_selectAll_clicked();                     // 文件操作:选择所有
  98.     void on_pushButton_copy_clicked();                          // 文件操作:复制
  99.     void on_pushButton_paste_clicked();                         // 文件操作:粘贴
  100.     void on_pushButton_back_clicked();                          // 文件操作:返回
  101. private slots:
  102.     void on_pushButton_startPlay_clicked();                     // 播放器:播放
  103.     void on_pushButton_pause_clicked();                         // 播放器:暂停
  104.     void on_pushButton_resume_clicked();                        // 播放器:恢复
  105.     void on_pushButton_stop_clicked();                          // 播放器:停止
  106.     void on_pushButton_playerBack_clicked();                    // 播放器:返回
  107. private:
  108.     Ui::EndoscopeWidget *ui;
  109.     QList<QString> _listCopyFile;                               // 复制的文件列表
  110.     QButtonGroup _buttonGroupLanguage;                          // 语言选择
  111.     QButtonGroup _buttonGroupKey1Function;                      // 按键1功能
  112.     QButtonGroup _buttonGroupKey2Function;                      // 按键2功能
  113.     QButtonGroup _buttonLocation;                               // 存储位置
  114.     QString _filePath;                                          // 播放地址
  115.     bool _isLoopSaveImageIndex;
  116.     int _imageIndex;                                            // 当天拍照的序号(从0开始)
  117.     bool _isLoopSaveVideoIndex;
  118.     int _videoIndex;                                            // 当天录像的序号(从0开始)
  119.     QString _cfgFile;                                           // 配置文件
  120.     LANGUAGE_TYPE _language;                                    // 当前语言
  121.     SAVE_LOCATION _saveLocation;                                // 当前存储位置
  122.     FUNCTION_TYPE _key1Function;                                // 按键1功能
  123.     FUNCTION_TYPE _key2Function;                                // 按键2功能
  124.     int _backgroundLightBrightness;                             // 背光亮度
  125.     int _lightSourceBrightness;                                 // 光源亮度
  126.     QString _storeDir;
  127.     QString _photoDir;                                          // 辅助变量:当前拍照文件夹
  128.     QString _videoDir;                                          // 辅助变量:当前视频文件夹
  129.     QString _fileName;                                          // 辅助变量:存储文件名称
  130. #ifdef LINUX
  131.     static QThread *_pX264ManagerThread;                        // x264视频编码线程
  132.     static X264Manager *_pX264Manager;                          // x264管理类
  133.     static int _index;
  134. private:
  135.     QTimer *_pTimer;
  136. protected slots:
  137.     void slot_timeOut();
  138. public:
  139.     static bool _recording;
  140.     static int fpga_com_read_record_data_handler_t(char *buffer, int length);
  141. #endif
  142.     QTimer *_pTimerInfo;                                        // 计时器用于显示
  143.     QLabel *_pLabelRecIcon;                                     // 图标
  144.     QLabel *_pLabelRecord;                                      // 图标
  145.     QLabel *_pLabelInfo;                                        // 提示Label
  146. };
  147. #endif // ENDOSCOPEWIDGET_H
复制代码
EndoscopeWidget.cpp
  1. #include "EndoscopeWidget.h"
  2. #include "ui_EndoscopeWidget.h"
  3. #include <QStyleOption>
  4. #include <QPaintEvent>
  5. #include <QPainter>
  6. #include <QDebug>
  7. #include <QDate>
  8. #include <QFontDatabase>
  9. #include <QButtonGroup>
  10. #include <QProcess>
  11. #include <QMessageBox>
  12. #include "DateTime2Widget.h"
  13. //#include "JpegManager.h"
  14. #ifdef LINUX
  15. QThread *EndoscopeWidget::_pX264ManagerThread = 0;
  16. X264Manager *EndoscopeWidget::_pX264Manager = 0;
  17. bool EndoscopeWidget::_recording = false;
  18. int EndoscopeWidget::_index = 0;
  19. #endif
  20. EndoscopeWidget::EndoscopeWidget(QWidget *parent) :
  21.     QWidget(parent),
  22.     ui(new Ui::EndoscopeWidget),
  23.     _imageIndex(1),
  24.     _isLoopSaveImageIndex(false),
  25.     _videoIndex(1),
  26.     _cfgFile(CFG_FILE),                     // 配置文件
  27.     _language(LANGUAGE_TYPE_CHINESE_SIMPLE),// 默认语言(未加载配置文件之前)
  28.     _saveLocation(SAVE_LOCATION_LOCAL),     // 默认存储在本地(未加载配置文件之前)
  29.     _key1Function(FUNCTION_TYPE_NO_USE),    // 默认按键1无功能(未加载配置文件之前)
  30.     _key2Function(FUNCTION_TYPE_NO_USE),    // 默认按键2无功能(未加载配置文件之前)
  31.     _backgroundLightBrightness(3),
  32.     _lightSourceBrightness(9),
  33.     _pLabelRecIcon(0),
  34.     _pLabelRecord(0),
  35.     _pLabelInfo(0),
  36.     _pTimerInfo(0),
  37. #ifdef LINUX
  38.     _pTimer(0),
  39. #endif
  40.     _isLoopSaveVideoIndex(false)
  41. {
  42.     ui->setupUi(this);
  43.     // 加载配置文件
  44.     loadCfg();
  45.     // 加入自带的字体 “Roboto-Condensed”
  46.     addFont();
  47.     // rec图标和提示信息
  48.     {
  49.         _pLabelRecIcon = new QLabel(this);
  50.         _pLabelRecIcon->setStyleSheet("border-image: url(:/images/recIcon.png);");
  51.         _pLabelRecIcon->show();
  52.         _pLabelRecord = new QLabel(this);
  53.         _pLabelRecord->setStyleSheet("border-image: url(:/images/rec.png);");
  54.         _pLabelRecord->show();
  55.         _pLabelInfo = new QLabel(this);
  56.         _pLabelInfo->setStyleSheet("font: 14px "思源黑体"; color: rgb(210,210,210);");
  57.         _pLabelInfo->setAlignment(Qt::AlignVCenter | Qt::AlignLeft);
  58.         _pLabelInfo->hide();
  59.         _pTimerInfo = new QTimer();
  60.         _pTimerInfo->setInterval(1500);
  61.         connect(_pTimerInfo, SIGNAL(timeout()), this, SLOT(slot_labelInfoTimeOut()));
  62.     }
  63.     // 初始化图像控件的默认存储地址(无需加载)
  64.     {
  65. //        ui->widget_camera->setPhotoDir(QString("%1/%2").arg(LOCAL_DIR).arg(PICTURE_DIR));
  66. //        ui->widget_camera->setRecordDir(QString("%1/%2").arg(LOCAL_DIR).arg(VIDEO_DIR));
  67.     }
  68.     // 初始化按钮(拍照、录像、触屏冻结、白平衡校正、默认亮度、照片查看)
  69.     {
  70.         // 初始化按钮的图标区域
  71.         int iconWidth = 60;
  72.         int iconHeight = 60;
  73.         int iconCenterX = 46;
  74.         int iconCenterY = 63;
  75.         QRect iconRect(iconCenterX - iconWidth / 2, iconCenterY - iconHeight / 2, iconWidth, iconHeight);
  76.         // 初始化按钮的文字区域
  77.         int textWidht = 236;
  78.         int textheight = 60;
  79.         int textCenterX = 168;
  80.         int textCenterY = 63;
  81.         QRect textRect(textCenterX - textWidht / 2, textCenterY - textheight / 2, textWidht, textheight);
  82.         // 初始化按钮的字体
  83.         QFont font = QFont();
  84.         font.setFamily("思源黑体 CN Normal");
  85.         font.setPixelSize(36);
  86.         // 拍照
  87.         ui->pushButton_photograph->setIconPixmap(QPixmap(":/images/photograph.png"));
  88.         ui->pushButton_photograph->setIconPixmapPressed(QPixmap(":/images/photograph_pressed.png"));
  89.         ui->pushButton_photograph->setIconPixmapDisable(QPixmap(":/images/photograph_disabled.png"));
  90.         ui->pushButton_photograph->setIconPixmapRect(iconRect);
  91.         ui->pushButton_photograph->setText(tr("拍照"));
  92.         ui->pushButton_photograph->setTextRect(textRect);
  93.         ui->pushButton_photograph->setFont(font);
  94.         // 录像
  95.         ui->pushButton_record->setIconPixmap(QPixmap(":/images/record.png"));
  96.         ui->pushButton_record->setIconPixmapPressed(QPixmap(":/images/record_pressed.png"));
  97.         ui->pushButton_record->setIconPixmapDisable(QPixmap(":/images/record_disabled.png"));
  98.         ui->pushButton_record->setIconPixmapRect(iconRect);
  99.         ui->pushButton_record->setText(tr("录像"));
  100.         ui->pushButton_record->setTextRect(textRect);
  101.         ui->pushButton_record->setFont(font);
  102.         // 触屏冻结
  103.         ui->pushButton_freezeScreen->setIconPixmap(QPixmap(":/images/freezeScreen.png"));
  104.         ui->pushButton_freezeScreen->setIconPixmapPressed(QPixmap(":/images/freezeScreen_pressed.png"));
  105.         ui->pushButton_freezeScreen->setIconPixmapDisable(QPixmap(":/images/freezeScreen_disabled.png"));
  106.         ui->pushButton_freezeScreen->setIconPixmapRect(iconRect);
  107.         ui->pushButton_freezeScreen->setText(tr("触屏冻结"));
  108.         ui->pushButton_freezeScreen->setTextRect(textRect);
  109.         ui->pushButton_freezeScreen->setFont(font);
  110.         // 白平衡校正
  111.         ui->pushButton_whiteBalanceCorrect->setIconPixmap(QPixmap(":/images/whiteBalanceCorrect.png"));
  112.         ui->pushButton_whiteBalanceCorrect->setIconPixmapPressed(QPixmap(":/images/whiteBalanceCorrect_pressed.png"));
  113.         ui->pushButton_whiteBalanceCorrect->setIconPixmapDisable(QPixmap(":/images/whiteBalanceCorrect_disabled.png"));
  114.         ui->pushButton_whiteBalanceCorrect->setIconPixmapRect(iconRect);
  115.         ui->pushButton_whiteBalanceCorrect->setText(tr("白平衡校正"));
  116.         ui->pushButton_whiteBalanceCorrect->setTextRect(textRect);
  117.         ui->pushButton_whiteBalanceCorrect->setFont(font);
  118.         // 默认亮度
  119.         ui->pushButton_defaultLight->setIconPixmap(QPixmap(":/images/defaultLight.png"));
  120.         ui->pushButton_defaultLight->setIconPixmapPressed(QPixmap(":/images/defaultLight_pressed.png"));
  121.         ui->pushButton_defaultLight->setIconPixmapDisable(QPixmap(":/images/defaultLight_disabled.png"));
  122.         ui->pushButton_defaultLight->setIconPixmapRect(iconRect);
  123.         ui->pushButton_defaultLight->setText(tr("默认亮度"));
  124.         ui->pushButton_defaultLight->setTextRect(textRect);
  125.         ui->pushButton_defaultLight->setFont(font);
  126.         // 照片查看
  127.         ui->pushButton_photoSee->setIconPixmap(QPixmap(":/images/photoSee.png"));
  128.         ui->pushButton_photoSee->setIconPixmapPressed(QPixmap(":/images/photoSee_pressed.png"));
  129.         ui->pushButton_photoSee->setIconPixmapDisable(QPixmap(":/images/photoSee_disabled.png"));
  130.         ui->pushButton_photoSee->setIconPixmapRect(iconRect);
  131.         ui->pushButton_photoSee->setText(tr("照片查看"));
  132.         ui->pushButton_photoSee->setTextRect(textRect);
  133.         ui->pushButton_photoSee->setFont(font);
  134.     }
  135.     // 初始化按钮(删除、复制、粘贴、选择、返回)
  136.     {
  137.         int iconWidth2 = 40;
  138.         int iconHeight2 = 40;
  139.         int iconCenterX2 = 80;
  140.         int iconCenterY2 = 63;
  141.         QRect iconRect2(iconCenterX2 - iconWidth2 / 2, iconCenterY2 - iconHeight2 / 2, iconWidth2, iconHeight2);
  142.         // 初始化按钮的文字区域
  143.         int textWidht = 236;
  144.         int textheight = 60;
  145.         int textCenterX = 170;
  146.         int textCenterY = 63;
  147.         QRect textRect(textCenterX - textWidht / 2, textCenterY - textheight / 2, textWidht, textheight);
  148.         // 初始化按钮的字体
  149.         QFont font = QFont();
  150.         font.setFamily("思源黑体 CN Normal");
  151.         font.setPixelSize(32);
  152.         // 删除
  153.         ui->pushButton_delete->setIconPixmap(QPixmap(":/images/delete.png"));
  154.         ui->pushButton_delete->setIconPixmapPressed(QPixmap(":/images/delete_pressed.png"));
  155.         ui->pushButton_delete->setIconPixmapDisable(QPixmap(":/images/delete_disabled.png"));
  156.         ui->pushButton_delete->setIconPixmapRect(iconRect2);
  157.         ui->pushButton_delete->setText(tr("删 除"));
  158.         ui->pushButton_delete->setTextRect(textRect);
  159.         ui->pushButton_delete->setFont(font);
  160.         // 全选
  161.         ui->pushButton_selectAll->setIconPixmap(QPixmap(":/images/selectAll.png"));
  162.         ui->pushButton_selectAll->setIconPixmapPressed(QPixmap(":/images/selectAll_pressed.png"));
  163.         ui->pushButton_selectAll->setIconPixmapDisable(QPixmap(":/images/selectAll_disabled.png"));
  164.         ui->pushButton_selectAll->setIconPixmapRect(iconRect2);
  165.         ui->pushButton_selectAll->setText(tr("全 选"));
  166.         ui->pushButton_selectAll->setTextRect(textRect);
  167.         ui->pushButton_selectAll->setFont(font);
  168.         // 复制
  169.         ui->pushButton_copy->setIconPixmap(QPixmap(":/images/copy.png"));
  170.         ui->pushButton_copy->setIconPixmapPressed(QPixmap(":/images/copy_pressed.png"));
  171.         ui->pushButton_copy->setIconPixmapDisable(QPixmap(":/images/copy_disabled.png"));
  172.         ui->pushButton_copy->setIconPixmapRect(iconRect2);
  173.         ui->pushButton_copy->setText(tr("复 制"));
  174.         ui->pushButton_copy->setTextRect(textRect);
  175.         ui->pushButton_copy->setFont(font);
  176.         // 粘贴
  177.         ui->pushButton_paste->setIconPixmap(QPixmap(":/images/paste.png"));
  178.         ui->pushButton_paste->setIconPixmapPressed(QPixmap(":/images/paste_pressed.png"));
  179.         ui->pushButton_paste->setIconPixmapDisable(QPixmap(":/images/paste_disabled.png"));
  180.         ui->pushButton_paste->setIconPixmapRect(iconRect2);
  181.         ui->pushButton_paste->setText(tr("粘 贴"));
  182.         ui->pushButton_paste->setTextRect(textRect);
  183.         ui->pushButton_paste->setFont(font);
  184.         // 返回
  185.         ui->pushButton_back->setIconPixmap(QPixmap(":/images/back.png"));
  186.         ui->pushButton_back->setIconPixmapPressed(QPixmap(":/images/back_pressed.png"));
  187.         ui->pushButton_back->setIconPixmapDisable(QPixmap(":/images/delete_disabled.png"));
  188.         ui->pushButton_back->setIconPixmapRect(iconRect2);
  189.         ui->pushButton_back->setText(tr("返 回"));
  190.         ui->pushButton_back->setTextRect(textRect);
  191.         ui->pushButton_back->setFont(font);
  192.     }
  193.     // 初始化按钮(播放、暂停、恢复、停止、返回)
  194.     {
  195.         // 初始化按钮的文字区域
  196.         int textWidht = 236;
  197.         int textheight = 60;
  198.         int textCenterX = 170;
  199.         int textCenterY = 63;
  200.         QRect textRect(textCenterX - textWidht / 2, textCenterY - textheight / 2, textWidht, textheight);
  201.         // 初始化按钮的字体
  202.         QFont font = QFont();
  203.         font.setFamily("思源黑体 CN Normal");
  204.         font.setPixelSize(32);
  205.         // 播放
  206.         ui->pushButton_startPlay->setText(tr("播 放"));
  207.         ui->pushButton_startPlay->setTextRect(textRect);
  208.         ui->pushButton_startPlay->setFont(font);
  209.         // 暂停
  210.         ui->pushButton_pause->setText(tr("暂 停"));
  211.         ui->pushButton_pause->setTextRect(textRect);
  212.         ui->pushButton_pause->setFont(font);
  213.         // 恢复
  214.         ui->pushButton_resume->setText(tr("恢 复"));
  215.         ui->pushButton_resume->setTextRect(textRect);
  216.         ui->pushButton_resume->setFont(font);
  217.         // 停止
  218.         ui->pushButton_stop->setText(tr("停 止"));
  219.         ui->pushButton_stop->setTextRect(textRect);
  220.         ui->pushButton_stop->setFont(font);
  221.         // 返回
  222.         ui->pushButton_playerBack->setText(tr("返 回"));
  223.         ui->pushButton_playerBack->setTextRect(textRect);
  224.         ui->pushButton_playerBack->setFont(font);
  225.     }
  226.     // 初始化按钮(设置)
  227.     {
  228.         int iconWidth2 = 34;
  229.         int iconHeight2 = 34;
  230.         int iconCenterX2 = 256;
  231.         int iconCenterY2 = 46;
  232.         QRect iconRect2(iconCenterX2 - iconWidth2 / 2, iconCenterY2 - iconHeight2 / 2, iconWidth2, iconHeight2);
  233.         // 初始化按钮的文字区域
  234.         QRect textRect = ui->pushButton_set->rect();
  235.         // 初始化按钮的字体
  236.         QFont font = QFont();
  237.         font.setFamily("思源黑体 CN Normal");
  238.         font.setPixelSize(36);
  239.         ui->pushButton_set->setIconPixmap(QPixmap(":/images/back.png"));
  240.         ui->pushButton_set->setIconPixmapPressed(QPixmap(":/images/back_pressed.png"));
  241.         ui->pushButton_set->setIconPixmapDisable(QPixmap(":/images/back_pressed.png"));
  242.         ui->pushButton_set->setIconPixmapRect(iconRect2);
  243.         ui->pushButton_set->setText(tr("设置选项"));
  244.         ui->pushButton_set->setTextRect(textRect);
  245.         ui->pushButton_set->setFont(font);
  246.     }
  247.     // 初始化各区域显示界面
  248.     {
  249.         ui->stackedWidget_leftKeys->setCurrentIndex(0);
  250.         ui->stackedWidget_center->setCurrentIndex(0);
  251.         ui->stackedWidget_rightKeys->setCurrentIndex(0);
  252.     }
  253.     // 用于模拟,打开usb摄像头
  254.     {
  255.         ui->widget_camera->open(0);
  256.     }
  257.     // 背景亮度改为4级(0,1,2,3)(默认为9级,0~8)
  258.     {
  259.         QFont font = ui->widget_backgroundLightSlider->getFont();
  260.         font.setFamily("思源黑体 CN Normal");
  261.         font.setPixelSize(32);
  262.         ui->widget_backgroundLightSlider->setAddPixmap(QPixmap(":/images/add.png"));
  263.         ui->widget_backgroundLightSlider->setAddPixmapPressed(QPixmap(":/images/add_pressed.png"));
  264.         ui->widget_backgroundLightSlider->setDecPixmap(QPixmap(":/images/dec.png"));
  265.         ui->widget_backgroundLightSlider->setDecPixmapPressed(QPixmap(":/images/dec_pressed.png"));
  266.         ui->widget_backgroundLightSlider->setFont(font);
  267.         ui->widget_backgroundLightSlider->setMinValue(0);
  268.         ui->widget_backgroundLightSlider->setMaxValue(3);
  269.         ui->widget_backgroundLightSlider->setValue(_backgroundLightBrightness);
  270.         ui->widget_backgroundLightSlider->setBackgroundPixmap(QPixmap(":/sliderWidget/images/background.png"));
  271.         connect(ui->widget_backgroundLightSlider, SIGNAL(signal_valueChanged(int)),
  272.                 this, SLOT(slot_backgroundLightBrightnessValueChanged(int)));
  273.     }
  274.     // 光源亮度9级别(0,1,2,3,4,5,6,7,8,9)
  275.     {
  276.         QFont font = ui->widget_backgroundLightSlider->getFont();
  277.         font.setFamily("思源黑体 CN Normal");
  278.         font.setPixelSize(32);
  279.         ui->widget_lightSourceSlider->setAddPixmap(QPixmap(":/images/add.png"));
  280.         ui->widget_lightSourceSlider->setAddPixmapPressed(QPixmap(":/images/add_pressed.png"));
  281.         ui->widget_lightSourceSlider->setDecPixmap(QPixmap(":/images/dec.png"));
  282.         ui->widget_lightSourceSlider->setDecPixmapPressed(QPixmap(":/images/dec_pressed.png"));
  283.         ui->widget_lightSourceSlider->setFont(font);
  284.         ui->widget_lightSourceSlider->setMinValue(0);
  285.         ui->widget_lightSourceSlider->setMaxValue(9);
  286.         ui->widget_lightSourceSlider->setValue(_lightSourceBrightness);
  287.         ui->widget_lightSourceSlider->setBackgroundPixmap(QPixmap(":/sliderWidget/images/ligthSourceBackground.png"));
  288.         connect(ui->widget_lightSourceSlider, SIGNAL(signal_valueChanged(int)),
  289.                 this, SLOT(slot_lightSourceBrightnessValueChanged(int)));
  290.     }
  291.     // 语言选择
  292.     {
  293.         _buttonGroupLanguage.addButton(ui->pushButton_chineseSimple);
  294.         _buttonGroupLanguage.addButton(ui->pushButton_english);
  295.         _buttonGroupLanguage.addButton(ui->pushButton_chineseTradition);
  296.         connect(&_buttonGroupLanguage, SIGNAL(buttonClicked(QAbstractButton*)), this, SLOT(slot_languageButtonClicked(QAbstractButton*)));
  297.         switch (_language)
  298.         {
  299.         case LANGUAGE_TYPE_CHINESE_SIMPLE:
  300.             ui->pushButton_chineseSimple->setChecked(true);
  301.             break;
  302.         case LANGUAGE_TYPE_ENGLISH:
  303.             ui->pushButton_english->setChecked(true);
  304.             break;
  305.         case LANGUAGE_TYPE_CHINESE_TRADITION:
  306.             ui->pushButton_chineseTradition->setChecked(true);
  307.             break;
  308.         default:
  309.             break;
  310.         }
  311.     }
  312.     // 按键1和2的功能
  313.     {
  314.         // 按键1的功能按钮
  315.         {
  316.             ui->pushButton_key1NoUse->setText(tr("不使用"));
  317.             ui->pushButton_key1Photo->setText(tr("拍照"));
  318.             ui->pushButton_key1Record->setText(tr("录像"));
  319.             ui->pushButton_key1Freeze->setText(tr("冻结"));
  320.             ui->pushButton_key1WhiteBalanceCorrect->setText(tr("白平衡校准"));
  321.             _buttonGroupKey1Function.addButton(ui->pushButton_key1NoUse);
  322.             _buttonGroupKey1Function.addButton(ui->pushButton_key1Photo);
  323.             _buttonGroupKey1Function.addButton(ui->pushButton_key1Record);
  324.             _buttonGroupKey1Function.addButton(ui->pushButton_key1Freeze);
  325.             _buttonGroupKey1Function.addButton(ui->pushButton_key1WhiteBalanceCorrect);
  326.             connect(&_buttonGroupKey1Function, SIGNAL(buttonClicked(QAbstractButton*)), this, SLOT(slot_key1ButtonClicked(QAbstractButton*)));
  327.             switch (_key1Function)
  328.             {
  329.             case FUNCTION_TYPE_NO_USE:
  330.                 ui->pushButton_key1NoUse->setChecked(true);
  331.                 break;
  332.             case FUNCTION_TYPE_PHTOTO:
  333.                 ui->pushButton_key1Photo->setChecked(true);
  334.                 break;
  335.             case FUNCTION_TYPE_RECORD:
  336.                 ui->pushButton_key1Record->setChecked(true);
  337.                 break;
  338.             case FUNCTION_TYPE_FREEZE:
  339.                 ui->pushButton_key1Freeze->setChecked(true);
  340.                 break;
  341.             case FUNCTION_TYPE_WHITE_BALANCE_CORRECT:
  342.                 ui->pushButton_key1WhiteBalanceCorrect->setChecked(true);
  343.                 break;
  344.             default:
  345.                 break;
  346.             }
  347.         }
  348.         // 按键2的功能按钮
  349.         {
  350.             ui->pushButton_key2NoUse->setText(tr("不使用"));
  351.             ui->pushButton_key2Photo->setText(tr("拍照"));
  352.             ui->pushButton_key2Record->setText(tr("录像"));
  353.             ui->pushButton_key2Freeze->setText(tr("冻结"));
  354.             ui->pushButton_key2WhiteBalanceCorrect->setText(tr("白平衡校准"));
  355.             _buttonGroupKey2Function.addButton(ui->pushButton_key2NoUse);
  356.             _buttonGroupKey2Function.addButton(ui->pushButton_key2Photo);
  357.             _buttonGroupKey2Function.addButton(ui->pushButton_key2Record);
  358.             _buttonGroupKey2Function.addButton(ui->pushButton_key2Freeze);
  359.             _buttonGroupKey2Function.addButton(ui->pushButton_key2WhiteBalanceCorrect);
  360.             connect(&_buttonGroupKey2Function, SIGNAL(buttonClicked(QAbstractButton*)), this, SLOT(slot_key2ButtonClicked(QAbstractButton*)));
  361.             switch (_key1Function)
  362.             {
  363.             case FUNCTION_TYPE_NO_USE:
  364.                 ui->pushButton_key2NoUse->setChecked(true);
  365.                 break;
  366.             case FUNCTION_TYPE_PHTOTO:
  367.                 ui->pushButton_key2Photo->setChecked(true);
  368.                 break;
  369.             case FUNCTION_TYPE_RECORD:
  370.                 ui->pushButton_key2Record->setChecked(true);
  371.                 break;
  372.             case FUNCTION_TYPE_FREEZE:
  373.                 ui->pushButton_key2Freeze->setChecked(true);
  374.                 break;
  375.             case FUNCTION_TYPE_WHITE_BALANCE_CORRECT:
  376.                 ui->pushButton_key2WhiteBalanceCorrect->setChecked(true);
  377.                 break;
  378.             default:
  379.                 break;
  380.             }
  381.         }
  382.     }
  383.     // 存储位置选择
  384.     {
  385.         // 存储位置选择
  386.         {
  387.             ui->label_locateLocal->setText(tr("本机"));
  388.             ui->label_locateUsb1->setText(tr("USB1"));
  389.             ui->label_locateUsb2->setText(tr("USB2"));
  390.             ui->label_locateLocal->setParent(ui->pushButton_locateLocal);
  391.             ui->label_locateUsb1->setParent(ui->pushButton_locateUsb1);
  392.             ui->label_locateUsb2->setParent(ui->pushButton_locateUsb2);
  393.             ui->label_locateLocal->move(0, 0);
  394.             ui->label_locateUsb1->move(0, 0);
  395.             ui->label_locateUsb2->move(0, 0);
  396.             ui->label_locateLocalStore->setText(QString("%1MB%2").arg(320).arg(tr("剩余")));
  397.             ui->label_locateUsb1Store->setText(QString("%1MB%2").arg(320).arg(tr("剩余")));
  398.             ui->label_locateUsb2Store->setText(QString("%1MB%2").arg(0).arg(tr("剩余")));
  399.             ui->label_locateLocalStore->setParent(ui->pushButton_locateLocal);
  400.             ui->label_locateUsb1Store->setParent(ui->pushButton_locateUsb1);
  401.             ui->label_locateUsb2Store->setParent(ui->pushButton_locateUsb2);
  402.             ui->label_locateLocalStore->move(ui->pushButton_locateLocal->width() / 2, 0);
  403.             ui->label_locateUsb1Store->move(ui->pushButton_locateUsb1->width() / 2, 0);
  404.             ui->label_locateUsb2Store->move(ui->pushButton_locateUsb2->width() / 2, 0);
  405.             _buttonLocation.addButton(ui->pushButton_locateLocal);
  406.             _buttonLocation.addButton(ui->pushButton_locateUsb1);
  407.             _buttonLocation.addButton(ui->pushButton_locateUsb2);
  408.             connect(&_buttonLocation, SIGNAL(buttonClicked(QAbstractButton*)), this, SLOT(slot_locateLocationClicked(QAbstractButton*)));
  409.             switch (_saveLocation)
  410.             {
  411.             case SAVE_LOCATION_LOCAL:
  412.                 ui->pushButton_locateLocal->setChecked(true);
  413.                 break;
  414.             case SAVE_LOCATION_USB1:
  415.                 ui->pushButton_locateUsb1->setChecked(true);
  416.                 break;
  417.             case SAVE_LOCATION_USB2:
  418.                 ui->pushButton_locateUsb2->setChecked(true);
  419.                 break;
  420.             default:
  421.                 break;
  422.             }
  423.         }
  424.         // 更新一下路径
  425.         updateLocateState();
  426.     }
  427.     // 文件浏览器信号
  428.     {
  429.         ui->widget_resourceBrowser->setCols(4);
  430.         ui->widget_resourceBrowser->setRows(4);
  431.         connect(ui->widget_resourceBrowser, SIGNAL(signal_doubleClickedVideoFile(QString)), this, SLOT(slot_doubleClickedVideoFile(QString)));
  432.     }
  433.     // 时间控件关联日期控件
  434.     {
  435.         ui->widget_time->setBackgroundPixmap(QPixmap(":/images/timeBackground.png"));
  436.         connect(ui->widget_time, SIGNAL(signal_dateChanged()), this, SLOT(slot_dateChanged()));
  437.     }
  438.     // 日期控件初始化
  439.     {
  440.         QFont font = ui->widget_dateSet->getFont();
  441.         font.setPixelSize(44);
  442.         ui->widget_dateSet->setFont(font);
  443.         ui->widget_dateSet->setBackgroundPixmap(QPixmap(":/images/setTimeBackground.png"));
  444.     }
  445.     // 时间控件初始化
  446.     {
  447.         QFont font = ui->widget_timeSet->getFont();
  448.         font.setPixelSize(32);
  449.         ui->widget_timeSet->setFont(font);
  450.         ui->widget_timeSet->setBackgroundPixmap(QPixmap(":/images/setTimeBackground.png"));
  451.     }
  452.     // 刷新日期
  453.     updateDate();
  454. #ifdef LINUX
  455.     // 注册录像回调函数
  456. //    fpga_comm_init(&fpga_com_read_record_data_handler_t);
  457.     fpga_comm_init(0);
  458.     // 初始化编码进程
  459.     {
  460. //        _pX264ManagerThread = new QThread();
  461.         _pX264Manager = new X264Manager();
  462.         connect(this, SIGNAL(signal_recvYuv(QByteArray)), _pX264Manager, SLOT(slot_recvYuv(QByteArray)), Qt::QueuedConnection);
  463. //        _pX264Manager->moveToThread(_pX264ManagerThread);
  464. //        _pX264ManagerThread->start();
  465.     }
  466. #endif
  467. }
  468. EndoscopeWidget::~EndoscopeWidget()
  469. {
  470.     delete ui;
  471. }
  472. ...
  473. #endif
复制代码

若该文为原创文章,转载请注明原文出处
本文章博客地址:https://blog.csdn.net/qq21497936/article/details/111241205

来源:https://blog.csdn.net/qq21497936/article/details/111241205
免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!
回复

使用道具 举报

提醒:禁止复制他人回复等『恶意灌水』行为,违者重罚!
您需要登录后才可以回帖 登录 | 注册[Register] 手机动态码快速登录 微信登录

本版积分规则

发布主题 快速回复 收藏帖子 返回列表 客服中心 搜索
简体中文 繁體中文 English 한국 사람 日本語 Deutsch русский بالعربية TÜRKÇE português คนไทย french

QQ|RSS订阅|小黑屋|处罚记录|手机版|联系我们|Archiver|医工互联 |粤ICP备2021178090号 |网站地图

GMT+8, 2024-9-20 11:47 , Processed in 0.269795 second(s), 63 queries .

Powered by Discuz!

Copyright © 2001-2023, Discuz! Team.

快速回复 返回顶部 返回列表