forked from SiriusDely/Cascades-Samples
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcustombarcodescanner.qdoc
90 lines (67 loc) · 4.38 KB
/
custombarcodescanner.qdoc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
/****************************************************************************
**
** Copyright (C) 2012 Research In Motion Limited.
** All rights reserved.
** Contact: Research In Motion Ltd. (http://www.rim.com/company/contact/)
**
** This file is part of the examples of the BB10 Platform.
**
** GNU Free Documentation License
** Alternatively, this file may be used under the terms of the GNU Free
** Documentation License version 1.3 as published by the Free Software
** Foundation and appearing in the file included in the packaging of
** this file.
**
** Other Usage
** Alternatively, this file may be used in accordance with the terms
** and conditions contained in a signed written agreement between you
** and Research In Motion Limited.
**
****************************************************************************/
/*!
\page custombarcodescanner
\example custombarcodescanner
\title Custom Barcode Scanner Example
\section1 Description
The Custom Barcode Scanner example allows the user to scan a QR Code with the camera and
view the decoded textual representation.
\image custombarcodescanner-example.png
\image custombarcodescanner-example1.png
\section1 Overview
In this example we'll learn how to use the \c Camera and the build in ZXing barcode decoding
library to scan a QR code and decode it.
\section1 The UI
The UI of this sample application consists of the custom \c Camera control and a \c Label, which shows
a preview of the current camera viewport and uses the \c Label to display decoded barcode data.
\snippet custombarcodescanner/assets/main.qml 0
The BarcodeDecoder custom control shows the video stream that is currently provided by the camera viewport.
It configures and opens the \c Camera upon its creation.
\snippet custombarcodescanner/assets/main.qml 1
This \c Label is used to display the required action and the resulting decoded barcode data after a successful
barcode scan has been performed.
\snippet custombarcodescanner/src/BarcodeDecoder.cpp 0
The constructor initializes the member variables. It creates and configures the \c Camera using \c CameraSettings and connects
its methods to the signals/slots mechanism. It initializes the reader for decoding barcodes from an image, and invokes
open() on the \c Camera.
If the open() call was successful, the cameraOpened() signal is emitted, which we react to in the cameraOpened()
signal handler.
\snippet custombarcodescanner/src/BarcodeDecoder.cpp 1
This method is invoked when a preview frame buffer is available with data. Using ZXing classes to convert the buffer into
a BinaryBitmap, which in turn is used with the reader to decode the barcode and save the results. After barcode decoding is
successful, it emits the newBarcodeDetected() signal with the textual data as parameter.
\snippet custombarcodescanner/src/BarcodeDecoder.cpp 2
This method is invoked when the \c Camera is opened. It adds unsigned char buffers to store the data from the preview frame
and connects to the signal/slots mechanism to recieve previewFrameAvailable() signals. Before the method returns it starts
the view finder, which begins streaming preview frames upon its success and emits previewFrameAvailable() signals.
\snippet custombarcodescanner/src/BarcodeDecoder.cpp 3
These are control methods to start/stop view finder streaming and clearing of the barcode data variable.
\snippet custombarcodescanner/src/BarcodeScannerApp.cpp 0
The constructor initializes various member variables. It creates a \c MediaPlayer for playing sounds upon barcode detection and
intializes a \c InvokeManager to deal with invoke requests when the sample is launched as a card by the "barcodeinvoker" sample.
Here it distinguishes how it was launched and sets the appropriate member variables to dictate its behaviour as an application
or as a card.
\snippet custombarcodescanner/src/BarcodeScannerApp.cpp 1
This method is invoked when a newBarcodeDetected() signal is received from the BarcodeDecoder class. It plays a sound upon receiving
the data. If the sample was launched as a Card, a \c CardDoneMessage is generated and sent as response to the parent of this Card.
Once the card is done, it transitions off screen and is pooled (ready to be invoked again) at which time it fires a cardPooled() signal.
*/