Commit b56004fe authored by LNJ's avatar LNJ 💬

QrCodeScannerFilter: Show error message when video frame format is unsupported

Co-authored-by: melvo's avatarMelvin Keskin <melvo@olomono.de>
parent 653d4c3a
......@@ -86,13 +86,16 @@ QVideoFrame QrCodeScannerFilterRunnable::run(
m_filter->m_processThread = QtConcurrent::run(
this,
&QrCodeScannerFilterRunnable::processVideoFrameProbed,
m_filter->m_frame
m_filter->m_frame,
m_filter
);
return *input;
}
void QrCodeScannerFilterRunnable::processVideoFrameProbed(QrCodeVideoFrame &videoFrame)
{
void QrCodeScannerFilterRunnable::processVideoFrameProbed(
QrCodeVideoFrame videoFrame,
QrCodeScannerFilter *filter
) {
// Return if the frame is empty.
if (videoFrame.data().length() < 1)
return;
......@@ -102,11 +105,18 @@ void QrCodeScannerFilterRunnable::processVideoFrameProbed(QrCodeVideoFrame &vide
// Return if conversion from the frame to the image failed.
if (image->isNull()) {
// dirty hack: write QVideoFrame::PixelFormat as string to format using QDebug
// QMetaEnum::valueToKey() did not work
QString format;
QDebug(&format) << videoFrame.pixelFormat();
qDebug() << "QrCodeScannerFilterRunnable error: Cannot create image file to process.";
qDebug() << "Maybe it was a format conversion problem.";
qDebug() << "VideoFrame format:" << videoFrame.pixelFormat();
qDebug() << "VideoFrame format:" << format;
qDebug() << "Image corresponding format:"
<< QVideoFrame::imageFormatFromPixelFormat(videoFrame.pixelFormat());
<< QVideoFrame::imageFormatFromPixelFormat(videoFrame.pixelFormat());
emit filter->unsupportedFormatReceived(format);
return;
}
......
......@@ -78,6 +78,13 @@ signals:
*/
void scanningSucceeded(const QString& result);
/**
* Emitted when a video frame with an unsupported format is received.
*
* @param format format of the video frame which is not supported
*/
void unsupportedFormatReceived(const QString& format);
private:
QrCodeDecoder *m_decoder;
......@@ -107,8 +114,9 @@ public:
* Converts a given frame, which may contain a QR code, to an image and then tries to decode it.
*
* @param videoFrame frame to be converted and which may contain a QR code to be decoded
* @param filter filter of the current execution
*/
void processVideoFrameProbed(QrCodeVideoFrame &videoFrame);
void processVideoFrameProbed(QrCodeVideoFrame videoFrame, QrCodeScannerFilter *filter);
private:
QrCodeScannerFilter *m_filter;
......
......@@ -82,6 +82,10 @@ Kirigami.Page {
// login by the data from the decoded QR code
kaidan.loginByUri(result)
}
onUnsupportedFormatReceived: {
pageStack.layers.pop()
passiveNotification(qsTr("The camera format '%1' is not supported.").arg(format))
}
}
// camera with continuous focus in the center of the video
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment