Open MichaelHeiser opened 2 years ago
I narrowed things down and it seems that
if (captureRect.isValid() && frameToProcess.size() != rect.size()) {
frameToProcess = image.copy(rect);
}
in QZxingFilterVideoSink.cpp is causing this crash. When i comment this line out, the app is not crashing. The example therefore does not recognize a barcode.
After further testing with Qt 6.3 RC1 after suggestion from Qt support I have narrowed things a little more down. I've done a manual slowdown of the processing by adding a timer which sets a bool each second to true to allow processing of videoFrame:
void QZXingFilter::processFrame(const QVideoFrame &frame) {
if(allowProcessing)
allowProcessing = false;
else
return;
#ifdef Q_OS_ANDROID
m_videoSink->setRhi(nullptr); // https://bugreports.qt.io/browse/QTBUG-97789
QVideoFrame f(frame);
f.map(QVideoFrame::ReadOnly);
#else
const QVideoFrame &f = frame;
#endif // Q_OS_ANDROID
if(!isDecoding() && processThread.isFinished()){
QImage::Format image_format = QVideoFrameFormat::imageFormatFromPixelFormat(f.pixelFormat());
if(image_format == QImage::Format_Invalid){
qDebug() << image_format;
#ifdef Q_OS_ANDROID
if(f.isMapped())
f.unmap();
#endif
return;
}
When i comment m_videoSink->setRhi(nullptr); out I get invalid image format from the frame. And when I comment this line in the app crashes with the crashlog attached. Seems that there is a problem in getting correct image information from VideoFrame QZXingLive_crashlog_QT6.3.0RC1.txt .
See this implementation: https://bugreports.qt.io/browse/QTBUG-97789?focusedCommentId=662706&page=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel#comment-662706
I tryed qzxing using qt 6.3 and didn't worked smooth (after 2-3 seconds there was only 1 frame in 5 seconds. This implementatoin fixed the issue on my side.
Implementend on my side here: https://github.com/CMGeorge/qzxing/commit/10b917f071b1f5b0145f04bb10ec8404d314165e#diff-cccfcad0b6ba438f5e4e6219f041e86fa651ea64921b2ba25ed5703af20c879f (Thre is a mess because of auto formating... only void QZXingFilter::processFrame(const QVideoFrame &frame) should be change. and don't forget to set signals as dirrect connection like here:
connect(m_videoSink, &QVideoSink::videoFrameChanged, this, &QZXingFilter::processFrame,Qt::DirectConnection);
Currently testing with Qt 6.5.0 and followed again the suggestions made in this thread. With master version the QZXing QrCode recognition is very slow and sluggish using QZXingLive. I've made following changes ot QZXingFilterVideoSink.cpp and with those changes QrCode-Scanning is working okay. https://gist.github.com/MichaelHeiser/5ab6ca42444a4c231ce0910ad0a4cf8a
@MichaelHeiser do you ever get it working with Qt 6.2? Current QXZing master is always crashing Android application when executing QImage().copy.
I also tried the Qt6_2_multimedia branch but it does crash also.
Currently working woth Qt 6.5.x. No changes to current version has to be made. QR-Code recognition is working as expected.
I am currently porting my app to Qt 6.2.x from Qt 5.15.x. QZXing is a part of our application so I was really thankful, that already some effort was made to get QZXing compatible with Qt6. When trying out with QZXingLive on my Android 12 device the example started but it crashes after a few seconds. I have a detailed crashlog of QtCreator:
And I can also provide the Logcat output:
Can anyone help me to narrow down, what I can do to get QZXing up and running?