修改分包接收前板发的YUV数据,取图成功后保存YUV图和JPG图

This commit is contained in:
钟富强 2024-09-03 15:58:23 +08:00
parent 15eb213578
commit c6e16094b9
18 changed files with 3799 additions and 123 deletions

View File

@ -138,6 +138,9 @@
<ClInclude Include="SourceCode\Media\VideoDecoder\RingBuffer.h" /> <ClInclude Include="SourceCode\Media\VideoDecoder\RingBuffer.h" />
<QtMoc Include="SourceCode\Network\DelUserWindows.h" /> <QtMoc Include="SourceCode\Network\DelUserWindows.h" />
</ItemGroup> </ItemGroup>
<ItemGroup>
<ResourceCompile Include="icon.rc" />
</ItemGroup>
<PropertyGroup Label="Globals"> <PropertyGroup Label="Globals">
<ProjectGuid>{2C8A5A59-2E79-4283-A0ED-D70DB305557E}</ProjectGuid> <ProjectGuid>{2C8A5A59-2E79-4283-A0ED-D70DB305557E}</ProjectGuid>
<Keyword>QtVS_v304</Keyword> <Keyword>QtVS_v304</Keyword>

View File

@ -309,4 +309,7 @@
<Filter>Network\mdns\qmdnsengine\include</Filter> <Filter>Network\mdns\qmdnsengine\include</Filter>
</ClInclude> </ClInclude>
</ItemGroup> </ItemGroup>
<ItemGroup>
<ResourceCompile Include="icon.rc" />
</ItemGroup>
</Project> </Project>

BIN
FactoryTestTool/Icon96.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 546 KiB

View File

@ -13,6 +13,85 @@ void yuvToRgb(int y, int u, int v, int& r, int& g, int& b)
b = qBound(0, b, 255); b = qBound(0, b, 255);
} }
// 将 QImage 数据转换为 YUV422
QByteArray convertQImageToYUV422(const QImage& image)
{
int width = image.width();
int height = image.height();
QByteArray yuvData;
yuvData.resize(width * height * 2); // YUV422: 每个像素2字节
int index = 0;
for (int y = 0; y < height; ++y) {
for (int x = 0; x < width; x += 2) {
QRgb pixel0 = image.pixel(x, y);
QRgb pixel1 = image.pixel(x + 1, y);
int r0 = qRed(pixel0);
int g0 = qGreen(pixel0);
int b0 = qBlue(pixel0);
int r1 = qRed(pixel1);
int g1 = qGreen(pixel1);
int b1 = qBlue(pixel1);
// 计算YUV值
int y0 = (0.299 * r0 + 0.587 * g0 + 0.114 * b0);
int u = (-0.169 * r0 - 0.331 * g0 + 0.5 * b0 + 128);
int y1 = (0.299 * r1 + 0.587 * g1 + 0.114 * b1);
int v = (0.5 * r0 - 0.419 * g0 - 0.081 * b0 + 128);
yuvData[index++] = static_cast<char>(qBound(0, y0, 255));
yuvData[index++] = static_cast<char>(qBound(0, u, 255));
yuvData[index++] = static_cast<char>(qBound(0, y1, 255));
yuvData[index++] = static_cast<char>(qBound(0, v, 255));
}
}
return yuvData;
}
// 将 QImage 数据转换为 YUV420
QByteArray convertQImageToYUV420(const QImage& image)
{
int width = image.width();
int height = image.height();
QByteArray yuvData;
int ySize = width * height;
int uvSize = (width / 2) * (height / 2);
yuvData.resize(ySize + 2 * uvSize); // Y 分量 + U 分量 + V 分量
int yIndex = 0;
int uIndex = ySize;
int vIndex = ySize + uvSize;
for (int y = 0; y < height; y++) {
for (int x = 0; x < width; x++) {
QRgb pixel = image.pixel(x, y);
int r = qRed(pixel);
int g = qGreen(pixel);
int b = qBlue(pixel);
// 计算 YUV 值
int Y = qBound(0, static_cast<int>(0.299 * r + 0.587 * g + 0.114 * b), 255);
int U = qBound(0, static_cast<int>(-0.169 * r - 0.331 * g + 0.5 * b + 128), 255);
int V = qBound(0, static_cast<int>(0.5 * r - 0.419 * g - 0.081 * b + 128), 255);
// 填充 Y 分量
yuvData[yIndex++] = static_cast<char>(Y);
// 对 U 和 V 分量进行抽样
if (y % 2 == 0 && x % 2 == 0) {
yuvData[uIndex++] = static_cast<char>(U);
yuvData[vIndex++] = static_cast<char>(V);
}
}
}
return yuvData;
}
// 将 YUV422 数据转换为 QImage // 将 YUV422 数据转换为 QImage
QImage convertYUV422ToQImage(const QByteArray& yuv422Data, int width, int height) QImage convertYUV422ToQImage(const QByteArray& yuv422Data, int width, int height)
{ {
@ -72,29 +151,21 @@ QImage convertYUV420ToQImage(const QByteArray& yuv420Data, int width, int height
return image; return image;
} }
void showPic(QLabel* leftLens_m_imageLabel, QLabel* rightLens_m_imageLabel, const QString& client, const QByteArray& valData) void DataHandler::showPic(QSize labelSize, int lens_n,
int width, int height, int format, const QByteArray* valData)
{ {
int lens_n = static_cast<unsigned char>(valData[0]); //QByteArray yuvData = valData.mid(6);
int width = (static_cast<unsigned char>(valData[2]) << 8) | static_cast<unsigned char>(valData[1]); qDebug() << "yuvData size = " << valData->size();
int height = (static_cast<unsigned char>(valData[4]) << 8) | static_cast<unsigned char>(valData[3]);
int format = static_cast<unsigned char>(valData[5]);
qDebug() << "lens_n = " << lens_n;
qDebug() << "format = " << format;
qDebug() << "width = " << width;
qDebug() << "height = " << height;
QByteArray yuvData = valData.mid(6);
qDebug() << "yuvData size = " << yuvData.size();
QImage image; QImage image;
if (format == YUV422) { if (format == YUV422) {
image = convertYUV422ToQImage(yuvData, width, height); image = convertYUV422ToQImage(*valData, width, height);
} }
else if (format == YUV420) { else if (format == YUV420) {
image = convertYUV420ToQImage(yuvData, width, height); image = convertYUV420ToQImage(*valData, width, height);
} }
else { else {
qWarning() << "Unsupported image format!"; qWarning() << "Unsupported image format! Please use YUV422 or YUV420 format";
return; return;
} }
@ -103,16 +174,48 @@ void showPic(QLabel* leftLens_m_imageLabel, QLabel* rightLens_m_imageLabel, cons
transform.rotate(90); // 可以调整旋转角度 transform.rotate(90); // 可以调整旋转角度
QImage rotatedImage = image.transformed(transform); QImage rotatedImage = image.transformed(transform);
QImage scaledImage = rotatedImage.scaled(leftLens_m_imageLabel->size(), Qt::KeepAspectRatio); QImage scaledImage = rotatedImage.scaled(labelSize, Qt::KeepAspectRatio);
QPixmap pixmap = QPixmap::fromImage(scaledImage);
if (lens_n == 0) { if (lens_n == 0) {
leftLens_m_imageLabel->setPixmap(QPixmap::fromImage(scaledImage)); //leftLens_m_imageLabel->setPixmap(QPixmap::fromImage(scaledImage));
//rightLens_m_imageLabel->setPixmap(QPixmap::fromImage(scaledImage)); emit updateLeftLensImage(pixmap);
} }
else if (lens_n == 1) { else if (lens_n == 1) {
rightLens_m_imageLabel->setPixmap(QPixmap::fromImage(scaledImage)); //rightLens_m_imageLabel->setPixmap(QPixmap::fromImage(scaledImage));
emit updateRightLensImage(pixmap);
} }
else { else {
qWarning() << "Unsupported image lens!"; qWarning() << "Unsupported image lens!";
} }
// 生成保存图片的目录
QString saveDirPath = QDir::currentPath() + "/frontBoardImage";
QDir saveDir(saveDirPath);
if (!saveDir.exists()) {
saveDir.mkpath(saveDirPath);
}
QString currentTime = QDateTime::currentDateTime().toString("yyyyMMdd_HHmmss");
QByteArray rotatedYuvData;
if (format == YUV422) {
rotatedYuvData = convertQImageToYUV422(rotatedImage);
}
else if (format == YUV420) {
rotatedYuvData = convertQImageToYUV420(rotatedImage);
}
QString yuvFileName = saveDirPath + "/" + currentTime + ".yuv";
QFile yuvFile(yuvFileName);
if (yuvFile.open(QIODevice::WriteOnly)) {
yuvFile.write(rotatedYuvData);
yuvFile.close();
qDebug() << "YUV image saved to" << yuvFileName;
}
else {
qWarning() << "Failed to save rotated YUV image to" << yuvFileName;
}
// 额外可以保存旋转后的图像为JPG或PNG格式
QString rotatedImageFileName = saveDirPath + "/" + currentTime + ".jpg";
rotatedImage.save(rotatedImageFileName, "JPG");
qDebug() << "JPG image saved to" << rotatedImageFileName;
} }

View File

@ -7,18 +7,18 @@
#include <QLabel> #include <QLabel>
#include <QDebug> #include <QDebug>
#include "../RecvDataHandler/RecvDataHandler.h"
#define YUV420 1 #define YUV420 1
#define YUV422 2 #define YUV422 2
// YUV 转换为 RGB 的辅助函数 // YUV 转换为 RGB 的辅助函数
void yuvToRgb(int y, int u, int v, int& r, int& g, int& b); void yuvToRgb(int y, int u, int v, int& r, int& g, int& b);
QByteArray convertQImageToYUV422(const QImage& image);
QByteArray convertQImageToYUV420(const QImage& image);
// 转换YUV422 // 转换YUV422
QImage convertYUV422ToQImage(const QByteArray& yuv422Data, int width, int height); QImage convertYUV422ToQImage(const QByteArray& yuv422Data, int width, int height);
QImage convertYUV420ToQImage(const QByteArray& yuv420Data, int width, int height); QImage convertYUV420ToQImage(const QByteArray& yuv420Data, int width, int height);
// 显示图片和视频的函数
void showPic(QLabel* leftLens_m_imageLabel, QLabel* rightLens_m_imageLabel, const QString& client, const QByteArray& valData);
//void showVideo(QLabel* videoLabel, const QString& client, const QByteArray& valData);
#endif // MEDIA_H #endif // MEDIA_H

View File

@ -11,16 +11,16 @@ FFmpegDecoder::FFmpegDecoder(QObject* parent) :
frame(nullptr), frame(nullptr),
packet(nullptr), packet(nullptr),
swsContext(nullptr), swsContext(nullptr),
videoStreamIndex(-1) // 初始化成员变量 videoStreamIndex(-1)
{ {
av_log_set_level(AV_LOG_QUIET); // 设置日志级别为安静模式 av_log_set_level(AV_LOG_QUIET); // 设置日志级别为安静模式
avformat_network_init(); // 初始化网络 avformat_network_init(); // 初始化网络
qDebug() << "FFmpegDecoder created"; qDebug() << "FFmpegDecoder thread created";
} }
FFmpegDecoder::~FFmpegDecoder() FFmpegDecoder::~FFmpegDecoder()
{ {
qDebug() << "Destroying FFmpegDecoder"; qDebug() << "Destroying FFmpegDecoder thread";
mutex.lock(); mutex.lock();
abort = true; abort = true;
condition.wakeOne(); condition.wakeOne();
@ -28,7 +28,7 @@ FFmpegDecoder::~FFmpegDecoder()
wait(); wait();
cleanup(); cleanup();
avformat_network_deinit(); // 反初始化网络 avformat_network_deinit(); // 反初始化网络
qDebug() << "FFmpegDecoder destroyed"; qDebug() << "FFmpegDecoder thread destroyed";
} }
void FFmpegDecoder::processVideo(int itemIndex) void FFmpegDecoder::processVideo(int itemIndex)
@ -72,7 +72,7 @@ void FFmpegDecoder::stopFFmpegDecoder()
{ {
mutex.lock(); mutex.lock();
abort = true; abort = true;
condition.wakeOne(); // 唤醒等待的线程 condition.wakeOne();
mutex.unlock(); mutex.unlock();
} }
@ -134,10 +134,8 @@ void FFmpegDecoder::run()
if (currentFileSize > fileSize) { if (currentFileSize > fileSize) {
fileSize = currentFileSize; fileSize = currentFileSize;
file.seek(fileSize); // 设置文件读取位置到末尾 file.seek(fileSize); // 设置文件读取位置到末尾
//qDebug() << "---------------1---------------";
// 读取并处理数据包 // 读取并处理数据包
while (av_read_frame(formatContext, packet) >= 0) { while (av_read_frame(formatContext, packet) >= 0) {
//qDebug() << "---------------2---------------";
if (packet->stream_index == videoStreamIndex) { if (packet->stream_index == videoStreamIndex) {
int ret = avcodec_send_packet(codecContext, packet); int ret = avcodec_send_packet(codecContext, packet);
if (ret < 0) { if (ret < 0) {
@ -145,7 +143,6 @@ void FFmpegDecoder::run()
av_packet_unref(packet); av_packet_unref(packet);
continue; continue;
} }
//qDebug() << "---------------3---------------";
while (ret >= 0) { while (ret >= 0) {
ret = avcodec_receive_frame(codecContext, frame); ret = avcodec_receive_frame(codecContext, frame);
if (ret == AVERROR(EAGAIN) || ret == AVERROR_EOF) { if (ret == AVERROR(EAGAIN) || ret == AVERROR_EOF) {
@ -156,31 +153,23 @@ void FFmpegDecoder::run()
qWarning() << "Error during decoding"; qWarning() << "Error during decoding";
break; break;
} }
//qDebug() << "---------------4---------------";
QImage img = avFrameToQImage(frame); QImage img = avFrameToQImage(frame);
//qDebug() << "---------------5---------------";
QImage scaledImage = img.scaled(labelSize, Qt::KeepAspectRatio, Qt::SmoothTransformation); QImage scaledImage = img.scaled(labelSize, Qt::KeepAspectRatio, Qt::SmoothTransformation);
//qDebug() << "---------------6---------------";
currentVideoLabel->setPixmap(QPixmap::fromImage(scaledImage)); currentVideoLabel->setPixmap(QPixmap::fromImage(scaledImage));
QThread::msleep(10); // Simulate 25 FPS frame rate QThread::msleep(10); // Simulate 25 FPS frame rate
//qDebug() << "---------------7---------------";
} }
} }
av_packet_unref(packet); av_packet_unref(packet);
//qDebug() << "---------------8---------------";
} }
} }
//qDebug() << "---------------9---------------";
mutex.lock(); mutex.lock();
if (restart) { if (restart) {
restart = false; restart = false;
mutex.unlock(); mutex.unlock();
break; break;
} }
//qDebug() << "---------------10---------------";
mutex.unlock(); mutex.unlock();
} }
//qDebug() << "---------------11---------------";
cleanup(); cleanup();
file.close(); file.close();

