若該文為原創文章,轉載請注明原文出處
本文章博客地址: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
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/237154.html
標籤:其他
上一篇:鄰接矩陣:BFS實作拓撲排序(實作輸入兩種格式的圖的輸入函式)(為什么總是出現RE)(一道題試怎么讓一個程式員枯萎的,又是怎么起死回生的)
下一篇:DDR3 MIG測驗記錄
