Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to detect QR codes via QZXingFilter on SailfishOS #200

Closed
patrickjane opened this issue Jun 28, 2021 · 5 comments
Closed

Unable to detect QR codes via QZXingFilter on SailfishOS #200

patrickjane opened this issue Jun 28, 2021 · 5 comments

Comments

@patrickjane
Copy link

Hello,

I am running SailfishOS 4.1.0.24 (QT 5.2) on a Sony XPeria 10 ii, and I want to read QR codes from within my app. I have included the full project in my project, and I have enabled several switches:

MyApp.pro
QT += multimedia

QZXing.pri
CONFIG += enable_decoder_qr_code qzxing_multimedia qzxing_qml

Currently I am trying the QZXingFilter like so:

int main(int argc, char *argv[])
{
   QScopedPointer<QGuiApplication> app(SailfishApp::application(argc, argv));
   QScopedPointer<QQuickView> view(SailfishApp::createView());

   QZXing::registerQMLTypes();

   view->setSource(SailfishApp::pathTo(QString("qml/harbour-myapp.qml")));
   view->show();

   return app->exec();
}
   Rectangle {
      width: 400
      height: 400
      x: 30; y: 90

      Camera {
         id: camera

         focus {
            focusMode: Camera.FocusContinuous
            focusPointMode: Camera.FocusPointCenter
         }
      }

      VideoOutput {
         id: videoOutput
         source: camera
         filters: [ videoFilter ]
         autoOrientation: false
      }
   }

   QZXingFilter {
      id: videoFilter

      decoder {
         imageSourceFilter: QZXing.SourceFilter_ImageNormal
         enabledDecoders: QZXing.DecoderFormat_QR_CODE
         tryHarder: true
         tryHarderType: QZXing.TryHarderBehaviour_Rotate | QZXing.TryHarderBehaviour_ThoroughScanning

         onTagFound: {
            console.log("Tag found:", tag);
         }
      }
   }

Since I had issues with no code beeing detected (onTagFound never emitted, and decodingFinished signaling failure) I have commented in the debug messages in QZXing::decodeImage(). This gives me the following output:

[D] QZXing::decodeImage:448 - Iterations:  1 , sourceFilter:  2
[D] QZXing::decodeImage:467 - Decoding phase 1: started
[D] QZXing::decodeImage:473 - Decoding phase 1: failed:  No code detected
[D] QZXing::decodeImage:478 - Decoding phase 2, thorought scan: starting
[D] QZXing::decodeImage:491 - Decoding phase 2, thorought scan: failed:  No code detected
[D] QZXing::decodeImage:498 - Decoding phase 2, rotate: starting
[D] QZXing::decodeImage:511 - Decoding phase 2, rotate: failed:  No code detected
[D] QZXing::decodeImage:519 - Decoding failed:  "This luminance source does not support rotation."
[D] QZXing::decodeImage:563 - End decoding 3
[D] QZXing::decodeImage:448 - Iterations:  1 , sourceFilter:  2
[D] QZXing::decodeImage:467 - Decoding phase 1: started
[D] QZXing::decodeImage:473 - Decoding phase 1: failed:  No code detected
[D] QZXing::decodeImage:478 - Decoding phase 2, thorought scan: starting
[D] QZXing::decodeImage:491 - Decoding phase 2, thorought scan: failed:  No code detected
[D] QZXing::decodeImage:498 - Decoding phase 2, rotate: starting
[D] QZXing::decodeImage:511 - Decoding phase 2, rotate: failed:  No code detected
[D] QZXing::decodeImage:519 - Decoding failed:  "This luminance source does not support rotation."
[D] QZXing::decodeImage:563 - End decoding 3

So now I don't know what to do in order to make it scan the code. For testing, I am using one of those codes.

Could anyone help me out figuring out whats wrong here?

@ftylitak
Copy link
Owner

Hello @patrickjane

most likely it has something to do with the image encoding not being 100% supported by QZXing.

I have a Jolla C with Sailfish 4 so I will give it a try :)
(minor note, the Qt version is 5.12 not 5.2 correct ?)

@patrickjane
Copy link
Author

patrickjane commented Jun 29, 2021

It should be 5.2 (https://sailfishos.org/wiki/Qt).

BTW: I am pretty sure there should be other apps for SailfishOS which are using ZXing/QZXing successfully, so I guess I am making some mistakes on the way.

@ftylitak
Copy link
Owner

Indeed you are correct, it seems that 5.2 is the correct.

Regarding your issue, till I find a proper way of integrating the solution, here is what you can do as a workaround.
In file QZXingFilter at the following files:

qzxing/src/QZXingFilter.cpp

Lines 183 to 187 in 9973b3d

#if defined(Q_OS_IOS) || defined (Q_OS_MAC)
uchar* pixel = pixelInit + (y - 1) * captureRect.targetWidth;
#else
uchar* pixel = pixelInit + (captureRect.targetHeight - y) * captureRect.targetWidth;
#endif

comment out all lines except line 184:

//#if defined(Q_OS_IOS) || defined (Q_OS_MAC)
        uchar* pixel = pixelInit + (y - 1) * captureRect.targetWidth;
//#else
//        uchar* pixel = pixelInit + (captureRect.targetHeight - y) * captureRect.targetWidth;
//#endif

Could you give it a try and send me your feedback if it works for you?

@patrickjane
Copy link
Author

patrickjane commented Jun 29, 2021

I have changed it, and I can confirm everything gets detected now. Thanks for the support!

@patrickjane
Copy link
Author

I might add that, in order to include this project into a SFOS project, I had to add more adjustments, otherwise the install targets would be messed up and I would no longer be able to produce RPMs.

See the patch here https://github.com/patrickjane/harbour-scooter/blob/main/qzxing_sfos_fix.patch

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants