Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
Network
Kaidan
Commits
23c429b6
Verified
Commit
23c429b6
authored
Oct 19, 2019
by
Jonah Brüchert
🌳
1
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
qrcode: Set camera format to avoid issues with unsupported formats
parent
8c616989
Pipeline
#9182
failed with stages
in 6 minutes and 42 seconds
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
25 additions
and
3 deletions
+25
-3
src/QrCodeScannerFilter.cpp
src/QrCodeScannerFilter.cpp
+14
-2
src/QrCodeScannerFilter.h
src/QrCodeScannerFilter.h
+7
-1
src/qml/QrCodeScannerPage.qml
src/qml/QrCodeScannerPage.qml
+4
-0
No files found.
src/QrCodeScannerFilter.cpp
View file @
23c429b6
...
...
@@ -61,6 +61,18 @@ QVideoFilterRunnable *QrCodeScannerFilter::createFilterRunnable()
return
new
QrCodeScannerFilterRunnable
(
this
);
}
void
QrCodeScannerFilter
::
setCameraDefaultVideoFormat
(
QObject
*
qmlCamera
)
{
QCamera
*
camera
=
qvariant_cast
<
QCamera
*>
(
qmlCamera
->
property
(
"mediaObject"
));
if
(
camera
)
{
QCameraViewfinderSettings
settings
=
camera
->
viewfinderSettings
();
settings
.
setPixelFormat
(
QVideoFrame
::
Format_RGB24
);
camera
->
setViewfinderSettings
(
settings
);
}
else
{
qWarning
()
<<
"Could not set pixel format of QML camera"
;
}
}
QrCodeScannerFilterRunnable
::
QrCodeScannerFilterRunnable
(
QrCodeScannerFilter
*
filter
)
:
QObject
(
nullptr
),
m_filter
(
filter
)
...
...
@@ -97,7 +109,7 @@ void QrCodeScannerFilterRunnable::processVideoFrameProbed(
QrCodeScannerFilter
*
filter
)
{
// Return if the frame is empty.
if
(
videoFrame
.
data
().
length
()
<
1
)
if
(
videoFrame
.
data
().
isEmpty
()
)
return
;
// Create an image from the frame.
...
...
@@ -108,7 +120,7 @@ void QrCodeScannerFilterRunnable::processVideoFrameProbed(
// dirty hack: write QVideoFrame::PixelFormat as string to format using QDebug
// QMetaEnum::valueToKey() did not work
QString
format
;
QDebug
(
&
format
)
<<
videoFrame
.
pixelFormat
();
QDebug
(
&
format
)
.
nospace
()
<<
videoFrame
.
pixelFormat
();
qDebug
()
<<
"QrCodeScannerFilterRunnable error: Cannot create image file to process."
;
qDebug
()
<<
"Maybe it was a format conversion problem."
;
...
...
src/QrCodeScannerFilter.h
View file @
23c429b6
...
...
@@ -48,7 +48,6 @@ class QrCodeScannerFilter : public QAbstractVideoFilter
friend
class
QrCodeScannerFilterRunnable
;
Q_OBJECT
Q_PROPERTY
(
QrCodeDecoder
*
decoder
READ
decoder
)
public:
/**
...
...
@@ -65,6 +64,13 @@ public:
QrCodeDecoder
*
decoder
();
QVideoFilterRunnable
*
createFilterRunnable
()
override
;
/**
* Sets the video frame format of the QML Camera object to our default format
*
* @param qmlCamera Camera object from QML
*/
Q_INVOKABLE
void
setCameraDefaultVideoFormat
(
QObject
*
qmlCamera
);
signals:
/**
* Emitted when the scanning of an image did not succeed, i.e. no valid QR code was found.
...
...
src/qml/QrCodeScannerPage.qml
View file @
23c429b6
...
...
@@ -95,5 +95,9 @@ Kirigami.Page {
focusMode
:
Camera
.
FocusContinuous
focusPointMode
:
Camera
.
FocusPointCenter
}
Component.onCompleted
:
{
scannerFilter
.
setCameraDefaultVideoFormat
(
camera
);
}
}
}
Linus Jahn
@lnj
·
Oct 19, 2019
Developer
Actually it was me committing in JBB's name here...
Actually it was me committing in JBB's name here...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment