1.调通所有与服务器HTTP连接的接口 2.更新图语License从服务器查询和U盘获取后上报,前板可直接使用产测工具写入License 3.优化接收到前板的H264解码后出现视频卡的问题 4.更新从前板取图后旋转 5.增加ffmpeg解码的视频分辨率获取
This commit is contained in:
@@ -72,51 +72,47 @@ QImage convertYUV420ToQImage(const QByteArray& yuv420Data, int width, int height
|
||||
return image;
|
||||
}
|
||||
|
||||
// 显示图片的函数
|
||||
void showPic(QLabel* leftLens_m_imageLabel, QLabel* rightLens_m_imageLabel, const QString& client, const QByteArray& valData)
|
||||
{
|
||||
int lens_n = static_cast<unsigned char>(valData[3]);
|
||||
int width = (static_cast<unsigned char>(valData[5]) << 8) | static_cast<unsigned char>(valData[4]);
|
||||
int height = (static_cast<unsigned char>(valData[7]) << 8) | static_cast<unsigned char>(valData[6]);
|
||||
int format = static_cast<unsigned char>(valData[8]);
|
||||
int lens_n = static_cast<unsigned char>(valData[0]);
|
||||
int width = (static_cast<unsigned char>(valData[2]) << 8) | static_cast<unsigned char>(valData[1]);
|
||||
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(9);
|
||||
|
||||
QByteArray yuvData = valData.mid(6);
|
||||
qDebug() << "yuvData size = " << yuvData.size();
|
||||
|
||||
QImage image;
|
||||
if (format == YUV422) {
|
||||
QImage image = convertYUV422ToQImage(yuvData, width, height);
|
||||
QImage scaledImage = image.scaled(leftLens_m_imageLabel->size(), Qt::KeepAspectRatio);
|
||||
if (lens_n == 0) {
|
||||
leftLens_m_imageLabel->setPixmap(QPixmap::fromImage(scaledImage));
|
||||
rightLens_m_imageLabel->setPixmap(QPixmap::fromImage(scaledImage));
|
||||
}
|
||||
else if (lens_n == 1) {
|
||||
rightLens_m_imageLabel->setPixmap(QPixmap::fromImage(scaledImage));
|
||||
}
|
||||
else {
|
||||
qWarning() << "Unsupported image lens!";
|
||||
}
|
||||
image = convertYUV422ToQImage(yuvData, width, height);
|
||||
}
|
||||
else if (format == YUV420) {
|
||||
QImage image = convertYUV420ToQImage(yuvData, width, height);
|
||||
QImage scaledImage = image.scaled(leftLens_m_imageLabel->size(), Qt::KeepAspectRatio);
|
||||
if (lens_n == 0) {
|
||||
leftLens_m_imageLabel->setPixmap(QPixmap::fromImage(scaledImage));
|
||||
}
|
||||
else if (lens_n == 1) {
|
||||
rightLens_m_imageLabel->setPixmap(QPixmap::fromImage(scaledImage));
|
||||
}
|
||||
else {
|
||||
qWarning() << "Unsupported image lens!";
|
||||
}
|
||||
image = convertYUV420ToQImage(yuvData, width, height);
|
||||
}
|
||||
else {
|
||||
qWarning() << "Unsupported image format!";
|
||||
return;
|
||||
}
|
||||
|
||||
// 旋转图像90度
|
||||
QTransform transform;
|
||||
transform.rotate(90); // 可以调整旋转角度
|
||||
QImage rotatedImage = image.transformed(transform);
|
||||
|
||||
QImage scaledImage = rotatedImage.scaled(leftLens_m_imageLabel->size(), Qt::KeepAspectRatio);
|
||||
if (lens_n == 0) {
|
||||
leftLens_m_imageLabel->setPixmap(QPixmap::fromImage(scaledImage));
|
||||
//rightLens_m_imageLabel->setPixmap(QPixmap::fromImage(scaledImage));
|
||||
}
|
||||
else if (lens_n == 1) {
|
||||
rightLens_m_imageLabel->setPixmap(QPixmap::fromImage(scaledImage));
|
||||
}
|
||||
else {
|
||||
qWarning() << "Unsupported image lens!";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -37,11 +37,11 @@ void FFmpegDecoder::initialize()
|
||||
avformat_network_init();
|
||||
}
|
||||
|
||||
void FFmpegDecoder::decodeFile(const QString& filePath, QLabel* videoLabel)
|
||||
void FFmpegDecoder::decodeFile(const QString& filePath, QLabel* videoDisplayLabel)
|
||||
{
|
||||
QMutexLocker locker(&mutex);
|
||||
this->filePath = filePath;
|
||||
this->videoLabel = videoLabel;
|
||||
this->videoLabel = videoDisplayLabel;
|
||||
if (!isRunning()) {
|
||||
qDebug() << "Starting decoder thread";
|
||||
start(NormalPriority);
|
||||
@@ -69,6 +69,13 @@ void FFmpegDecoder::run()
|
||||
QLabel* currentVideoLabel = videoLabel;
|
||||
QSize labelSize = currentVideoLabel->size();
|
||||
mutex.unlock();
|
||||
|
||||
if (labelSize.width() <= 0 || labelSize.height() <= 0) {
|
||||
// 自动调整 QLabel 大小
|
||||
labelSize = QSize(800, 600); // 例如设置为默认大小
|
||||
currentVideoLabel->setFixedSize(labelSize);
|
||||
qDebug() << "Adjusting video label size to: Width =" << labelSize.width() << ", Height =" << labelSize.height();
|
||||
}
|
||||
qDebug() << "Video label size: Width =" << labelSize.width() << ", Height =" << labelSize.height();
|
||||
|
||||
if (!file.open(QIODevice::ReadOnly)) {
|
||||
@@ -107,6 +114,8 @@ void FFmpegDecoder::run()
|
||||
break;
|
||||
}
|
||||
|
||||
qDebug() << "H264 video resolution: Width =" << frame->width << ", Height =" << frame->height;
|
||||
|
||||
QImage img = avFrameToQImage(frame);
|
||||
QImage scaledImage = img.scaled(labelSize, Qt::KeepAspectRatio, Qt::SmoothTransformation);
|
||||
currentVideoLabel->setPixmap(QPixmap::fromImage(scaledImage));
|
||||
@@ -184,7 +193,7 @@ bool FFmpegDecoder::initializeFFmpeg(const QString& filePath)
|
||||
return false;
|
||||
}
|
||||
|
||||
frame = av_frame_alloc();
|
||||
frame = av_frame_alloc();
|
||||
packet = av_packet_alloc();
|
||||
|
||||
return true;
|
||||
|
||||
@@ -12,6 +12,9 @@
|
||||
#include <QMutex>
|
||||
#include <QFile>
|
||||
#include <QWaitCondition>
|
||||
#include <cstdint>
|
||||
#include <vector>
|
||||
|
||||
#include "RingBuffer.h"
|
||||
|
||||
extern "C" {
|
||||
|
||||
Reference in New Issue
Block a user