View File

@ -142,13 +142,11 @@ void ClientHandler::sendJsonItem(const QJsonArray& jsonArray, int itemIndex, con
isClickedSend = true; isClickedSend = true;
isRecvImgData = false; isRecvImgData = false;
if (itemType == "handleVideo") { if (itemType == "handleVideo") {
if (itemIndex == 0) { if (itemIndex == 0) {
qDebug() << "0 itemIndex: " << itemIndex;
isSingleSend = false; isSingleSend = false;
isClickedSend = false; isClickedSend = false;
} }
else { else {
qDebug() << "!0 itemIndex: " << itemIndex;
stopReadVideoDataTimer(preVideoClientId); stopReadVideoDataTimer(preVideoClientId);
} }
} }
@ -157,8 +155,8 @@ void ClientHandler::sendJsonItem(const QJsonArray& jsonArray, int itemIndex, con
isClickedSend = false; isClickedSend = false;
isRecvImgData = true; isRecvImgData = true;
} }
qDebug() << "itemIndex" << itemIndex; //qDebug() << "itemIndex" << itemIndex;
qDebug() << "jsonArray.size()" << jsonArray.size(); //qDebug() << "jsonArray.size()" << jsonArray.size();
if (itemIndex >= 0 && itemIndex < jsonArray.size()) { if (itemIndex >= 0 && itemIndex < jsonArray.size()) {
currentItemIndex = (itemType == "test") ? itemIndex : 0; currentItemIndex = (itemType == "test") ? itemIndex : 0;
currentFuncItemIndex = (itemType == "func") ? itemIndex : 0; currentFuncItemIndex = (itemType == "func") ? itemIndex : 0;
@ -210,7 +208,6 @@ void ClientHandler::sendGetPicItem(int itemIndex, int GetPicCamIndex)
void ClientHandler::sendGetVideoItem(int itemIndex, int GetVideoCamIndex) void ClientHandler::sendGetVideoItem(int itemIndex, int GetVideoCamIndex)
{ {
qDebug() << "sendGetVideoItem itemIndex:" << itemIndex; qDebug() << "sendGetVideoItem itemIndex:" << itemIndex;
qDebug() << "sendGetVideoItem GetVideoCamIndex:" << GetVideoCamIndex;
if(isBackBoardOrAllBoard) { if(isBackBoardOrAllBoard) {
sendJsonItem(getVideoJson, itemIndex, QString::number(GetVideoCamIndex), "handleVideo"); sendJsonItem(getVideoJson, itemIndex, QString::number(GetVideoCamIndex), "handleVideo");
} }
@ -521,7 +518,7 @@ void ClientHandler::setThreadPriority(QThread::Priority priority) {
QThread* thread = QThread::currentThread(); QThread* thread = QThread::currentThread();
if (thread) { if (thread) {
thread->setPriority(priority); thread->setPriority(priority);
qDebug() << "Thread priority set to" << priority << "for clientId:" << clientId; //qDebug() << "Thread priority set to" << priority << "for clientId:" << clientId;
} }
else { else {
qWarning() << "Failed to set thread priority. Current thread is null."; qWarning() << "Failed to set thread priority. Current thread is null.";
@ -531,7 +528,6 @@ void ClientHandler::setThreadPriority(QThread::Priority priority) {
// 处理数据接收 // 处理数据接收
void ClientHandler::onDataReceived() void ClientHandler::onDataReceived()
{ {
// 接收其他数据 添加区分 视频与其他数据 的标志位
//qDebug() << "isRecvVideoData:" << isRecvVideoData; //qDebug() << "isRecvVideoData:" << isRecvVideoData;
//qDebug() << "isPowerOnSend:" << isPowerOnSend; //qDebug() << "isPowerOnSend:" << isPowerOnSend;
//qDebug() << "isClickedSend:" << isClickedSend; //qDebug() << "isClickedSend:" << isClickedSend;
@ -556,20 +552,16 @@ void ClientHandler::onDataReceived()
emit startTimeout(0); emit startTimeout(0);
} }
if (!allData.isEmpty()) { if (!allData.isEmpty()) {
//emit dataReceived(getClientAddress(), allData, 0xFF, currentItemIndex, currentFuncItemIndex, "", "");
emit dataReceived(getClientAddress(), allData, 0xFF, currentItemIndex, currentFuncItemIndex, getCurrentItemLable(), "", currentJson, currentJsonItem); emit dataReceived(getClientAddress(), allData, 0xFF, currentItemIndex, currentFuncItemIndex, getCurrentItemLable(), "", currentJson, currentJsonItem);
if (!isSingleSend && !isPowerOnSend) { if (!isSingleSend && !isPowerOnSend) {
currentItemIndex ++; currentItemIndex ++;
itemsProcessedCount ++; itemsProcessedCount ++;
} }
} }
// 由于启动了 onTimeoutRead 所以 isSingleSend = false 导致连续发送
//if (isSingleSend && clientId >= 4) {
if (isSingleSend) { if (isSingleSend) {
isSingleSend = false; // 重置标志 isSingleSend = false;
isClickedSend = false; isClickedSend = false;
} }
else if (isPowerOnSend && currentFrontBoardIndex < frontBoardDevInfoJson.size()) { else if (isPowerOnSend && currentFrontBoardIndex < frontBoardDevInfoJson.size()) {
sendDevInfoItem(); sendDevInfoItem();
} }

View File

@ -2,20 +2,16 @@
#include "RecvDataHandler.h" #include "RecvDataHandler.h"
#include "../Network/ClientHandler.h" #include "../Network/ClientHandler.h"
DataHandler::DataHandler(QLabel* leftLens_imageLabel, QLabel* rightLens_imageLabel, QLabel* videoLabel, DataHandler::DataHandler(QLabel* videoLabel, QLineEdit* VideoResolutionEdit, QSize labelSize, QMap<QString, QLineEdit*>* devInfoLineEdits,
QLineEdit* VideoResolutionEdit, QJsonArray frontBoardOneClickTest, QJsonArray frontBoardTest, QJsonArray frontBoardFuncConfig,
QTextEdit* licenseHwInfoEdit, QMap<QString, QLineEdit*>* devInfoLineEdits, QJsonArray frontBoardDevInfoJson, QJsonArray frontBoardLicenseJson,
QJsonArray frontBoardOneClickTest, QJsonArray frontBoardTest, QJsonArray frontBoardFuncConfig, QJsonArray backBoardOneClickTest, QJsonArray backBoardTest, QJsonArray backBoardFuncConfig,
QJsonArray frontBoardDevInfoJson, QJsonArray frontBoardLicenseJson, QJsonArray backBoardDevInfoJson, QJsonArray backBoardUuidJson,
QJsonArray backBoardOneClickTest, QJsonArray backBoardTest, QJsonArray backBoardFuncConfig, QJsonArray getPicJson, QJsonArray getVideoJson, QObject* parent)
QJsonArray backBoardDevInfoJson, QJsonArray backBoardUuidJson,
QJsonArray getPicJson, QJsonArray getVideoJson, QObject* parent)
: QObject(parent), : QObject(parent),
leftLens_m_imageLabel(leftLens_imageLabel),
rightLens_m_imageLabel(rightLens_imageLabel),
videoLabel(videoLabel), videoLabel(videoLabel),
VideoResolutionEdit(VideoResolutionEdit), VideoResolutionEdit(VideoResolutionEdit),
licenseHwInfoEdit(licenseHwInfoEdit), labelSize(labelSize),
devInfoLineEdits(devInfoLineEdits), devInfoLineEdits(devInfoLineEdits),
frontBoardOneClickTest(frontBoardOneClickTest), frontBoardTest(frontBoardTest), frontBoardOneClickTest(frontBoardOneClickTest), frontBoardTest(frontBoardTest),
frontBoardFuncConfig(frontBoardFuncConfig), frontBoardDevInfoJson(frontBoardDevInfoJson), frontBoardFuncConfig(frontBoardFuncConfig), frontBoardDevInfoJson(frontBoardDevInfoJson),
@ -23,18 +19,18 @@ DataHandler::DataHandler(QLabel* leftLens_imageLabel, QLabel* rightLens_imageLab
backBoardOneClickTest(backBoardOneClickTest), backBoardTest(backBoardTest), backBoardOneClickTest(backBoardOneClickTest), backBoardTest(backBoardTest),
backBoardFuncConfig(backBoardFuncConfig), backBoardDevInfoJson(backBoardDevInfoJson), backBoardFuncConfig(backBoardFuncConfig), backBoardDevInfoJson(backBoardDevInfoJson),
backBoardUuidJson(backBoardUuidJson), getPicJson(getPicJson), getVideoJson(getVideoJson), backBoardUuidJson(backBoardUuidJson), getPicJson(getPicJson), getVideoJson(getVideoJson),
ffmpegDecoder(new FFmpegDecoder()), // 初始化FFmpeg解码器 buffer(new QByteArray()), picBuffer(new QByteArray()),
buffer(new QByteArray()) ffmpegDecoder(new FFmpegDecoder()) // 初始化FFmpeg解码器
{ {
ffmpegDecoder->initialize(); // 初始化解码器 ffmpegDecoder->initialize(); // 初始化解码器
clearAllRecvData(); clearAllRecvData();
initializeMsgIdToCmdMap(); initializeMsgIdToCmdMap();
qDebug() << "DataHandler created"; qDebug() << "DataHandler thread created";
} }
DataHandler::~DataHandler() DataHandler::~DataHandler()
{ {
qDebug() << "---1--- DataHandler destroyed";
if (ffmpegDecoder) { if (ffmpegDecoder) {
ffmpegDecoder->stopFFmpegDecoder(); ffmpegDecoder->stopFFmpegDecoder();
ffmpegDecoder->requestInterruption(); ffmpegDecoder->requestInterruption();
@ -44,7 +40,7 @@ DataHandler::~DataHandler()
} }
delete buffer; delete buffer;
buffer = nullptr; buffer = nullptr;
qDebug() << "---2--- DataHandler destroyed"; qDebug() << "DataHandler thread destroyed";
} }
void DataHandler::handleOpenFocusWindow(int itemIndex) void DataHandler::handleOpenFocusWindow(int itemIndex)
@ -96,7 +92,8 @@ void DataHandler::showVideo(const QString& client, const QByteArray& valData)
void DataHandler::updateLineEdit(int msg_id, const QByteArray& actual_data) { void DataHandler::updateLineEdit(int msg_id, const QByteArray& actual_data) {
QString dataStr = QString(actual_data.toHex(' ')); QString dataStr = QString(actual_data.toHex(' '));
licenseHwInfoEdit->setPlainText(dataStr); //licenseHwInfoEdit->setPlainText(dataStr);
emit updateLicenseHwInfoEdit(dataStr);
if (msgIdToCmdMap.contains(msg_id)) { if (msgIdToCmdMap.contains(msg_id)) {
QString cmd = msgIdToCmdMap[msg_id]; QString cmd = msgIdToCmdMap[msg_id];
@ -133,8 +130,7 @@ void DataHandler::handleData(const QString& client, const QByteArray& recvData,
qDebug() << "read file data size:" << recvdata.size(); qDebug() << "read file data size:" << recvdata.size();
#endif #endif
qDebug() << "---Received data size:" << recvData.size();
//qDebug() << "---Received data size:" << recvData.size();
// 将接收到的数据追加到buffer // 将接收到的数据追加到buffer
buffer->append(recvData); buffer->append(recvData);
@ -148,17 +144,46 @@ void DataHandler::handleData(const QString& client, const QByteArray& recvData,
(static_cast<unsigned char>(buffer->at(6))); (static_cast<unsigned char>(buffer->at(6)));
//qDebug() << "---Received dataSize:" << dataSize; //qDebug() << "---Received dataSize:" << dataSize;
//qDebug() << "---msg_id:" << QString::number(msg_id, 16).toUpper(); //qDebug() << "---msg_id:" << QString::number(msg_id, 16).toUpper();
//qDebug() << "---(static_cast<unsigned char>(buffer->at(10)):" << static_cast<unsigned char>(buffer->at(10)); /*qDebug() << "---(static_cast<unsigned char>(buffer->at(0)):" << QString::number(static_cast<unsigned char>(buffer->at(0)), 16).toUpper();
//qDebug() << "---(static_cast<unsigned char>(buffer->at(11)):" << static_cast<unsigned char>(buffer->at(11)); qDebug() << "---(static_cast<unsigned char>(buffer->at(1)):" << QString::number(static_cast<unsigned char>(buffer->at(1)), 16).toUpper();
//qDebug() << "---(static_cast<unsigned char>(buffer->at(12)):" << static_cast<unsigned char>(buffer->at(12)); qDebug() << "---(static_cast<unsigned char>(buffer->at(2)):" << QString::number(static_cast<unsigned char>(buffer->at(2)), 16).toUpper();
//qDebug() << "---(static_cast<unsigned char>(buffer->at(13)):" << static_cast<unsigned char>(buffer->at(13)); qDebug() << "---(static_cast<unsigned char>(buffer->at(3)):" << QString::number(static_cast<unsigned char>(buffer->at(3)), 16).toUpper();
//qDebug() << "---(static_cast<unsigned char>(buffer->at(14)):" << static_cast<unsigned char>(buffer->at(14)); qDebug() << "---(static_cast<unsigned char>(buffer->at(4)):" << QString::number(static_cast<unsigned char>(buffer->at(4)), 16).toUpper();
//qDebug() << "---(static_cast<unsigned char>(buffer->at(15)):" << static_cast<unsigned char>(buffer->at(15)); qDebug() << "---(static_cast<unsigned char>(buffer->at(5)):" << QString::number(static_cast<unsigned char>(buffer->at(5)), 16).toUpper();
qDebug() << "---(static_cast<unsigned char>(buffer->at(6)):" << QString::number(static_cast<unsigned char>(buffer->at(6)), 16).toUpper();
qDebug() << "---(static_cast<unsigned char>(buffer->at(7)):" << QString::number(static_cast<unsigned char>(buffer->at(7)), 16).toUpper();
qDebug() << "---(static_cast<unsigned char>(buffer->at(8)):" << QString::number(static_cast<unsigned char>(buffer->at(8)), 16).toUpper();
qDebug() << "---(static_cast<unsigned char>(buffer->at(9)):" << QString::number(static_cast<unsigned char>(buffer->at(9)), 16).toUpper();
qDebug() << "---(static_cast<unsigned char>(buffer->at(10)):" << QString::number(static_cast<unsigned char>(buffer->at(10)), 16).toUpper();
qDebug() << "---(static_cast<unsigned char>(buffer->at(11)):" << QString::number(static_cast<unsigned char>(buffer->at(11)), 16).toUpper();
qDebug() << "---(static_cast<unsigned char>(buffer->at(12)):" << QString::number(static_cast<unsigned char>(buffer->at(12)), 16).toUpper();
qDebug() << "---(static_cast<unsigned char>(buffer->at(13)):" << QString::number(static_cast<unsigned char>(buffer->at(13)), 16).toUpper();
qDebug() << "---(static_cast<unsigned char>(buffer->at(14)):" << QString::number(static_cast<unsigned char>(buffer->at(14)), 16).toUpper();
qDebug() << "---(static_cast<unsigned char>(buffer->at(15)):" << QString::number(static_cast<unsigned char>(buffer->at(15)), 16).toUpper();*/
// 第11字节为返回 OK/NG // 第11字节为返回 OK/NG
bool success = (static_cast<unsigned char>(buffer->at(10)) == 0x00); bool success = (static_cast<unsigned char>(buffer->at(10)) == 0x00);
int totalSize = 10 + dataSize; // 数据头大小(10字节) + 实际数据大小 int totalSize = 10 + dataSize; // 数据头大小(10字节) + 实际数据大小
if (buffer->size() >= totalSize) { if (buffer->size() >= totalSize) {
qDebug() << "---(static_cast<unsigned char>(buffer->at(0)):" << QString::number(static_cast<unsigned char>(buffer->at(0)), 16).toUpper();
qDebug() << "---(static_cast<unsigned char>(buffer->at(1)):" << QString::number(static_cast<unsigned char>(buffer->at(1)), 16).toUpper();
qDebug() << "---(static_cast<unsigned char>(buffer->at(2)):" << QString::number(static_cast<unsigned char>(buffer->at(2)), 16).toUpper();
qDebug() << "---(static_cast<unsigned char>(buffer->at(3)):" << QString::number(static_cast<unsigned char>(buffer->at(3)), 16).toUpper();
qDebug() << "---(static_cast<unsigned char>(buffer->at(4)):" << QString::number(static_cast<unsigned char>(buffer->at(4)), 16).toUpper();
qDebug() << "---(static_cast<unsigned char>(buffer->at(5)):" << QString::number(static_cast<unsigned char>(buffer->at(5)), 16).toUpper();
qDebug() << "---(static_cast<unsigned char>(buffer->at(6)):" << QString::number(static_cast<unsigned char>(buffer->at(6)), 16).toUpper();
qDebug() << "---(static_cast<unsigned char>(buffer->at(7)):" << QString::number(static_cast<unsigned char>(buffer->at(7)), 16).toUpper();
qDebug() << "---(static_cast<unsigned char>(buffer->at(8)):" << QString::number(static_cast<unsigned char>(buffer->at(8)), 16).toUpper();
qDebug() << "---(static_cast<unsigned char>(buffer->at(9)):" << QString::number(static_cast<unsigned char>(buffer->at(9)), 16).toUpper();
qDebug() << "---(static_cast<unsigned char>(buffer->at(10)):" << QString::number(static_cast<unsigned char>(buffer->at(10)), 16).toUpper();
qDebug() << "---(static_cast<unsigned char>(buffer->at(11)):" << QString::number(static_cast<unsigned char>(buffer->at(11)), 16).toUpper();
qDebug() << "---(static_cast<unsigned char>(buffer->at(12)):" << QString::number(static_cast<unsigned char>(buffer->at(12)), 16).toUpper();
qDebug() << "---(static_cast<unsigned char>(buffer->at(13)):" << QString::number(static_cast<unsigned char>(buffer->at(13)), 16).toUpper();
qDebug() << "---(static_cast<unsigned char>(buffer->at(14)):" << QString::number(static_cast<unsigned char>(buffer->at(14)), 16).toUpper();
qDebug() << "---(static_cast<unsigned char>(buffer->at(15)):" << QString::number(static_cast<unsigned char>(buffer->at(15)), 16).toUpper();
qDebug() << "---(static_cast<unsigned char>(buffer->at(16)):" << QString::number(static_cast<unsigned char>(buffer->at(16)), 16).toUpper();
qDebug() << "---(static_cast<unsigned char>(buffer->at(17)):" << QString::number(static_cast<unsigned char>(buffer->at(17)), 16).toUpper();
qDebug() << "---(static_cast<unsigned char>(buffer->at(18)):" << QString::number(static_cast<unsigned char>(buffer->at(18)), 16).toUpper();
// 去掉前面 11 字节 // 去掉前面 11 字节
QByteArray data = buffer->mid(11, dataSize); QByteArray data = buffer->mid(11, dataSize);
//QByteArray data = buffer->mid(10, dataSize); //QByteArray data = buffer->mid(10, dataSize);
@ -166,7 +191,7 @@ void DataHandler::handleData(const QString& client, const QByteArray& recvData,
QByteArray actual_data = hexStringToByteArray(hexString); QByteArray actual_data = hexStringToByteArray(hexString);
//qDebug() << "---Received hexString:" << hexString; //qDebug() << "---Received hexString:" << hexString;
buffer->remove(0, totalSize); // 移除已处理的数据 buffer->remove(0, totalSize); // 移除已处理的数据
if(msg_id != 0x0040 && msg_id != START_VIDEO) { if(msg_id != 0x0040 && msg_id != START_VIDEO && msg_id != GET_IMG) {
//if (msg_id != 0x0040) { //if (msg_id != 0x0040) {
qDebug() << "--- msg_id:" << msg_id; qDebug() << "--- msg_id:" << msg_id;
qDebug() << "--- clientLastMsgId.value(client, 0):" << clientLastMsgId.value(client, 0); qDebug() << "--- clientLastMsgId.value(client, 0):" << clientLastMsgId.value(client, 0);
@ -179,8 +204,6 @@ void DataHandler::handleData(const QString& client, const QByteArray& recvData,
true, itemData, funcItemData, jsonArray, itemJsonIndex); true, itemData, funcItemData, jsonArray, itemJsonIndex);
} }
clientLastMsgId[client] = msg_id; clientLastMsgId[client] = msg_id;
qDebug() << "--- client:" << client;
qDebug() << "--- clientLastMsgId[client]:" << clientLastMsgId[client];
} }
handleCmd(msg_id, client, actual_data); handleCmd(msg_id, client, actual_data);
} }
@ -225,21 +248,6 @@ void DataHandler::handleCmd(int msg_id, const QString& client, QByteArray actual
void DataHandler::handleFrontCmd(int msg_id, const QString& client, QByteArray actual_data) void DataHandler::handleFrontCmd(int msg_id, const QString& client, QByteArray actual_data)
{ {
switch (msg_id) { switch (msg_id) {
case 0x0019:
{
showPic(leftLens_m_imageLabel, rightLens_m_imageLabel, client, actual_data);
}
break;
case 0x0011:
{
showVideo(client, actual_data);
}
break;
case 0x0021:
{
//showVideo(client, actual_data);
}
break;
case FACE_ENROLL_SINGLE: case FACE_ENROLL_SINGLE:
{ {
@ -297,7 +305,34 @@ void DataHandler::handleFrontCmd(int msg_id, const QString& client, QByteArray a
break; break;
case GET_IMG: case GET_IMG:
{ {
showPic(leftLens_m_imageLabel, rightLens_m_imageLabel, client, actual_data); qDebug() << "--- showPic actual_data.size():" << actual_data.size();
int lens_n = static_cast<unsigned char>(actual_data[1]);
int width = (static_cast<unsigned char>(actual_data[3]) << 8) | static_cast<unsigned char>(actual_data[2]);
int height = (static_cast<unsigned char>(actual_data[5]) << 8) | static_cast<unsigned char>(actual_data[4]);
int format = static_cast<unsigned char>(actual_data[6]);
qDebug() << "lens_n = " << lens_n;
qDebug() << "format = " << format;
qDebug() << "width = " << width;
qDebug() << "height = " << height;
qint32 picSize = width * height * 1.5;
QByteArray yuvData = actual_data.mid(7);
qDebug() << "--- showPic width * height * 1.5:" << picSize;
qDebug() << "--- showPic picBuffer.size():" << picBuffer->size();
if (yuvData.size() + picBuffer->size() == picSize) {
picBuffer->append(yuvData);
showPic(labelSize, lens_n, width, height, format, picBuffer);
picBuffer->remove(0, picSize);
}
else if (yuvData.size() + picBuffer->size() > picSize) {
picBuffer->append(yuvData);
qDebug() << "width is " << width << " height is " << height << "PIC size is" << picSize;
qDebug() << "But recv PIC size is " << picBuffer->size();
picBuffer->remove(0, picBuffer->size());
}
else {
picBuffer->append(yuvData);
}
} }
break; break;
case START_VIDEO: case START_VIDEO:
@ -507,7 +542,6 @@ void DataHandler::handleDevInfo(int msg_id, const QString& client, QByteArray ac
case GET_FRONT_HW_INFO: case GET_FRONT_HW_INFO:
{ {
qDebug() << "GET_FRONT_HW_INFO"; qDebug() << "GET_FRONT_HW_INFO";
//QString dataStr = QString(actual_data.toHex(' '));
QStringList hexList; QStringList hexList;
QString dataStr; QString dataStr;
qDebug() << "actual_data.size(): " << actual_data.size(); qDebug() << "actual_data.size(): " << actual_data.size();
@ -521,7 +555,8 @@ void DataHandler::handleDevInfo(int msg_id, const QString& client, QByteArray ac
else else
dataStr = "前板发送的HW INFO 数据大小不正确"; dataStr = "前板发送的HW INFO 数据大小不正确";
QString displayText = dataStr; QString displayText = dataStr;
licenseHwInfoEdit->setPlainText(displayText); //licenseHwInfoEdit->setPlainText(displayText);
emit updateLicenseHwInfoEdit(displayText);
} }
break; break;
case WRITE_FRONT_LICENSE: case WRITE_FRONT_LICENSE:

View File

@ -33,9 +33,7 @@ class DataHandler : public QObject
Q_OBJECT Q_OBJECT
public: public:
explicit DataHandler(QLabel* leftLens_imageLabel, QLabel* rightLens_imageLabel, QLabel* videoLabel, explicit DataHandler(QLabel* videoLabel, QLineEdit* VideoResolutionEdit, QSize labelSize, QMap<QString, QLineEdit*>* devInfoLineEdits,
QLineEdit* VideoResolutionEdit,
QTextEdit* licenseHwInfoEdit, QMap<QString, QLineEdit*>* devInfoLineEdits,
QJsonArray frontBoardOneClickTest, QJsonArray frontBoardTest, QJsonArray frontBoardFuncConfig, QJsonArray frontBoardOneClickTest, QJsonArray frontBoardTest, QJsonArray frontBoardFuncConfig,
QJsonArray frontBoardDevInfoJson, QJsonArray frontBoardLicenseJson, QJsonArray frontBoardDevInfoJson, QJsonArray frontBoardLicenseJson,
QJsonArray backBoardOneClickTest, QJsonArray backBoardTest, QJsonArray backBoardFuncConfig, QJsonArray backBoardOneClickTest, QJsonArray backBoardTest, QJsonArray backBoardFuncConfig,
@ -52,7 +50,11 @@ signals:
void statusUpdated(const QString& clientAddress, int currentItemIndex, int currentFuncItemIndex, void statusUpdated(const QString& clientAddress, int currentItemIndex, int currentFuncItemIndex,
bool success, const QString& currentItemLabel, const QString& currentFuncItemLabel, bool success, const QString& currentItemLabel, const QString& currentFuncItemLabel,
const QJsonArray& jsonArray, int itemJsonIndex); const QJsonArray& jsonArray, int itemJsonIndex);
void updateLicenseHwInfoEdit(const QString& text);
void updateLeftLensImage(const QPixmap& pixmap);
void updateRightLensImage(const QPixmap& pixmap);
void updateVideoLabel(const QPixmap& pixmap);
void updateVideoResolution(const QString& resolutionText);
private: private:
QJsonArray frontBoardOneClickTest; // 前板一键功能测试 JSON QJsonArray frontBoardOneClickTest; // 前板一键功能测试 JSON
QJsonArray frontBoardTest; // 前板单项测试 JSON QJsonArray frontBoardTest; // 前板单项测试 JSON
@ -67,20 +69,22 @@ private:
QJsonArray getDevInfoJson; // 获取设备信息 JSON 配置 QJsonArray getDevInfoJson; // 获取设备信息 JSON 配置
QJsonArray getPicJson; // 发送取图指令 JSON 配置 QJsonArray getPicJson; // 发送取图指令 JSON 配置
QJsonArray getVideoJson; // 发送拉视频指令 JSON 配置 QJsonArray getVideoJson; // 发送拉视频指令 JSON 配置
QLabel* leftLens_m_imageLabel; //QLabel* leftLens_m_imageLabel;
QLabel* rightLens_m_imageLabel; //QLabel* rightLens_m_imageLabel;
QLabel* videoLabel; QLabel* videoLabel;
QLineEdit* VideoResolutionEdit; QLineEdit* VideoResolutionEdit;
QTextEdit* licenseHwInfoEdit; //QTextEdit* licenseHwInfoEdit;
QByteArray allRecvData; // 完整的一帧数据 QByteArray allRecvData; // 完整的一帧数据
int remain = 0; int remain = 0;
int start_run = 0; int start_run = 0;
long dataLen = 0; long dataLen = 0;
FFmpegDecoder* ffmpegDecoder; FFmpegDecoder* ffmpegDecoder;
QByteArray *buffer; QByteArray* buffer;
QByteArray* picBuffer;
QHash<QString, unsigned char> clientLastMsgId; QHash<QString, unsigned char> clientLastMsgId;
QMap<QString, QLineEdit*>* devInfoLineEdits; QMap<QString, QLineEdit*>* devInfoLineEdits;
QMap<int, QString> msgIdToCmdMap; QMap<int, QString> msgIdToCmdMap;
QSize labelSize;
// 如果接收十六进制数据,转为二进制 // 如果接收十六进制数据,转为二进制
QByteArray hexStringToByteArray(const QString& hexString); QByteArray hexStringToByteArray(const QString& hexString);
@ -92,6 +96,8 @@ private:
void handleBackCmd(int msg_id, const QString& client, QByteArray actual_data); void handleBackCmd(int msg_id, const QString& client, QByteArray actual_data);
void initializeMsgIdToCmdMap(); void initializeMsgIdToCmdMap();
void updateLineEdit(int msg_id, const QByteArray& actual_data); void updateLineEdit(int msg_id, const QByteArray& actual_data);
void showPic(QSize labelSize, int lens_n,
int width, int height, int format, const QByteArray* valData);
}; };
#endif // DATAHANDLER_H #endif // DATAHANDLER_H

View File

@ -43,17 +43,17 @@ MainWidget::MainWidget(QWidget* parent) :
connect(server, &QTcpServer::newConnection, this, [this]() { connect(server, &QTcpServer::newConnection, this, [this]() {
// 检查是否有挂起的连接 // 检查是否有挂起的连接
while (server->hasPendingConnections()) { while (server->hasPendingConnections()) {
QTcpSocket* socket = server->nextPendingConnection(); QTcpSocket* socket = server->nextPendingConnection();
int clientId = nextClientId ++; int clientId = nextClientId ++;
QHostAddress clientIp = socket->peerAddress(); QHostAddress clientIp = socket->peerAddress();
quint16 clientPort = socket->peerPort(); quint16 clientPort = socket->peerPort();
QString ipString = clientIp.toString(); QString ipString = clientIp.toString();
if (ipString.startsWith("::ffff:")) { if (ipString.startsWith("::ffff:")) {
ipString = ipString.mid(7); ipString = ipString.mid(7);
} }
qDebug() << ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"; qDebug() << ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>";
qDebug() << "> A client is connected. ID:" << clientId; qDebug() << "> A client is connected. ID:" << clientId;
qDebug() << "> Client IP:" << ipString << " Port:" << clientPort; qDebug() << "> Client IP:" << ipString << " Port:" << clientPort;
qDebug() << ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"; qDebug() << ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>";
if (ipString.startsWith("10.10.10")) { if (ipString.startsWith("10.10.10")) {
@ -96,14 +96,11 @@ MainWidget::MainWidget(QWidget* parent) :
handler->moveToThread(thread); handler->moveToThread(thread);
// 创建 DataHandler 对象并连接信号 // 创建 DataHandler 对象并连接信号
DataHandler* dataHandler = new DataHandler(leftLens_imageLabel, rightLens_imageLabel, videoLabel, DataHandler* dataHandler = new DataHandler(videoLabel, VideoResolutionEdit, leftLens_imageLabel->size(), &devInfoLineEdits,
VideoResolutionEdit,
licenseHwInfoEdit, &devInfoLineEdits,
frontBoardOneClickTest, frontBoardTest, frontBoardFuncConfig, frontBoardOneClickTest, frontBoardTest, frontBoardFuncConfig,
frontBoardDevInfoJson, frontBoardLicenseJson, frontBoardDevInfoJson, frontBoardLicenseJson,
backBoardOneClickTest, backBoardTest, backBoardFuncConfig, backBoardDevInfoJson, backBoardOneClickTest, backBoardTest, backBoardFuncConfig, backBoardDevInfoJson,
backBoardUuidJson, getPicJson, getVideoJson, nullptr); backBoardUuidJson, getPicJson, getVideoJson, nullptr);
qDebug() << "dataHandler->moveToThread(thread)";
// 将 DataHandler 移到线程池中的线程 // 将 DataHandler 移到线程池中的线程
dataHandler->moveToThread(thread); dataHandler->moveToThread(thread);
@ -152,14 +149,23 @@ MainWidget::MainWidget(QWidget* parent) :
connect(thread, &QThread::finished, this, [=]() { connect(thread, &QThread::finished, this, [=]() {
onThreadFinished(thread, handler, dataHandler); onThreadFinished(thread, handler, dataHandler);
}); });
connect(dataHandler, &DataHandler::updateLicenseHwInfoEdit, this, [this](const QString& text) {
licenseHwInfoEdit->setPlainText(text);
});
connect(dataHandler, &DataHandler::updateLeftLensImage, leftLens_imageLabel, &QLabel::setPixmap);
connect(dataHandler, &DataHandler::updateRightLensImage, rightLens_imageLabel, &QLabel::setPixmap);
connect(dataHandler, &DataHandler::updateVideoLabel, videoLabel, &QLabel::setPixmap);
connect(dataHandler, &DataHandler::updateVideoResolution, VideoResolutionEdit, &QLineEdit::setText);
// 启动新的线程 // 启动新的线程
thread->start(); thread->start();
connect(handler, &ClientHandler::startReadTimer, this, &MainWidget::startClientReadTimer); connect(handler, &ClientHandler::startReadTimer, this, &MainWidget::startClientReadTimer);
connect(handler, &ClientHandler::stopReadTimer, this, &MainWidget::stopClientReadTimer); connect(handler, &ClientHandler::stopReadTimer, this, &MainWidget::stopClientReadTimer);
//handler->getClientId() == handler->preVideoClientId //handler->getClientId() == handler->preVideoClientId
qDebug() << "---- handler->getClientId():" << handler->getClientId(); //qDebug() << "---- handler->getClientId():" << handler->getClientId();
qDebug() << "---- handler->preVideoClientId:" << handler->preVideoClientId; //qDebug() << "---- handler->preVideoClientId:" << handler->preVideoClientId;
connect(this, &MainWidget::openFocusWindowRequested, dataHandler, &DataHandler::handleOpenFocusWindow); connect(this, &MainWidget::openFocusWindowRequested, dataHandler, &DataHandler::handleOpenFocusWindow);
// 创建和管理定时器 // 创建和管理定时器
@ -295,7 +301,6 @@ void MainWidget::onClientDisconnected(ClientHandler* handler)
*/ */
handler->deleteLater(); // 延迟删除 ClientHandler 对象 handler->deleteLater(); // 延迟删除 ClientHandler 对象
qDebug() << "-----------dataHandlers-----------";
if (dataHandlers.contains(clientId)) { if (dataHandlers.contains(clientId)) {
DataHandler* dataHandler = dataHandlers[clientId]; DataHandler* dataHandler = dataHandlers[clientId];
dataHandlers.remove(clientId); // 从容器中移除 dataHandlers.remove(clientId); // 从容器中移除
@ -448,7 +453,7 @@ void MainWidget::setupUI()
mainLayout->addLayout(rightVerticalLayout, 3); mainLayout->addLayout(rightVerticalLayout, 3);
setLayout(mainLayout); setLayout(mainLayout);
setWindowTitle("SL100 工厂产测工具 - V0.0.1"); setWindowTitle("SL100 工厂产测工具 - V0.0.4");
resize(1340, 900); resize(1340, 900);
connect(startServerButton, &QPushButton::clicked, this, &MainWidget::onStartServerClicked); connect(startServerButton, &QPushButton::clicked, this, &MainWidget::onStartServerClicked);
@ -680,7 +685,7 @@ void MainWidget::FactoryToolSendPostLicenseToHttpServer(const QString& hardware_
} }
void MainWidget::startClientReadTimer(int clientId) { void MainWidget::startClientReadTimer(int clientId) {
qDebug() << "------ startClientReadTimer clientId:" << clientId; //qDebug() << "------ startClientReadTimer clientId:" << clientId;
if (clientReadTimers.contains(clientId)) { if (clientReadTimers.contains(clientId)) {
clientReadTimers[clientId]->start(10); clientReadTimers[clientId]->start(10);
} }
@ -1268,6 +1273,7 @@ void MainWidget::onSendGetVideoClicked()
//QMutexLocker locker(&mutex); //QMutexLocker locker(&mutex);
for (ClientHandler* handler : clients) { for (ClientHandler* handler : clients) {
if (handler->getClientId() == handler->controlClientId) { if (handler->getClientId() == handler->controlClientId) {
qDebug() << "lens number:" << lastClickedGetVideoCamIndex;
handler->sendGetVideoItem(itemIndex - 7, lastClickedGetVideoCamIndex); handler->sendGetVideoItem(itemIndex - 7, lastClickedGetVideoCamIndex);
break; break;
} }

View File

@ -23,8 +23,8 @@ int main(int argc, char* argv[]) {
//FreeConsole(); // 关闭控制台窗口 //FreeConsole(); // 关闭控制台窗口
QApplication app(argc, argv); QApplication app(argc, argv);
qDebug() << "Current working directory:" << QDir::currentPath(); qDebug() << "Current working directory:" << QDir::currentPath();
QIcon appIcon("./app_icon.ico"); //QIcon appIcon("./app_icon.ico");
app.setWindowIcon(appIcon); //app.setWindowIcon(appIcon);
MainWidget w; MainWidget w;
w.show(); w.show();

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

File diff suppressed because one or more lines are too long

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff