steffen-foerster / sailfish-barcode

22 stars 36 forks source link

App does not work on SailfishX #34

Open sfbg opened 6 years ago

sfbg commented 6 years ago

It does not scan on Xperia X. The camera works, but, after clicking Scan, nothing happens.

steffen-foerster commented 6 years ago

I don't have a Xperia X. I hope someone else can find the cause for this bug.

AlmAck commented 6 years ago

I can try to debug it, but where do you think the problem resides?

steffen-foerster commented 6 years ago

Please send me the console output. There should be some debugging messages. After that, I can narrow down the cause a little bit.

AlmAck commented 6 years ago

Here the log: barcode.log I can debug the app if you want, let me know what I can do to help you.

steffen-foerster commented 6 years ago

It seems there is a problem with the screenshot creation. Can you send me the following image: /home/nemo/.cache/harbour-barcode/harbour-barcode/capture-code.jpg

AlmAck commented 6 years ago

there is no image in that folder, is empty.

drwxr-xr-x 3 nemo nemo 4096 Oct 11 21:34 harbour-barcode

steffen-foerster commented 6 years ago

I think this code of the class AutoBarcodeScanner is not working:

QDBusMessage m = QDBusMessage::createMethodCall("org.nemomobile.lipstick", "/org/nemomobile/lipstick/screenshot", "org.nemomobile.lipstick", "saveScreenshot"); m << m_decoder->getCaptureLocation(); QDBusConnection::sessionBus().call(m); QImage screenshot(m_decoder->getCaptureLocation());

Can you execute the following command on your Xperia phone?

dbus-send --dest=org.nemomobile.lipstick --session --print-reply /org/nemomobile/lipstick/screenshot org.nemomobile.lipstick.saveScreenshot string:"/home/nemo/Pictures/test.jpg

This command should create a screenshot and save the image in the file test.jpg. It works on my Jolla1. Can you find this file after the execution?

The result on your console should be something like: "method return time=..."

AlmAck commented 6 years ago

that works fine, I get the screenshot on my Pictures folder.

Output is: method return time=1508684577.735856 sender=:1.25 -> destination=:1.539 serial=10327 reply_serial=2

EDIT: found the problem!


[nemo@Sailfish ~]$ dbus-send --dest=org.nemomobile.lipstick --session --print-reply /org/nemomobile/lipstick/screenshot org.nemomobile.lipstick.saveScreenshot string:"/home/nemo/.cache/harbour-barcode/harbour-barcode/capture_code.jpg"
Error org.freedesktop.DBus.Error.Failed: File path for screenshot not accepted: path includes hidden part or '..'

EDIT2: I changed to QStandardPaths::DownloadLocation and the temporary image is generated, BUT:

btw, why a screenshot dbus message is used instead of taking a real picture with the camera?

steffen-foerster commented 6 years ago

I changed the location to QStandardPaths::PicturesLocation and commited all changes. Can you test it again?

btw, why a screenshot dbus message is used instead of taking a real picture with the camera?

I tested the usage of the class QCameraImageCapture to take pictures with the camera. After each call of the method capture the view finder freezes for some seconds. I don't like this behaviour.

AlmAck commented 6 years ago

As explained above does not work. I wil try to explain what happens: if the capture_code.jpg does not exist, then I can open the barcode app, point the barcode and press "scan". The barcode is detected correctly! But then, I can't take an other barcode anymore until I close the app and remove the capture_code.jpg manually. The cropped area of the image is wrong, like this (capture_code.jpg): capture_code

This is what I see on screen: 20171023000557

steffen-foerster commented 6 years ago

For the first problem

But then, I can't take an other barcode anymore until I close the app and remove the capture_code.jpg manually.

I need the log file of the entire test.

For the second problem:

The cropped area of the image is wrong, like this (capture_code.jpg):

Please comment out this lines

QImage copy = screenshot.copy(m_viewFinderRect);
copy.save(m_decoder->getCaptureLocation());

and set copy = screenshot.

palbr commented 6 years ago

I own a Xperia X (flashed to SailfishOS) and want to help to fix this problem. (Because I like your code reader App). My problem: I have no experience with developing / building Sailfish-Apps. So could you please provide an installer file containing your latest fixes for me to test? Or otherwise, what do I need to build and install your application?

steffen-foerster commented 6 years ago

Thanks for your offer!

I need the log file with the debugging entries. So it is necessary to start the app with the Sailfish SDK. It's not so complicated to install and run the SDK :-)

BTW: You have to enable the debugging mode on your device => it's a settings option. There you can find the IP address and the remote password.

Feel free to ask if you have any questions.

palbr commented 6 years ago

Thanks for your reply. I hope I will have time to test this tomorrow.

palbr commented 6 years ago

Ok, I have managed to install the Sailfish SDK, cloned your git repo, changed the lines

QImage copy = screenshot.copy(m_viewFinderRect);
copy.save(m_decoder->getCaptureLocation());

to

QImage copy = screenshot;

and deployed your code via the SDK to my Xperia X.

Reproducibility: I can fully reproduce the behavior, @AlmAck described above.

Debug logs: To create debug logs, I did the following:

  1. delete file /home/nemo/Pictures/capture_code.jpg
  2. open https://en.wikipedia.org/wiki/QR_code in a browser of my desktop machine
  3. in Qt Creator: build + deploy to Xperia + run your application
  4. position the Xperia on the left side of the browser window (no QR code visible, see screenshot) screenshot_20171101_001
  5. press "Scan" button in the application
  6. move Xperia to the right side of the browser window, showing this QR code: screenshot_20171101_002
  7. wait 10 seconds while slightly rotating the Xperia to reduce perspective problems => QR-Code not detected
  8. press "Abort" button in the application
  9. close application by "swipe down"

These are the logs with can be seen in Qt Creator: debug_2017-11-01_20-54.zip (hope this is the data, you wanted to see)

Additional observation: During this whole process the file /home/nemo/Pictures/capture_code.jpg is continuously rewritten to the filesystem of the Xperia. But the content is always be identical! Like @AlmAck wrote, for me it looks like this: If the file is not there, a screenshot is taken and written to the filesystem. After ?? milliseconds the process starts over: But this time, the file is found and read from the filesystem, in order to write the identical file back to the filesystem. At the end of my test, the file /home/nemo/Pictures/capture_code.jpg did show the same data as seen in the first screenshot "screenshot_20171101_001", so the QR-code detection failed.

palbr commented 6 years ago

Successful Test: Like @AlmAck wrote, I did:

  1. delete file /home/nemo/Pictures/capture_code.jpg
  2. open https://en.wikipedia.org/wiki/QR_code in a browser of my desktop machine
  3. in Qt Creator: build + deploy to Xperia + run your application
  4. position the Xperia on the right side of the browser window (QR code visible)
  5. press the "Scan" button
  6. QR code is instantly detected and correct text is decoded
  7. close application by "swipe down"

Debug logs: debug_2017-11-01_21-25.zip

Only the issue: The nice markers are no longer drawn on the QR code.

steffen-foerster commented 6 years ago

Thanks for your effort and your very good description. It is very helpful. I found the root cause for this issue:

[D] AutoBarcodeScanner::processDecode:237 - reply of method call <screenshot>: QDBusMessage(type=Error, service=":1.12", error name="org.freedesktop.DBus.Error.Failed", error message="File path for screenshot not accepted: File exists", signature="s", contents=("File path for screenshot not accepted: File exists") )

I will fix the problem, so that you can test it again.

palbr commented 6 years ago

Great news. Thanks!

AlmAck commented 6 years ago

I tested with:

         if (scanActive) {
+            if (QFileInfo::exists(m_decoder->getCaptureLocation()))
+                QFile::remove(m_decoder->getCaptureLocation());

and works fine. If you agree, I can create a merge request. Maybe would be better to remove the temporary image at the end?

steffen-foerster commented 6 years ago

Sure, you can create a pull request.

On November 2, 2017 8:34:07 PM GMT+01:00, Luca Giambonini notifications@github.com wrote:

I tested with:

        if (scanActive) {
+            if (QFileInfo::exists(m_decoder->getCaptureLocation()))
+                QFile::remove(m_decoder->getCaptureLocation());

and works fine. If you agree, I can create a merge request.

-- You are receiving this because you commented. Reply to this email directly or view it on GitHub: https://github.com/steffen-foerster/sailfish-barcode/issues/34#issuecomment-341533964

steffen-foerster commented 6 years ago

You can find the new binaries (version 0.7.12) here: https://openrepos.net/content/steffenf/codereader

It is tested with the lastest version of SailfishOS 2.1.3.7 on Jolla 1.

If you find further problems please send me the log file and all images from the directory Pictures/codereader.

AlmAck commented 6 years ago

Strange, the app downloaded from openrepos does not work, the one compiled locally does.

I noticed that with your changes the captured image is missing, I see only a black rectangle. Instead I sould see the image with the acquired markers.

monofox commented 6 years ago

Hi, for me the version on openrepos with 0.7.12 also does not work on Jolla 1, SailfishOS 2.1.3.7. Didn't tried yet with own build. Update: own compiled version works, thanks!

monofox commented 6 years ago

One more update: on Jolla Tablet (X86) it does still not work (but i guess that there is another problem based on log and debug screenshots).

See log here: codereader_debug_2017-11-05_182300.zip

steffen-foerster commented 6 years ago

The packages on openrepos were outdated. I have uploaded new versions.

I cannot find the problem for the Jolla Tablet in the log file. The images are blank. It seems the screenshot service doesn't work.

Message on your Tablet: [D] AutoBarcodeScanner::createScreeshot:295 - reply of method call <screenshot>: QDBusMessage(type=MethodReturn, service=":1.25", signature="", contents=() )

Message on my Jolla 1: [D] AutoBarcodeScanner::createScreeshot:295 - reply of method call <screenshot>: QDBusMessage(type=MethodReturn, service=":1.32", signature="", contents=() )

I only see a difference in the service version.

palbr commented 6 years ago

I tested the new code (commit febccdd1ab9516e0d592c5a8a88b4879b4a4ba45) via QtCreator without local modifications on my Xperia SailfishX 2.1.3.5: Scanning a QR code works on the Xperia! :)

Even the markers (in the corners of the QR code) are back and in correct position. 👍

Thanks!


Some minor issues (which are not necessary for the main functionality):

Scanning for a QR code seems to trigger some "screenshot"-events, which are displayed at the top of the screen on my Xperia X. When you scan for a longer time e.g. 40 seconds, many screenshot-events are triggert. And the smartphone displays each event for a few seconds. So those "top-screen-messages" are still displayed after the QR code scanning has successfully finished. But this is a very minor issue. screenshot_20171105_001

After having successfully scanned a QR code and having closed the application by swipe-down-gesture, there do remain 4 JPGs in "/home/nemo/Pictures/codereader": debug_cropped.jpg, debug_screenshot.jpg, debug_transformed.jpg, screenshot.jpg I tried your code on Github, deployed to my smartphone via QtCreator, so this is kind of "developer"-code. But since those pictures also show up in the Jolla gallery, I would suggest to remove those in the final version for harbour.

steffen-foerster commented 6 years ago

I looked at the problem with the screenshot events. I can't fix this problem with the current application design. It needs a bigger redesign so I don't need the screenshot service anymore. And this will take some time ...

steffen-foerster commented 6 years ago

@palbr I opened #37 for the notification issue.