Merge lp://staging/~dpm/qreator/touch-scanner into lp://staging/qreator/touch

Proposed by David Planella
Status: Merged
Merged at revision: 16
Proposed branch: lp://staging/~dpm/qreator/touch-scanner
Merge into: lp://staging/qreator/touch
Diff against target: 4388 lines (+4189/-50)
12 files modified
.bzrignore (+2/-0)
js/jsqrcode-combined.js (+3748/-0)
qreator-touch.qml (+49/-16)
qreator/Creator.qml (+0/-17)
qreator/Decoder.qml (+68/-0)
qreator/DeviceOrientation.qml (+37/-0)
qreator/History.qml (+2/-2)
qreator/QrCodeCanvas.qml (+4/-4)
qreator/QrCodeDialog.qml (+44/-0)
qreator/QrCodeToolbar.qml (+13/-2)
qreator/Scanner.qml (+185/-9)
qreator/UploadImageDialog.qml (+37/-0)
To merge this branch: bzr merge lp://staging/~dpm/qreator/touch-scanner
Reviewer Review Type Date Requested Status
Schwarzburg Approve
Review via email: mp+169683@code.staging.launchpad.net

Description of the change

This branch implements the initial scanning support for Qreator

# Choice of decoding backend

I've tried hard to use the JavaScript backend, but due to either the camera, JavaScript limitations, or my own limitations in JavaScript knowledge, I've not managed to get it working in a way that it offers acceptable performance on a device.

In any case, I've abstracted the decoding backend in a Decoder component, and I'll leave the JavaScript backend in the source tree for a few revisions for testing purposes and in case we need to review the decision. Switching backends is as easy as setting the useJsbackend boolean property of the Decoder component.

The main issue is that for the decoding to be fast (as in less than 30 seconds) on a device, the picture taken needs to be downscaled to about 640px width. The C++ backend does that without trouble, but I've not found a way to do it with JavaScript. Downscaling the resolution at the camera level before passing the image to the decoding backend was something else I tried, but first the camera needs to be queried for supported resolutions (otherwise if I just set its resolution to 640x480 it might or might not work), and there seems to be no way to do that in QML.

Therefore, given the fact that it's working already, I've chosen to use the C++ plugin. This means that for either developing or running Qreator the qtdeclarative5-qzxing-plugin package [1] will need to be installed.

I want to consider the decoding backend as a library (i.e. a black box with interfaces) and it not be the focus of development. It just needs a bit of polish right now, but I hope to have it done in a couple of days.

# Caveats

• Decoding is not yet automated (e.g. with a timer), in the sense that the user has to take the picture himself/herself by revealing the toolbar on the scan page and press the "Decode" action. A further iteration of the scanner will implement automatic decoding.
• The camera is always active when Qreator is running. In a further iteration we'll need to deactivate it when a) the app loses focus and b) when we switch away from the Scanner tab to another one
• The "Open" action on the dialog shown upon successful decoding does nothing yet
• There is an issue whereby the root page of the PageStack in the Create tab allows a toolbar to be revealed, when in fact there should not be any toolbar there. It seems to happen only the first time the root page is shown. Perhaps an SDK bug?

# Camera caveats

For all its awesomeness and plug-and-play feel, the QML camera component has also been a source of headaches:

• When using camera.imageCapture.captureToLocation(captureLocation); pictures don't get overwritten on the device as expected. This works on the desktop, but inexplicably, it crashes the camera on a device whenever you take a second picture that should overwrite the picture at captureLocation
• There is no way to tell the camera not to store the pictures on the filesystem, and e.g. simply pass the in-memory preview to the decoder. It's nice to be able to store the pictures taken, but we cannot do it when scanning for codes automatically, as we'd be filling the filesystem with pictures taken every half a second or so. An option might be
just to delete the files from the filesystem via the C++ plugin.
• Cannot query device resolutions from the camera, thus there is no guarantee a given resolution will be set. I.e. we cannot use a low resolution to scan images, they need to be downscaled afterwards

[1] https://launchpad.net/~qreator-hackers/+archive/qreator-experimental

To post a comment you must log in.
Revision history for this message
Schwarzburg (stefan-schwarzburg) wrote :

Hi David,

First of all: Really great work!

I played with it on the desktop and it worked quite well (except for the camera..., now I have also pictures that are half bright, half dark :-) but thats another topic...).

I'm not surprised about the increase of performance with C++, and I think we should keep that in mind as advice for others and ourselves in the future: QML/JS for the interface, C++ for intensive tasks. On mobile devices, snappy applications are important!

I do have a few minor questions:

- you wrote "qt5declarative-qzxing-plugin", but you meant "qtdeclarative5-qzxing-plugin", right?

- Did you remove the history tab since it is still empty, or did you change your mind about including it as a tab, or do you want it removed in general?

- I guess that the debug tab is just there temporary? Do you want to remove it for every release but keep it there in-between releases?

As I said, great work!

review: Approve
Revision history for this message
David Planella (dpm) wrote :

On Sun, Jun 16, 2013 at 4:18 PM, Schwarzburg <
<email address hidden>> wrote:

> Review: Approve
>
> Hi David,
>
> First of all: Really great work!
>
> I played with it on the desktop and it worked quite well

Cool, thanks!

> (except for the camera..., now I have also pictures that are half bright,
> half dark :-) but thats another topic...).
>
>
Yeah, the Camera QML module (and perhaps also the desktop GStreamer
backend) is proving to be a bit of a pain :/

> I'm not surprised about the increase of performance with C++, and I think
> we should keep that in mind as advice for others and ourselves in the
> future: QML/JS for the interface, C++ for intensive tasks. On mobile
> devices, snappy applications are important!
>
>
Indeed. Still, I haven't quite given up on it, as JS does offer advantages
for development (if performance would be on par), as it avoids the need to
do cross-compilation (or at least compile for ARM on the device itself):
I've tried to downscale the image before sending it to the JS decoder, but
so far I've been unsuccessful:

https://code.launchpad.net/~dpm/qreator/touch-decoder-improvements

In any case, I've now created a project for the C++ plugin and I'm going to
get the daily package builds from there:

https://launchpad.net/qzxing

>
> I do have a few minor questions:
>
> - you wrote "qt5declarative-qzxing-plugin", but you meant
> "qtdeclarative5-qzxing-plugin", right?
>
>
You're right, fixed it on the description.

> - Did you remove the history tab since it is still empty, or did you
> change your mind about including it as a tab, or do you want it removed in
> general?
>
>
I still want history as a tab. If I removed any content there was in it, it
was unintentional, but I didn't recall it containing anything yet.

> - I guess that the debug tab is just there temporary? Do you want to
> remove it for every release but keep it there in-between releases?
>
>
Yeah, the debug tab is temporary. You might have seen the comment where I
tried to make it "hideable" via a property, but it turns out it is not
possible at the moment (
https://bugs.launchpad.net/ubuntu-ui-toolkit/+bug/1190972).

Yes, until Qt Creator gains support for debugging code on devices it might
be worth keeping for in between releases, and comment it out for releases.

>
> As I said, great work!
>

Thanks for the review!

> --
> https://code.launchpad.net/~dpm/qreator/touch-scanner/+merge/169683
> You are the owner of lp:~dpm/qreator/touch-scanner.
>

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
The diff is not available at this time. You can reload the page or download it.

Subscribers

People subscribed via source and target branches