zhongfuqiang上传最新代码20250325
This commit is contained in:
@@ -242,7 +242,7 @@ void SerialDataHandler::showPic(QSize labelSize, int lens_n,
|
||||
}
|
||||
|
||||
QTransform transform;
|
||||
transform.rotate(90); // 可以调整旋转角度
|
||||
transform.rotate(270); // 可以调整旋转角度
|
||||
QImage rotatedImage = image.transformed(transform);
|
||||
QImage scaledImage = rotatedImage.scaled(labelSize, Qt::KeepAspectRatio);
|
||||
QPixmap pixmap = QPixmap::fromImage(scaledImage);
|
||||
@@ -272,7 +272,13 @@ void SerialDataHandler::showPic(QSize labelSize, int lens_n,
|
||||
else if (format == YUV420) {
|
||||
rotatedYuvData = convertQImageToYUV420(rotatedImage);
|
||||
}
|
||||
QString yuvFileName = saveDirPath + "/" + currentTime + ".yuv";
|
||||
|
||||
QString len_num = "";
|
||||
if (lens_n == 0)
|
||||
len_num = "left";
|
||||
else
|
||||
len_num = "right";
|
||||
QString yuvFileName = saveDirPath + "/" + len_num + "_" + currentTime + ".yuv";
|
||||
QFile yuvFile(yuvFileName);
|
||||
if (yuvFile.open(QIODevice::WriteOnly)) {
|
||||
yuvFile.write(rotatedYuvData);
|
||||
@@ -282,9 +288,10 @@ void SerialDataHandler::showPic(QSize labelSize, int lens_n,
|
||||
else {
|
||||
qWarning() << "Failed to save rotated YUV image to" << yuvFileName;
|
||||
}
|
||||
|
||||
|
||||
// 额外:可以保存旋转后的图像为JPG或PNG格式
|
||||
QString rotatedImageFileName = saveDirPath + "/" + currentTime + ".jpg";
|
||||
QString rotatedImageFileName = saveDirPath + "/" + len_num + "_" + currentTime + ".jpg";
|
||||
rotatedImage.save(rotatedImageFileName, "JPG");
|
||||
qDebug() << "JPG image saved to" << rotatedImageFileName;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
// FFmpegDecoder.cpp
|
||||
#include "FFmpegDecoder.h"
|
||||
#include <QApplication>
|
||||
|
||||
|
||||
FFmpegDecoder::FFmpegDecoder(QObject* parent) :
|
||||
QThread(parent),
|
||||
@@ -37,6 +39,9 @@ FFmpegDecoder::~FFmpegDecoder()
|
||||
|
||||
void FFmpegDecoder::processVideo(int itemIndex)
|
||||
{
|
||||
qDebug() << "processVideo running in thread:" << QThread::currentThread();
|
||||
qDebug() << "FFmpegDecoder thread:" << this->thread();
|
||||
|
||||
QLabel* originalLabel;
|
||||
if (isBackBoardOrAllBoard) {
|
||||
originalLabel = this->videoLabel_back;
|
||||
@@ -45,8 +50,8 @@ void FFmpegDecoder::processVideo(int itemIndex)
|
||||
originalLabel = this->videoLabel;
|
||||
}
|
||||
if ((FocusWindowWidth != 0) && (FocusWindowHeight != 0)) {
|
||||
qDebug() << "------ processVideo";
|
||||
FocusWindowDialog* dialog = nullptr;
|
||||
qDebug() << "---1--- processVideo";
|
||||
/*FocusWindowDialog* dialog = nullptr;
|
||||
if (FocusWindowWidth * 16 == FocusWindowHeight * 9) {
|
||||
dialog = new FocusWindowDialog(nullptr, QSize(540, 960));
|
||||
}
|
||||
@@ -68,14 +73,49 @@ void FFmpegDecoder::processVideo(int itemIndex)
|
||||
this->videoLabelTemp = dialog->videoDisplayLabel;
|
||||
this->videoLabelChanged = true;
|
||||
mutex.unlock();
|
||||
|
||||
qDebug() << "---2--- processVideo";
|
||||
if ((dialog->exec() == QDialog::Accepted) || (dialog->exec() == QDialog::Rejected)) {
|
||||
mutex.lock();
|
||||
this->videoLabelTemp = originalLabel;
|
||||
this->videoLabelChanged = true;
|
||||
mutex.unlock();
|
||||
}
|
||||
delete dialog;
|
||||
delete dialog;*/
|
||||
QMetaObject::invokeMethod(qApp, [=]() {
|
||||
FocusWindowDialog* dialog = nullptr;
|
||||
if (FocusWindowWidth * 16 == FocusWindowHeight * 9) {
|
||||
dialog = new FocusWindowDialog(nullptr, QSize(540, 960));
|
||||
}
|
||||
else if (FocusWindowWidth * 9 == FocusWindowHeight * 16) {
|
||||
dialog = new FocusWindowDialog(nullptr, QSize(960, 540));
|
||||
}
|
||||
else if (FocusWindowWidth * 4 == FocusWindowHeight * 3) {
|
||||
dialog = new FocusWindowDialog(nullptr, QSize(480, 640));
|
||||
}
|
||||
else if (FocusWindowWidth * 3 == FocusWindowHeight * 4) {
|
||||
dialog = new FocusWindowDialog(nullptr, QSize(640, 480));
|
||||
}
|
||||
else {
|
||||
qDebug() << "------ Other scaled resolutions use 480x640";
|
||||
dialog = new FocusWindowDialog(nullptr, QSize(480, 640));
|
||||
}
|
||||
|
||||
// 设置临时视频Label
|
||||
mutex.lock();
|
||||
this->videoLabelTemp = dialog->videoDisplayLabel;
|
||||
this->videoLabelChanged = true;
|
||||
mutex.unlock();
|
||||
|
||||
connect(dialog, &QDialog::finished, this, [=](int result) {
|
||||
mutex.lock();
|
||||
this->videoLabelTemp = originalLabel;
|
||||
this->videoLabelChanged = true;
|
||||
mutex.unlock();
|
||||
dialog->deleteLater(); // 关闭后删除窗口
|
||||
});
|
||||
|
||||
dialog->open(); // **在 UI 线程执行 open(),避免阻塞**
|
||||
}, Qt::QueuedConnection);
|
||||
}
|
||||
else {
|
||||
qDebug() << "------ Please wait for the video to be decoded and rendered before clicking";
|
||||
@@ -192,7 +232,7 @@ void FFmpegDecoder::run()
|
||||
labelSize = currentVideoLabel->size();
|
||||
}
|
||||
mutex.unlock();
|
||||
|
||||
qWarning() << "-------currentVideoLabel";
|
||||
QImage img = avFrameToQImage(frame);
|
||||
QImage scaledImage = img.scaled(labelSize, Qt::KeepAspectRatio, Qt::SmoothTransformation);
|
||||
//currentVideoLabel->setPixmap(QPixmap::fromImage(scaledImage));
|
||||
|
||||
Reference in New Issue
Block a user