SlideShare a Scribd company logo
1 of 82
I
Faculty of Arts, Computing, Engineering & Sciences
Department of Computing
Final Year Individual Project (SEGM)
[55-6727]
2014/15
Author: Ismail M.I.M
Date
Submitted:
Supervisor: Dr.Pradeepa Samarsinghe
Degree Course: BEng (Hons) in Software Engineering
Title of Project: Numver (Android app to Capture Number
Based Data e.g. Scratch Cards ,and
process them )
Confidentially Required?
NO 
YES 
II
Abstract
The aim of this project is to create a mobile app which could capture an image
from a scratch card and automatically top-up a mobile account, with the
specific amount of credits for a leading mobile service provider. Users will not
have to enter the scratch card numbers manually digit by digit, which is more
prone to errors (typical scratch cards have either 16 digit or 12 digit to enter to
top-up). The app uses latest image processing and optical character
recognition technology to obtain accurate results from a given scratch card.
Adding more the app would also feature some extra functionality like package
activation (data, voice, SMS), which is usually done through inputting series of
USSD codes or through sending SMS messages to the service provider. And
app would also maintain user statistics about top-ups made in the course of
the app usage.
III
Acknowledgment
First and foremost I would like to thank Dr.Pradeepa Samarasinghe, my
project supervisor, for guiding, encouraging and supporting me during all the
stages of this project as well as helping me and guiding me through the 3 year
degree program.
I would also like to show my gratitude to Mr.Nuwan kodagoda, module leader
for the projects module for approving this project and for aiding me in finding
all necessary requirements to start my project.
Furthermore I would like thank both the past and the present lectures and
instructors of Srilanka Institute of information technology who thought me , for
guiding me with the proper skill set within this three year study in this
institution, without them I would not have accomplished up to this level.
I would also like to thank George Xian from New Zealand, mentor of Tron
academy for his continues support in helping me out with some of the technical
issues I faced during the course of this project via the internet.
Last but not least I would like to thank my papa, my sisters and my younger
brother for caring, encouraging and supporting me to complete this project on
time.
1
Table of Contents
Abstract..................................................................................................II
Acknowledgment ....................................................................................III
List of figures ..........................................................................................4
List of tables............................................................................................5
1. Introduction ........................................................................................6
2. The Usual Way ....................................................................................7
2.1 Through automatic top-up via a local store. ..................................7
2.2 Manually entering a recharge card number....................................7
2.3 Usual way for package activation..................................................8
3 Specification .....................................................................................9
3.1 Requirements ..............................................................................9
3.1.1 Scan and activate scratch card using the rear camera for a
mobile operator in Sri Lanka ..............................................................9
3.1.2 Maintain data of all top-up’s made and generate report..........10
3.1.3 Activate specific data, talk-time, and text message packages
with ease........................................................................................10
3.1.4 Enter scratch card PIN manually ...........................................10
3.1.5 Check account balance automatically ....................................10
4 Feasibility Study..............................................................................11
4.1 Why choose prepaid connections over postpaid connection for this
project...............................................................................................11
4.1.1 Results from the survey .......................................................11
5 Existing Application .........................................................................13
5.1 OCR - Text Scanner by Rishi Apps (Apps, 2015)..........................13
5.2 Invoice123 by Arlen Tung (Tung, 2015)......................................14
5.3 Text Fairy (OCR Text Scanner) by Renard Wellnitz (Wellnitz, 2015)
15
6 Software Development Methodologies ..............................................17
6.1 Scrum/Solo Scrum (Bell, 2015) ..................................................17
6.2 PXP (personal Xtreme programming) ..........................................18
6.3 Prototyping................................................................................19
6.4 Selecting the most suitable methodology for the project..............19
6.5 Use case diagram ......................................................................20
7 Selecting appropriate Technologies ..................................................21
7.1 Choosing the platform for the app to run.....................................21
2
7.1.1 Google’s android Operating system.......................................21
7.1.2 Apple’s IOS..........................................................................21
7.1.3 Android Operating System or IOS .........................................22
7.1.4 Development difficulty.............................................................22
7.2 More users than IOS ..................................................................23
7.2.1Questioner report Results ........................................................23
7.3 Choosing the image processor....................................................23
7.3.1 OpenCV...............................................................................23
7.3.2 Matlab.................................................................................23
7.3.3 FastCV from Qualcomm........................................................24
7.4 Choosing the Optical Character Recognition Engine .....................25
7.4.1 ABBYY Mobile OCR Engine ....................................................25
7.4.2 Tesseract OCR Engine ..........................................................26
7.4.3 Tested image data (for test carried out mentioned in table 3) 27
7.5 Database management ..............................................................29
7.5.1 Comparison between DBMS..................................................29
7.6 Workbench Selection (android studio or eclipse ADT)...................30
7.6.1 Android studio .....................................................................30
7.6.2 Eclipse adt...........................................................................30
7.6.3 Comparison between different IDE’s......................................31
8 Design ............................................................................................32
8.3 Folder structure .........................................................................32
8.4 Brief detail about the folder structures ........................................32
8.5 Class Diagram ...........................................................................37
8.6 Use case scenarios.....................................................................38
8.7 Wireframe models......................................................................40
9 Implementation...............................................................................43
9.3 Setting up the workbench...........................................................43
9.3.1 Installing eclipse Juno and setting up the ADT bundle ............43
9.3.2 Installing the Android NDK, CDT plugin and setting it up with
eclipse (Xian, 2015) ........................................................................44
9.3.3 Installing libraries (OpenCV, Tesseract).................................46
9.4 The process of extracting text from image ..................................47
9.5 Running the application..............................................................48
9.6 System requirements ..............................................................48
9.7 Final application.........................................................................48
9.7.1 The Numver Logo.................................................................48
3
9.7.2 Application Screenshots........................................................48
10 Testing the Application..................................................................50
10.3 Character recognition test .......................................................50
10.4 Application stability test ..........................................................51
11 Problems faced during the course of the project .............................53
11.3 Setting up the NDK .................................................................53
11.4 OCR never recognized the characters from an image accurately 53
11.5 Portrait mode did not work......................................................53
12 Further Development ....................................................................55
13 Personal Development...................................................................56
Bibliography ..........................................................................................57
Glossary................................................................................................59
Appendix I Questionnaire for Mobile phone users ......................................1
Appendix II Coding snippets.....................................................................2
Application permission and more from the manifest.xml file....................2
Imports for the application....................................................................3
Variable declarations.............................................................................4
On Create method override ...................................................................5
On camera frame sent all the methods are used in this section ...............6
Appendix III Project Specification .............................................................1
Appendix IV Ethics Form ..........................................................................4
Organizations .......................................................................................6
Adherence to SHU policy & procedures ..................................................8
4
List of figures
Figure 1 image (front) of a typical mobile data/sms scratch card in Srilanka
from dialog axiata....................................................................................9
Figure 2 image (rear) of a typical mobile data/sms scratch card in Srilanka
from dialog axiata....................................................................................9
Figure 3 image (rear) of a typical mobile value scratch card in Srilanka from
dialog axiata..........................................................................................10
Figure 4 image (front) of a typical mobile value scratch card in Srilanka
from dialog axiata..................................................................................10
Figure 5 Pie Chart for results obtained in the survey “prepaid user compared
with postpaid users" ..............................................................................11
Figure 6 Pie Chart for results obtained in the survey “prepaid user compared
with postpaid users for different operating system" .................................12
Figure 7 screenshots of similar apps "OCR-Scanner by rishi" ....................13
Figure 8 screenshots of similar apps "OCR-Scanner by rishi" ....................13
Figure 9 screenshot of similar apps “Invoice123 by Arlen Tung” ...............14
Figure 10 screenshot of similar apps “Text Fairy (OCR Text Scanner) by
Renard Wellnitz .....................................................................................15
Figure 11 Scrum Flow chart....................................................................18
Figure 12 PXP flowchart.........................................................................18
Figure 13 prototyping work flow diagram ................................................19
Figure 14 Use case scenario for the Numver mobile application................20
Figure 15 comparison of different programming difficulties for different
Operating system ..................................................................................22
Figure 16 pie chart results from the survey "different operating users within
the university".......................................................................................23
Figure 17 Test image for courier/black....................................................27
Figure 18test image for courier/gray.......................................................27
Figure 19 Test image for justy/black.......................................................28
Figure 20 Test image for justy/gray........................................................28
Figure 21 Test image for times/black......................................................28
Figure 22 Test image for times/gray.......................................................28
Figure 23 Test image for verdana/black ..................................................28
Figure 24 Test image for verdana/grey ...................................................29
Figure 25 folder structure for android using eclipse ide ............................32
Figure 26 Class diagram for Numver application......................................37
Figure 27 wireframe diagram of the main user inteface ...........................40
Figure 28 wireframe showing user balance..............................................41
Figure 29 wireframe showing the manual PIN input screen ......................41
Figure 30 wireframe showing the package selection menu .......................42
Figure 31 features of the phone used to develop the application ..............43
Figure 32 layers of android mobile architecture .......................................44
Figure 33 presumed time taken for code execution normal for java..........44
Figure 34 presumed time taken for code execution normal for compiled
language...............................................................................................45
Figure 35 illustration for multiplatform support with android ndk..............45
Figure 36 flow of a scratch card frame throughout many process .............47
Figure 37 logo of the scratch card...........................................................48
5
Figure 38 this is how the main interface looks like ...................................48
Figure 39 the confirm reload dialog box..................................................49
Figure 40 the package selection menu....................................................49
Figure 41 Number pad to input scratch card PIN manually .......................49
Figure 42 dialog box before performing a manual reload..........................49
Figure 43 setting up environment variable for Android NDK .....................53
List of tables
Table 1 Comparison of three image processing libraries...........................25
Table 2 comparison between the two OCR ..............................................26
Table 3 comparison of 4 best OCR in the market .....................................27
Table 4 comparison between databases..................................................30
Table 5 comparison between workbenches..............................................31
Table 6 brief description about all the directories in the eclipse IDE ..........36
Table 7 use case scenario to perform an auto top-up...............................38
Table 8 use case scenario to check balance............................................39
Table 9 use case scenario to perform a manual top-up...........................39
Table 10 use case scenario to activate a package...................................39
Table 11 use case scenario to view top up history ..................................40
Table 12 test results for character recognition.........................................50
Table 13 Test case for auto top-up .........................................................51
Table 14 Test case for manual reload......................................................51
Table 15 Test case for package activation...............................................52
Table 16 Test case to display top-up History ...........................................52
Table 17 Test case to show balance........................................................52
6
1. Introduction
Topping up a mobile account with a scratch card has always been a trouble
to mobile subscribers all over Sri Lanka. Subscribers who wish to add credit
to their account either has to buy a scratch card or use the reload feature
from a local store.
Most of the users do make mistake while keying in the number from the
scratch card .And some might not even know the process of toping it up.
Adding, people who are visually impaired face this difficulty the most. This
becomes verse when you have to top up multiple cards at the same time (if
the desired denominator is not available you got to key in many smaller
denominator cards to reach it)
Most of the people are not being update about special Packages (Talk Time,
Data, and SMS) and promotion offered by the mobile Service Providers.
The target of this project is to propose design and implement an android
app named “Numver” to quote the above complications.
7
2. The Usual Way
Usually users who possess a mobile phone with a prepaid mobile connection
would top-up their account either.
 Through automatic top-up via a local store.
 Manually entering a recharge card number.
2.1 Through automatic top-up via a local store.
A typical user would go to a retail outlet which provides a top-up facility
and the user will hand over his/her mobile number to the store keeper with
the money she wish to top up ,and then the store keeper would enter the
mobile number into his system, select a service provider and will top-up the
account.
Drawbacks
Users will have to handover their mobile number to an unknown.
person (store keeper), which a typical user would consider
confidential to him or herself.
At times, the funds in the store keepers system would not be enough
to perform a requested top-up.
2.2 Manually entering a recharge card number
To cater to the drawbacks present in the above method, user could use this
method, where a user could purchase a scratch card and type in the scratch
cards PIN number to perform a top-up.
Drawbacks
Users will have to enter the PIN manually which will lead to many
errors, whereas the user is prompt to enter the PIN once again.
Really annoying when a user is in a hurry.
User who have an impaired vision or user who wears spectacles will
find it difficult to read the PIN numbers at optimal view distance as
the text in the scratch card is only 5.2mm in size.
8
2.3 Usual way for package activation
Users who like to activate specific data, sms or talk time package will either
have to dial in a series of USSD codes or will have to send specific
messages to the mobile subscriber. Which at times will the user tired to do
it repeatedly.
9
Figure 1 image (front) of a typical mobile data/sms scratch
card in Srilanka from dialog axiata
3 Specification
Requirements for this project was not clear, that is why prototyping model
was chosen (for more information look section 6) but to initiate the project
some of requirements were assumed as below.
3.1 Requirements
3.1.1 Scan and activate scratch card using the rear camera for a
mobile operator in Sri Lanka
A typical user should be able to capture a scratch card and top up his
mobile account with aid of his/her smartphone’s built in rear camera.
A couple of scratch cards from Dialog axiata, which is used to top up an
account
5.2mm
M
10
Figure 4 image (front) of a typical
mobile value scratch card in Srilanka
from dialog axiata
Figure 3 image (rear) of a typical mobile
value scratch card in Srilanka from
dialog axiata
3.1.2 Maintain data of all top-up’s made and generate report
User is prompted to enter the amount that he/she is going to top-up before
proceeding with a top-up so that all top-up data will be stored ,which in turn
would help users to review their top-up data.
3.1.3 Activate specific data, talk-time, and text message
packages with ease.
Users will also have the freedom to activate or deactivate data /text/talk
time plans via the app its self .Which makes it easier ,whereas usually users
will have to send multiple text message or USSD codes.
3.1.4 Enter scratch card PIN manually
User will also be able to enter a scratch card manually, as due to bad
lighting if the application fails to identify the PIN number from the scratch
card.
3.1.5 Check account balance automatically
User will be able to check their account balance without leaving the app to
make sure a top-up was success full or not.
5.2mm
M
11
4 Feasibility Study
A feasibility study was carried out before the commencement of the project,
to make sure the project was a successful one. Many aspects of the project
was discussed along with the supervisor to make sure this app was
success, decision were derived after a survey which was conducted within
the university premises for around 100 participants (university students)
(Appendix I), the results obtained is briefed below .
4.1 Why choose prepaid connections over postpaid
connection for this project
It’s obvious that users cannot top-up a postpaid account, furthermore it was
researched that most users in Sri Lanka own a prepaid connection rather
than a postpaid connection, after gazing at the results that was obtained
during the survey within the university it was decided that this project will
be of great use for many people who own a prepaid connection.
4.1.1 Results from the survey
Prepaid Users vs Postpaid users
Prepaid user post paid users
Figure 5 Pie Chart for results obtained in the survey “prepaid user compared with postpaid
users"
12
As it is demonstrated in the above diagram, number of students who own a
postpaid connection is as less as 27% than who own a prepaid connection
who stay in a peak of 73%, when considering android users it is the same
case too. This is also the same when considering the mobile connections
provided by one of the top services provider in Sri Lanka .Dialog axiata PLC
limited, in their fact sheets (Axiata, 2015) say that they have 8,714,005
customers over all and out of which only 962,892 are postpaid customers
and rest of the 7,751,113 are prepaid customers this shows that more users
are prepaid.
This was why prepaid connection was chosen rather than a postpaid
connection.
After a vigorous study, the project was finalized by the supervisor as a
feasible one. And then the project began its Design pace.
android - prepaid and post paid
IOS Android postpaid Prepai
Figure 6 Pie Chart for results obtained in the survey “prepaid user compared with postpaid
users for different operating system"
13
5 Existing Application
There are no specific application which resembles “Numver” directly, some
of these OCR apps which were found on Google’s Play store which uses
similar features as Numver are listed below.
5.1 OCR - Text Scanner by Rishi Apps (Apps, 2015)
Figure 7 screenshots of similar apps "OCR-Scanner by rishi"
Figure 8 screenshots of similar apps "OCR-Scanner by rishi"
This app lets users load a Pre captured image and then enhance it, after
which the image is passed to an ocr engine and then the text is extracted.
14
Drawbacks
The main drawback using this app is that users cannot capture an
image in app, rather they will have to use an image which is already
captured.
5.2 Invoice123 by Arlen Tung (Tung, 2015)
Figure 9 screenshot of similar apps “Invoice123 by Arlen Tung”
This app keeps track of all your invoice by scanning the invoice number and
then by scanning the price it also has more added features like scanning bar
codes, QR codes and so on.
Drawbacks
Poor Language support (does not support English).
15
5.3 Text Fairy (OCR Text Scanner) by Renard Wellnitz (Wellnitz,
2015)
Figure 10 screenshot of similar apps “Text Fairy (OCR Text Scanner) by Renard Wellnitz
Text Fairy (OCR Text Scanner) by Renard Wellnitz does a similar work like
what Numver does. It also uses the back camera of an android device and
captures an image and extracts all the texts from it .Main purpose of the
app is to convert font styles so that users could read the text they prefer in
a font style which they prefer.
Some other features of Text Fairy
• Perform OCR (optical character recognition).
• Correct the viewpoint of an image.
• Edit extracted text.
• Copy extracted text into the clipboard for use in other apps.
• Convert the scanned page into PDF.
• Recognizes printed text from more than 50 languages.
Benefits
Could customize the size of area to be scanned.
Drawbacks
Because Text Fairy is still in its testing phase most of its functionality
are still buggy.
So at times results might not be accurate
16
After considering all these application, there were no specific app to read a
scratch card and perform an operation with it, rather all the above listed
apps where mainly used to extract text’s only.
17
6 Software Development Methodologies
To keep track of project and to maintain and optimize both time and quality
of the project a Software Development Life cycle has to be chosen. After
some heavy effort of research, found out some of the SDLC which will suit
the requirements of Numver .They are listed below
 Scrum/Solo SCRUM
 Prototyping
 PXP (personal Xtreme programming).
6.1 Scrum/Solo Scrum (Bell, 2015)
Solo Scrum is also known as scrum for one. Scrum is an iterative and
incremental methodology based and responsive to project development. A
key principle of scrum is the recognition that for a customer project can
change their minds about what they want and need (often called "
requirements churn " ) , and that unforeseen challenges cannot be handled
easily, predictively or traditional planned. As such, it adopts a mixed
approach accepting that the problem cannot be fully understood or defined,
focusing on maximizing the team's ability to deliver quickly and respond to
new empirical requirements. And what Dr.Jeff (Sutherland, 2015) says in
his article .Scrum divides complex work into simple pieces, large
organizations into small teams and far-reaching projects into a series of
short time horizons called sprints.
When complex work is divided into simple pieces it is easier to map out
what needs to be done. With a clear roadmap the team can start working
immediately, know what items need to be worked on together and
understand when the job has been completed. Small bites of work, just like
food, are easier to chew, swallow and digest.
So solo scrum is where a single person is going to perform all the task of
multiple stakeholders in a project .Even though it is not an official SDLC
people who have tried it say that they can perform and accomplish really
heavy tasks with ease (Bell, 2015)
Benefits
No need for a team .A single person could work as if he is a team.
18
Drawbacks
Not official, so no proper documentation to follow.
No Client in project, as Numver is not a bespoke project, so cannot
evaluate with a client time to time
Figure 11 Scrum Flow chart
6.2 PXP (personal Xtreme programming)
Personal extreme programming is once again another agile based SDLC for
autonomous developers which allows two individuals to perform all the
stages of the project. While an individual works on a single aspect of the
software the next persons monitors it and the vice versa. This is done in
iterative way until the final stage of the project. As mentioned by (Yani
Dzhurov, 2009) and also what the figure depticts .
Figure 12 PXP flowchart
19
6.3 Prototyping
The prototype model is a systems development methodology in which to
realize the project requirements of a prototype system is made that
implements the known characteristics , this then can be presented , used
and tested by all stakeholders before going back to the development team
to be reformulated for the next prototype stage to be made (Rouse, 2005).
This model is advantageous when you need a solution quickly. The
prototyping model allows users to participate actively in the development,
allowing any bugs to be detected early and corrected before the final
release (ISTQB Exam Certification, 2015).
Figure 13 prototyping work flow diagram
6.4 Selecting the most suitable methodology for the project
After vigorous research it was decided that prototyping would rather suit
best for this project as the features that would be available in the final
product could be depicted, then a prototype could be made and after letting
a user use the developed prototype further adjustments could be made to
suit the feedback of the user so that all the requirements could accurately
cater to user’s requirements.
20
6.5 Use case diagram
Application User
Scan a scratch card and perform a top-up
Check Balance
input scratch card PIN manually
activate
data,sms,talk time packages
share application online
generate report on all top-ups performed using the app
Figure 14 Use case scenario for the Numver mobile application
21
7 Selecting appropriate Technologies
7.1 Choosing the platform for the app to run
7.1.1 Google’s android Operating system
Google maintains an operating system called Android. It has all the low -
level "stuff” as well as the necessary middleware power use an electronic
device, and is freely given to anyone who will take the code and build the
operating system from it. There is even a complete application framework
included, so third party applications can be built and installed then available
for the user to run as they like.
The name for this is the project of the Android Open Source Project, and
that's what people mean when they say things like Android is open and
free. Android, in this iteration, is free for anyone to use as they like.
(Hildenbrand, 2015)
7.1.2 Apple’s IOS
IOS is the mobile operating system from Apple used to run the iPhone, iPad
and iPod Touch popular. Formerly known as iPhone OS, there are more than
900,000 applications available for download on Apple IOS App Store, the
most popular application store any mobile device. IOS uses a multi -touch
interface, where simple gestures are used to operate the device, such as
swipe the screen to move to the next page or pinch your fingers to zoom
out.
Since its release, IOS has gone through several updates, with recent
updates by adding the ability to create folders for application icons and the
ability to multi- task. Updates are usually free for iPhone and iPad users,
while iPod Touch users are sometimes required to pay a fee.
(Nations, 2015)
22
7.1.3 Android Operating System or IOS
Choosing between Google’s android OS with Apple’s IOS was a difficult task.
Development vise both of them had enough resources. But choosing the
best for this project was a tough job .At first it was decided that the app
would run on both platform, but after performing the survey (appendix I), it
was found that most prepaid mobile users used an android based device
rather than IOS device. So it was worthless to spend more time developing
for both the platform thus android operating system was chosen also with
the following points considered.
7.1.4 Development difficulty
Figure 15 comparison of different programming difficulties for different Operating system
This shows that android is somewhere in the middle of difficulty in
developing apps as mentioned by (Pundits, 2015).
23
OS Users
Android IOS other
Figure 16 pie chart results from the survey "different operating users within the university"
7.2 More users than IOS
After considering the results obtained from the survey it was found that
more students use an android based device rather than an ios device.
7.2.1Questioner report Results
7.3 Choosing the image processor
OpenCV (open computer vision), Mathworks Matlab or Qualcomm’s FastCV
Choosing one from these was a difficult task.
7.3.1 OpenCV
OpenCV is an open source image processing Library which could be used
develop application which features image recognition or image processing,
recommended by most of the developers (anonymous, OPENCV,
2015),OpenCV runs directly on androids kernel which makes it one of the
faster image processing libraries.
7.3.2 Matlab
Matlab is a relatively easy language to start. Matlab is really a high-level
scripting language, which means you do not have to worry about libraries,
declaring variables, memory management or other low-level programming
24
problems. As such, it can be very easy to throw together some code to
prototype your image processing idea. (anonymous, matworks, 2015).
7.3.3 FastCV from Qualcomm
FastCV provides an optimized mobile computer vision library that packs if
image processing tools most widely used for use in a wide variety of mobile
devices, even mass-marketdevices. (Qualcomm, 2015).
OPENCV MATLAB FASTCV
specificity Made for image
processing only
Made as a generic
image processor
Made for
image
processing
only
Speed 30 frames per
second( real
time)
3-4 frames per
second(not real
time)
Not real time
Efficiency Less resources
needed (good for
mobile devices
with less
resources)
More resources
needed compared
to OpenCV
Moderate
amount of
resources
needed
Ease of
programming
Hard compared
to Matlab
Easy moderate
IDE availability No specific IDE
(should configure
an IDE with
OpenCV before
use)
Matlab integrated
IDE available
No specific
IDE (should
configure an
IDE with
FastCV before
use)
Memory
management
Really low
considered to
Matlab
High memory
management
unknown
Price Free(open
source)
List price for the
base (no
toolboxes)
free
25
MATLAB
(commercial,
single user
License) is
around €1500
euros
Mobile support OpenCV for
android
Not supported supported
Mobile
Architecture
support
All leading
mobile
architecture
Not applicable ONLY ARM
based
processors
Table 1 Comparison of three image processing libraries
7.4 Choosing the Optical Character Recognition Engine
After the frame is captured and processed using OpenCV image processing
libraries, the processed frame will be passed on to an OCR which will extract
the PIN number from the frame so that the pin number can be manipulated
and can be used for the top up process (see section 9 for more info).
To select the best OCR libraries available a comparison was made between
“ABBYY Mobile OCR Engine” and “Tesseract OCR”.
7.4.1 ABBYY Mobile OCR Engine
Abbyy OCR Engine aids developers integrate OCR into smartphones, the
SDK provided by them helps users to convert images and photographs into
a digital source which can be edited and used to search and so forth
(unknown, 2015)
Abbyy OCR Engine is by far the best OCR available in the market its rates of
recognition is really good in compared to other OCR engines (look table 2)
in the market, the only drawback it has is that it comes as a commercial
version where developers have to pay to get a license.
26
7.4.2 Tesseract OCR Engine
Released under the Apache License 2.0. (apache, 2015), On the other hand
Tesseract is rated for its best accuracy among three other OCR engine in
the market. It has its advantage as it is open source so it is free of charge.
Comparison of the two selected OCR.
Abbyy OCR Tesseract OCR
specificity Made for
character
recognition
Made for character
recognition
Speed Really low
compared to
Tesseract
Fast
Efficiency Less resources
needed (good for
mobile devices
with less
resources)
More resources
needed compared
to Abbyy
Ease of
programming
Hard Easy
Price 15 000 USD with
ABBYY Mobile
Imaging OCR SDK
Free(open source)
Mobile support yes yes
Mobile
Architecture
support
All leading mobile
architecture
All leading Mobile
architecture
Table 2 comparison between the two OCR
27
Comparison of leading OCR for Linux based operating system courtesy
(Gohr, 2015) .
ABBYY
OCR
CUNEIFORM GOCR OCRAD TESSERACT
License Proprietary BSD GPL2 GPL3 Apache 2.0
Version 8.0 0.9.0 0.48 0.19 SVN r402
Input-Format PNG1)
PNM PNM PNM TIF2)
Recognition rates and time spent:
courier/black 100%
(2.92s)
61%
(1.11s)
67%
(0.09s)
21%
(0.02s)
81%
(0.63s)
courier/gray 100%
(2.85s)
67%
(0.09s)
21%
(0.03s)
81%
(0.63s)
justy/black 11%
(3.62s)
3%
(1.14s)
31%
(0.11s)
1%
(0.02s)
15%
(0.61s)
justy/gray 14%
(3.45s)
31%
(0.10s)
1%
(0.02s)
15%
(0.60s)
times/black 100%
(2.80s)
96%
(1.07s)
76%
(0.16s)
82%
(0.03s)
92%
(0.74s)
times/gray 100%
(2.87s)
76%
(0.16s)
82%
(0.03s)
92%
(0.74s)
verdana/black 100%
(2.90s)
95%
(1.07s)
98%
(0.10s)
98%
(0.03s)
98%
(0.45s)
verdana/gray 100%
(2.85s)
98%
(0.10s)
98%
(0.02s)
98%
(0.46s)
Table 3 comparison of 4 best OCR in the market
7.4.3 Tested image data (for test carried out mentioned in table 3)
Figure 17 Test image for courier/black
Figure 18test image for courier/gray
28
Figure 19 Test image for justy/black
Figure 20 Test image for justy/gray
Figure 21 Test image for times/black
Figure 22 Test image for times/gray
Figure 23 Test image for verdana/black
29
Figure 24 Test image for verdana/grey
Images and tables used for above test are the courtesy of (Gohr, 2015).
After many consideration, a final decision was made as to use Tesseract,
because Tesseract is really fast in generating outputs (table 3) and it is also
praised for its accuracy which are some of the vital requirements for this
project.
7.5 Database management
To manage data within the app a local database was required for this
purpose.
Two already existing database management system was selected and
compared.
7.5.1 Comparison between DBMS
SQLite H2 database engine
Footprint 350KiB ~1MB
License Public domain Dual: Modified MPL 1.1 / EPL
1.0(commercial friendly)
Self-contained ✔ ✔
Single file ✔ ✔
Server less ✔ ✔
Server-mode ✖ ✔
Zero-
configuration
✔ ✔
Transactions ✔ ✔
30
Indices ✔ (B-tree, R-
tree, full-text)
✔ (B-tree, tree, hash, full-text)
Encryption ✖ ✔
In-memory
databases
✔ ✔
Android native
support
✔ ✖
Table 4 comparison between databases
SQLite was chosen as it was really user friendly and it had native support
for android so that adding extra libraries to the application is omitted thus
reducing the file size of the final application.
7.6 Workbench Selection (android studio or eclipse ADT)
This was one of the toughest choice to make, both of them had their pros
and cons, and some of them are tabulated below.
7.6.1 Android studio
Android studio is the official IDE to develop android application which was
released on December 2014 as version 1.0, it is based on Jetbrain’s IntelliJ
IDEA (IDEA, 2015) it supports multiple operating system like Windows, Mac
OS X and Linux. (anonymous, android, 2015).
7.6.2 Eclipse adt
Eclipse Android development tool is really a plugin for the already existing
eclipse IDE, both the ADT and the android sdk has to be installed before
using eclipse for android application developed (anonymous, android,
2015).
31
7.6.3 Comparison between different IDE’s
Android studio Eclipse ADT
Ease of use Easy Easy
Bugs As it is new might
possess some bugs
Less chances of
finding a bug
Online helps Very few as it is new Sufficient amount of
help available
IDE
Performance/Stability
Not stable as it
contains bugs but
overall experience is
smooth
Stable but is resource
hungry need more
ram for pure smooth
experience
Project Organization Good Good
User Interface
Design
Really good Somewhat better
Table 5 comparison between workbenches
32
8 Design
The android app which will later be packed and deployed as a single apk,
will first be created using the selected Eclipse IDE, the folder structure of a
typical android application is briefed below.
8.3 Folder structure
8.4 Brief detail about the folder structures
Directory Description
src This is where all the user defined
logics is coded.
gen This directory on an Android
application consists of all the files
automatically generated. You can
Figure 25 folder structure for
android using eclipse ide
33
see R.java within this folder, which
is a generated class that contains
references to certain project assets.
R.java is created automatically by
the Eclipse IDE and any manual
changes are not necessary.
res This directory on an Android
application consists of all the files
automatically generated. You can
see R.java within this folder, which
is a generated class that contains
references to certain project assets.
R.java is created automatically by
the Eclipse IDE and any manual
changes are not necessary.
/res/values It is used to set styles, strings,
colors, dimensions and static
arrays. By convention each type is
stored in a separate file, for
example, strings are defined in the
file res / values / strings.xml, so on
and so on.
/ Res / values - v16 is the API
version of the 16 values (android
version 4.1 Jellybean), and / res /
values - v15 is the API version of
the 15 values (version 4.0.1
android ice- cream sandwich).
/res/animator This directory includes XML
animation for animation API
property that lets you animate
properties of random objects over
time.
/res/layout This directory contains the layouts
to be used in the application. A
34
layout feature shows the
architecture for the user interface in
an activity or a component of a
UI.As Android device support
multiple screen sizes, these
resource directories in an
application provides several layout
templates for different screen sizes.
/res/layout - layout for normal
screen size or default screen size.
/res/layout-small - layout for
small screen size.
/res/layout-large - layout for
large screen size.
/res/layout-xlarge -layout for
extra-large screen size.
/res/layout-xlarge-land - layout
for extra-large in landscape
orientation.
/res/layout-sw600dp - layout for
tablets or layout for 7” tablets
(600density pixel (dp) wide and
bigger).
/res/layout-sw720dp - layout for
10” tablets (720dp wide and bigger)
/res/layout-w600dp - layout for
Multi-pane (any screen with 600dp
available width or more).
./res/menu This directory menu consist of
resources to be used in the
application.
/res/raw Resource materials that can be
searched by their resource IDs are
stored in this directory. These
35
features can be referenced from all
other resources in the same way we
do with other resources.
/res/drawable The folders are resource directories
in an application that provides
different bitmap drawable for
medium , high screens , and extra
high density./res/drawable-mdpi
- bitmap for medium density
/res/drawable-hdpi - bitmap for
high density
/res/drawable-xhdpi - bitmap
for extra high density
/res/drawable-nodpi - bitmap
with no pre-scaling.
libs External library files are placed in
this folder. If you want to add any
external library in place the jar
library project within this folder will
be added to the class path
automatically.
Assets This directory has the gross
structure of files and directories
without other capabilities. It's just a
hierarchy of unstructured files ,
allowing you to put whatever you
want there and later recover as raw
Byte streams.
bin Bin is that the use of the compiler
to prepare the files to be finally
packaged for application APK file.
this includes
• Compile your Java code into class
files.
36
 Place your resources
(including images) in a
structure to be compressed
to the APK.
AndroidManifest.xml This is an XML control file that
stores key information about the
application to the Android system,
the system information should have
been added to it before it can run
any application code. This control
file describes the nature of the
application and each of its
components, such as the granting
of permission to access device
features.
project.properties Project.properties is the main
project properties file with the
extension “.properties “containing
information on the construction
platform destination and the library
dependencies. Project.properties
file was renamed default.properties
in older versions of the SDK. This
file is essential for the project to be
executed.
Table 6 brief description about all the directories in the eclipse IDE
37
8.5 Class Diagram
This basic class diagram shows the classes and functions of the application.
Android Activity
Numver main Activity
-pin_number:int
-last_balance:float
-topup_history:float[0.*]
-total_top_made:float
+scanCard(output:int)
+sendTextToReload(input:int,output:bo
ol)
manupilateString(input:string,output:stri
ng)
+checkBalance(output:int)
+activatePackage(input:string)
+manual_reload(input:double)
Scratch Card
-scartc_card_number:double
-maxminm_price_LKR:float
+setScratchCardPIN(input:double)
+getScratchCardPIN(output:double)
Data/SMS card
data_value:int
sms_value:int
+setDataValue(input:int)
+getDataValue(output:int)
+setSmsValue(input:int)
+getSmsValue(output:int)
Talktime card
-taltime_value:int
+setTalktimeValue(input:int)
+getTalktimeValue(output:int)
IDD card
-idd_talktime:int
+setIDDTalktimeValue(input:int)
+getIDDTalktimeValue(output:int)
Package
-package_name:string
-package_id:int
-packge_details:String
+activatePackage(input:String,output:bo
ol)
+deactivatePackage(input:String,Outut;b
ool)
1
0 ..*
User
1
0..*
1
1
Figure 26 Class diagram for Numver application
A user can have many packages, he/she can also activate as many scratch
card as possible from the app. scratch cards are of 3 different types they
are Data/sms cards, Talk time only cards and IDD cards, all these cards
possess their own properties and they also possess some properties in
common, which is centralized in a class called scratch card.
38
8.6 Use case scenarios
1.Use case name: Perform automated reload
2.precondions: Have a valid scratch card
3.Primary Actor: App user
4. Main Flow of Events: 1.User aims the scratch card
towards the rear camera
2. Selects the value of the scratch
card.
4. Aligns the PIN number with the
aid of the green box.
5. Taps the top up button.
6. Taps the dialog box PIN value
with the scratch card PIN value.
7. Taps okay button
8. App performs the reload
4.extensions 4(a). If the pin number is less than
or greater than 12 digits or 16
digits (depending on the mobile
subscriber)
4(a) 1.show dialog box saying
wrong integer count
4(a) 2.start from step 2
Table 7 use case scenario to perform an auto top-up
1.Use case name: Check user account balance
2.precondions: Started the application.
3.Primary Actor: App user
4. Main Flow of Events: 1.Taps check balance button
2. App checks the balance and
displays it.
39
4.extensions
Table 8 use case scenario to check balance
1.Use case name: Perform manual Top-up
2.precondions: Have a valid scratch card
3.Primary Actor: App user
4. Main Flow of Events: 1. Taps the manual top-up button.
2. Enters the PIN with the number
pad.
3. Taps okay.
4. Taps confirm in the dialog box.
4.extensions 2(a). If the pin number is less than
or greater than 12 digits or 16
digits (depending on the mobile
subscriber)
4(a) 1.shows a dialog box
saying wrong integer count
4(a) 2.start from step 2
Table 9 use case scenario to perform a manual top-up
1.Use case name: Activate packages
2.precondions: App is open and loaded
3.Primary Actor: App user
4. Main Flow of Events: 1.Taps on package selection button
2. Select appropriate package the
user requires.
3. App activates the package.
4.extensions
Table 10 use case scenario to activate a package
1.Use case name: Display top up history
2.precondions: App is open and loaded
3.Primary Actor: App user
4. Main Flow of Events: 1.Taps on top-up history button
3. App displays the top-up history.
40
4.extensions
Table 11 use case scenario to view top up history
8.7 Wireframe models
Wireframes for the GUI, developed using the above requirements
Figure 27 wireframe diagram of the main user inteface
Designed using ninja mock (ninjamock, 2015)
Wireframe is accessible via here
A This will redirect to package selections page.
B Shows the logo of the mobile subscriber the smartphone is
registered to.
C This will prompt the user with the current balance of his connection.
D Enables user to manual input a pin if the scanning of the scratch
card gives an inaccurate result.
E This green box is a guideline to the user, it helps the user to align
the PIN number for the scan to proceed.
F Once the user aligns the PIN number within the green box he/she
has to press this button to proceed with the top up.
G This shows a brief report of all the top the user has during the use of
this app.
H The camera view which shows the camera in the background.
41
I User will have to select one of this option based on the card they
top-up, so that it would be helpful to generate reports.
More wireframes
Figure 28 wireframe showing user balance
This dialog will be shown after the user presses the check Balance button
Figure 29 wireframe showing the manual PIN input screen
This dialog is shown when the user presses the input PIN button
42
Figure 30 wireframe showing the package selection menu
This dialog is shown when the user press he activate package button
43
9 Implementation
After the designing phase, the implementation phase began, where the
workbench was set and all the resources where optimized to its best.
9.3 Setting up the workbench
Setting up the workbench can be divided into three
 Installing eclipse Juno and setting up the ADT bundle.
 Installing Android NDK, CDT plugin and setting it up with Eclipse.
 Installing libraries (OpenCV, Tesseract).
9.3.1 Installing eclipse Juno and setting up the ADT bundle
This was a piece of cake compared to others, the eclipse package was
downloaded from their official website (ecllipse.org, 2015) , after which
android adt bundle was installed within eclipse with the help of the built in
software installer, which is found under help –>install new software.
A real device was used for debugging purpose as the project uses a
compulsory rear facing camera
For this purpose an ASUS zenfone 5 was used
9.3.1.1 Asus zenfone 5 features
Screen Size 5.0 inches (~63.9% screen-to-body
ratio), 720 x 1280 pixels (~294 ppi
pixel density)
Camera 8 Megapixel, 3264 x 2448 pixels
with autofocus
Processor Dual-core 2 GHz, Intel Atom Z2580
Ram 2 GB
Network GSM / HSPA
Platform Android OS, v5.0.2 (Lollipop).
Figure 31 features of the phone used to develop the application
44
Figure 32 layers of android mobile architecture
9.3.2 Installing the Android NDK, CDT plugin and setting it up
with eclipse (Xian, 2015)
9.3.2.1 About android NDK
Now this is where things get a bit complicated .First let’s have a look at
what Android NDK is. Android NDK or Android native development kit is a
set of tools which allows a developer to implement parts of their app using
native-code languages such as C and C++. Typically, good use cases for the
NDK are CPU-intensive applications such as game engines, signal
processing, and physics simulation.
Usually all android apps run in the dalvik virtual Machine, as it takes time to
execute a code it will not suite our use case where top-up should be
processed in real time.
This is were android
executes the code usually.
Android code execution goes through JVM(which is the dalvik virtual
machine in android) and then the Hardware layer after which it is
executed,which consumes a lot of time.
Figure 33 presumed time taken for code execution normal for java
For real-time
image processing
the code should
execute in here
45
Figure 34 presumed time taken for code execution normal for compiled language
*Diagrams are not an actual depiction of time taken of a CPU fetch-decode-execution cycle,
only for illustrative purpose.
But if we use android NDK we could bypass the dalvik VM and execute the
code directly in the Linux kernel (hardware decode only) (Xian, 2015)
So in this case Android NDK is used by the OPENCV library to process
images in real-time.
Drawbacks
The only drawback in this is that the application should carry libraries for all
CPU architecture which considerable increases the package file size.
Figure 35 illustration for multiplatform support with android ndk
9.3.2.2.Installing Android NDK and CDT plugin
First the setup file was downloaded from android NDK (android, 2015)
website, after installing the ndk with the help of the setup file .eclipse was
configured with android ndk this documentation gave a helping hand in
setting up the ndk (opencv, 2015) , the CDT plugin was also downloaded
like the adt plugin with the help of Eclipse’s built in software manger
46
These are the steps taken to setup android NDK and CDT plugin
 Install NDK setup in a convenient location. (An important point to
consider when installing the ndk is to omit any spaces in the
installation file path names).
 Open Eclipse IDE and install the NDK plugin provided by android from
help->install new software menu and restart eclipse
 Now in eclipse go to windows-> preferences-> NDK and provide the
folder path where you have installed all the ndk files before on step
one.
This is how the android NDK was supposed to be installed with the help of
the document (opencv, 2015) but there was a problem using this method
which will be briefed on ‘problems faced’ section 11.
9.3.3 Installing libraries (OpenCV, Tesseract)
Installing libraries was simple, within eclipse you have to import the library
as an existing android project, then go to project properties of the imported
Library->Android-> and select ‘is Library’ option under Library.
This was done for both OpenCV 3.0 and Tesseract.
Additionally for Tesseract the whole library has to build for all processor
architecture.
In command prompt change the working directory to where the library is
and then run the “ndk-build” command.
It took around 2 hours for the whole library to build. (Raghavan, 2015).
And to run Tesseract extra language data files were needed which could be
found in (google, 2015). This file was placed on the device’s SD card root
folder so that Tesseract library could access it.
After which a new project was created for Numver application.
Information about code samples is present in the appendix II section
47
9.4 The process of extracting text from image
Figure 36 flow of a scratch card frame throughout many process
The above diagram shows the flow of a selected frame, which is passed
between a couple of libraries for text to be extracted.
Within OpenCV the following image manipulation is processed with the
incoming frame
 Crop the area with PIN number separately so that the image will be
processed quickly, rather than processing a whole frame, processing
a small position of screen is more efficient and further more
unwanted data which will be present on the frame will not be
processed.
 Change the cropped frame to grayscale for maximum efficiency.
 Apply a median Blur for the cropped frame
o “The median filter run through each element of the signal (in
this case the image) and replace each pixel with the median of
its neighboring pixels (located in a square neighborhood
around the evaluated pixel).” (OpenCV, 2015)
 Apply an adaptive threshold and then send it to Tesseract
o “In this, the algorithm calculate the threshold for a small
regions of the image. So we get different thresholds for
different regions of the same image and it gives us better
results for images with varying illumination.” (author, 2105)
48
Figure 38 this is how the main
interface looks like
9.5 Running the application.
After implementation of the code, it should run on the following device
9.6 System requirements
Minimum requirements
 Android device with an API level 16 or more (android 4.1 jelly bean)
 A rear camera.
 A single core 1000mhz or more CPU
Recommended requirements
 Android device with an API level 21 or more (android 5.0 lolipop)
 A rear camera 5 megapixel sensor or more.
 A dual core 2.0 GHz or more CPU.
9.7 Final application
These were some of the screenshots captured from the Numver application
9.7.1 The Numver Logo
9.7.2 Application Screenshots
Figure 37 logo of the
scratch card
49
Figure 39 the confirm reload dialog
box
Figure 40 the package selection
menu
Figure 41 Number pad to input
scratch card PIN manually
Figure 42 dialog box before
performing a manual reload
50
10 Testing the Application
Many test where carried out to make sure the application was stable and to
make sure that the users had the best user experience.
Some such test are listed below
10.3 Character recognition test
The app was tested for its Character recognition accuracy on scanning
different scratch cards under different lighting conditions, and the results
are tabulated below.
Scratch card Pin Value Scanned results
1 3566 9208 9321 356692089321
2 9184 5765 8971 918457658971
3 7251 0780 7854 725107807854
4 9584 8475 7384 958484757384
5 7683 6572 7682 768300727682
6 6748 2642 7583 674826427583
7 5738 7485 2637 573874852637
8 8593 0473 8237 859304738237
9 7584 6423 8492 758462238492
10 8694 3838 8483 869438388483
Table 12 test results for character recognition
Character recognition test was not one hundred present successful as there
were some numbers that Tesseract miss extracted, the reason for this
inaccuracy should be due to bad lighting, and if a user face this problem
he/she might use the manual PIN enter function.
51
10.4 Application stability test
The application was vigorously tested for possible bugs and the results are
as follows
TEST TYPE Auto Top-up
STEPS 1. Aim scratch card towards the
camera
2. Select the value of the scratch
card.
4. Align the PIN number.
5. Tap the top up button.
6. Tap OK in the dialog box PIN
value with the scratch card PIN
value.
7. Tap okay button
TEST RESULTS App performs the automatic top-up
successfully after performing the
above steps.
Table 13 Test case for auto top-up
TEST TYPE Perform manual top-up.
STEPS 1.tap the manual top-up button
2.enter the PIN with the number
pad
3.tap okay
4.input the amount to top-up
5.tap confirm in the dialog box
TEST RESULTS App performs the manual top-up
successfully after performing the
above steps.
Table 14 Test case for manual reload
TEST TYPE Activate specific packages
52
STEPS 1. Tap activate package button.
2. Tap a specific package.
3. Confirm the dialog box.
TEST RESULTS App Activates the specified package
and displays a success dialog box
Table 15 Test case for package activation
TEST TYPE Display top up history
STEPS 1. Tap top-up history.
TEST RESULTS App Display all top history
Table 16 Test case to display top-up History
TEST TYPE Check user account balance.
STEPS 1.tap check balance button
TEST RESULTS App Display balance credit
Table 17 Test case to show balance
53
11 Problems faced during the course of the
project
Projects are meant to find solutions for a specific problem, but this project
had more problems than what was expected. Some such are briefed below
11.3 Setting up the NDK
As mentioned in section 9, both the OpenCV and the Tesseract OCR never
worked as suggested by (Xian, 2015) after some searching, found out that
setting up Android ndk path within the eclipse ide did not work for OpenCV
but setting the Android ndk path as separate variable within windows
environment variables was detected by OpenCV, and he libraries worked as
expected.
Figure 43 setting up environment variable for Android NDK
11.4 OCR never recognized the characters from an image
accurately
At first after receiving a frame from OpenCV and passing it to Tesseract just
gave garbage values, after applying many filters to the frame some
accurate results were obtained. This was one of the toughest problem to
overcome, After many trial and error method of changing the parameters
which was passed to the filters the results started to turn better and after
days of tweaking the parameters, Accuracy was increased to a level so that
results where even better at low light.
11.5 Portrait mode did not work
OpenCV natively supported only landscape mode, but users’ preferred to
use this application in portrait mode. Steps were taken to convert the
54
application to portrait mode, for this purpose Library files where altered,
after altering the library files the application worked in portrait mode, but
the performance was considerable low, So when compared to user
satisfaction and usability, usability should be given a high priority, so
portrait problem was ignored, thus the application was developed in
landscape mode.
There were more small problems which were later resolved with the help of
the internet.
55
12 Further Development
Many aspects of this application could be improved. Firstly this app could be
developed to support multiple mobile service providers rather than just one,
so that more users could benefit from this application.
Furthermore the accuracy of the character recognizer could be increased by
either training the already existing Tesseract engine or changing the OCR
engine to a more reliable one.
The interface of the application should be improved as currently it is not
that user friendly
The application does not support multiple SIM devices, only the first active
SIM is taken to consideration when the application is used. But this
application could be developed to support multiple SIM devices.
56
13 Personal Development
Throughout the development of this project a great quantity of wisdom was
learned, from Image processing, character recognition, android app
designing even to time management in real world project. It was a great
experience heading along with the project alone, but still there was the
encouragement of the people, which made this project a great success.
In the beginning programming with android was new, after design and
research, it became clear that it would be the best choice for the
development of this application, and not only that, this technology can also
be used to deploy powerful applications quickly and effectively.
Thus this project has highly helped me in pushing whatever I have learned
for the last 3 years into a reality, with the help of this project I have
discovered the real potential of me. The way I could cope with deadlines,
the way I could face real world challengers. Once again this project has
given me a great amount of experience to face the industry, and I guess I
am ready to face it.
57
Bibliography
android. (2015, 5 12). android developer. Retrieved from android ndk:
https://developer.android.com/ndk/downloads/index.html
anonymous. (2015, 06 12). android. Retrieved from android adt:
http://developer.android.com/tools/sdk/eclipse-adt.html
anonymous. (2015, 07 26). android. Retrieved from android devloper:
http://developer.android.com/tools/studio/index.html
anonymous. (2015, 05 30). matworks. Retrieved from matlab:
http://in.mathworks.com/products/matlab/
anonymous. (2015, 06 12). OPENCV. Retrieved from opencv for android :
http://opencv.org/platforms/android.html
apache. (2015, 12 07). license. Retrieved from
http://www.apache.org/licenses/LICENSE-2.0
Apps, R. (2015, 07 23). OCR - Text Scanner. Retrieved from
https://play.google.com/store/apps/details?id=com.offline.ocr.english
.image.to.text
author, m. (2105, 05 09). Doc.opencv. Retrieved from OpenCV thresholding
:
http://docs.opencv.org/master/d7/d4d/tutorial_py_thresholding.html
Axiata, D. (2015, 07 24). dialog.lk. Retrieved from factsheet:
https://www.dialog.lk/fact-sheet
Bell, B. P. (2015, 07 24). Solo Scrums. Retrieved from
http://www.pbell.com/index.cfm/2007/6/17/Solo-Scrums
ecllipse.org. (2015, 07 17). eclipse. Retrieved from eclipse juno:
https://eclipse.org/juno/
Gohr, A. (2015, 12 22). Splitbarain.org. Retrieved from Linux OCR Software
Comparison: http://www.splitbrain.org/blog/2010-06/15-
linux_ocr_software_comparison
google. (2015, 6 12). tesseract. Retrieved from language data:
https://code.google.com/p/tesseract-ocr/downloads/list
Hildenbrand, J. (2015, 06 29). Android Central. Retrieved from What is
android : http://www.androidcentral.com/what-android
IDEA, i. (2015, 06 23). intelij IDEA. Retrieved from intelij IDEA:
https://www.jetbrains.com/idea/
ISTQB Exam Certification. (2015). What is Prototype model- advantages,
disadvantages and when to use it? Retrieved 03 03, 2015, from
ISTQB Exam Certification: http://istqbexamcertification.com/what-is-
prototype-model-advantages-disadvantages-and-when-to-use-it/
Nations, B. D. (2015, 07 24). about tech. Retrieved from what is iOS:
http://ipad.about.com/od/iPad-Glossary/g/What-Is-iOS.htm
58
ninjamock. (2015, 04 26). ninjamock. Retrieved from wirframe creator for
Android apps: http://ninjamock.com/home/index
OpenCV. (2015, 05 23). OPENCV. Retrieved from Image filters :
http://docs.opencv.org/doc/tutorials/imgproc/gausian_median_blur_
bilateral_filter/gausian_median_blur_bilateral_filter.html
OpenCV vs Matlab. (2015, 07 17). Retrieved from
http://blog.fixational.com/post/19177752599/opencv-vs-matlab
opencv, o. (2015, 05 12). openCV. Retrieved from setting opencv for
android:
http://docs.opencv.org/doc/tutorials/introduction/android_binary_pac
kage/android_dev_intro.html
Pundits, M. (2015, 07 17). Cross-Platform App Development in C#.
Retrieved from http://www.slideshare.net/poojarunija/crossplatform-
app-development-in-c
Qualcomm. (2015, 07 26). developer.qualcomm. Retrieved from fastcv:
https://developer.qualcomm.com/software/fastcv-sdk
Raghavan, k. (2015, 06 04). www.kaustubhraghavan.com. Retrieved from
Tesseract OCR: http://www.kaustubhraghavan.com/ocr.html
Rouse, M. (2005, 08). Prototyping Model. Retrieved 03 03, 2015, from
TechTarget: http://searchcio.techtarget.com/definition/Prototyping-
Model
Sutherland, J. (2015, 07 24). basic of scrum. Retrieved from
https://www.google.lk/url?sa=t&rct=j&q=&esrc=s&source=web&cd=
1&cad=rja&uact=8&ved=0CB0QFjAAahUKEwjwocKk9vLGAhUhraYKHY
aCBJ4&url=http%3A%2F%2Fwww.scruminc.com%2Fwp-
content%2Fuploads%2F2014%2F06%2FThe-Basics-of-
Scrum.pdf&ei=NL6xVfC3LqHamgWGhZLwCQ&usg=AFQjCNH
Tung, A. (2015, 07 23). invoice 123. Retrieved from
https://play.google.com/store/apps/details?id=tw.idv.arlen&hl=en
unknown. (2015, 07 23). ABBYY. Retrieved from ABBYY mobile OCR:
http://www.abbyy.com/mobile-ocr/
Wellnitz, R. (2015, 07 23). Text Fairy (OCR Text Scanner). Retrieved from
https://play.google.com/store/apps/details?id=com.renard.ocr&hl=en
Xian, G. (Director). (2015). Tron Academy Episode 2- Setting Up Android
NDK and OpenCV on Eclipse [Motion Picture]. New Zealand. Retrieved
04 12, 2015, from
https://www.youtube.com/watch?v=N2onPuDZQVY
Yani Dzhurov, I. K. (2009). Personal Extreme Programming – An Agile
Process. Proceedings of International Conference on SOFTWARE,
SERVICES & SEMANTIC TECHNOLOGIES (pp. 253-259). Sofia,
Bulgaria: Demetra EOOD.
59
Glossary
Top up A way to add money to your mobile
phone connection
Scratch Cards Sold in shops ,where some secret
content is hidden under, a customer
who buys one of them could scratch
the surface of the card so that the
secret content is revealed , In this
context used to top up a mobile
phone connection
Numver Name of the application which is
developed in this project
Workbench A tool used to make something, in
this context tools used to build the
application
API Short form for application program
interface, it is a set
SDK Short form for software
development kit used to develop
software specific application
NDK Short form for Native development
kit used to develop software with
support for Native language support
in Android, NDK allows users to
partly develop their app in C or
C++ languages
Postpaid connection A mobile connection providers
system of receiving money, an
invoice will be dispatched to the
connection owners resident and the
owner would submit the invoice at
an outlet to pay his/her mobile bill.
60
Prepaid Connection A mobile connection providers
system of receiving money, A
typical user should maintain a
specific amount of money in his/her
account to use any feather provided
by the service provider( for E.g.
make or call or browse the internet)
A user could add money to his
account via any method specified
by the service provider.
IDE Another word for workbench
1
Appendix I Questionnaire for Mobile phone
users
1. Do you own a working cellular phone?
a. Yes I do
b. No I don’t
2. If yes, is it a smartphone or not
a. Yes it is a smartphone
b. No it is not a smartphone
3. If yes, what operating system the phone is running on
a. Android Operating System
b. Apple’s I Operating system
c. Microsoft windows phone operating system
d. Others
4. How many working mobile or cell phones do you currently have?
5. Do you use a multi SIM phone,
a. Yes I use a multi SIM phone.
b. No I don’t use a multi SIM phone.
6. Are you registered to valid mobile service provider in Sri Lanka or not
a. Yes I am registered.
b. No I am not registered.
7. If yes, what mobile service provider are you registered to
a. Mobitel telecom
b. Dialog axiata
c. Airtel
d. Etisalat
e. Hutch
8. Please specify whether you are a prepaid customer or a postpaid
customer?
a. I am a prepaid customer.
b. I am a postpaid customer.
_____________________
Signature
2
Appendix II Coding snippets
Application permission and more from the manifest.xml file
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.ISDCF.Numver"
android:versionCode="21"
android:versionName="2.1">
<supports-screens android:resizeable="true"
android:smallScreens="true"
android:normalScreens="true"
android:largeScreens="true"
android:anyDensity="true" />
<application
android:allowBackup="true"
android:label="@string/app_name"
android:icon="@drawable/icon"
android:theme="@android:style/Theme.NoTitleBar.Fullscreen" >
<activity android:name=" MainActivity"
android:label="@string/app_name"
android:screenOrientation="landscape"
android:configChanges="keyboardHidden|orientation">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
<uses-sdk android:minSdkVersion="8" />
<uses-permission android:name="android.permission.CAMERA"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.SEND_SMS" />
<uses-permission android:name="android.permission.CALL_PHONE"/>
<uses-feature android:name="android.hardware.camera" android:required="false"/>
<uses-feature android:name="android.hardware.camera.autofocus" android:re-
quired="false"/>
<uses-feature android:name="android.hardware.camera.front" android:re-
quired="false"/>
<uses-feature android:name="android.hardware.camera.front.autofocus" android:re-
quired="false"/>
</manifest>
3
Imports for the application
//imports for opencv
import org.opencv.android.BaseLoaderCallback;
import org.opencv.android.CameraBridgeViewBase.CvCameraViewFrame;
import org.opencv.android.CameraBridgeViewBase.CvCameraViewListener2;
import org.opencv.android.JavaCameraView;
import org.opencv.android.LoaderCallbackInterface;
import org.opencv.android.OpenCVLoader;
import org.opencv.android.Utils;
import org.opencv.core.CvException;
import org.opencv.core.Mat;
import org.opencv.imgproc.Imgproc;
//default imports
import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.graphics.Bitmap;
import android.net.Uri;
import android.os.Bundle;
import android.os.Environment;
import android.telephony.SmsManager;
import android.text.InputType;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.view.SurfaceView;
import android.view.View;
import android.view.WindowManager;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.Toast;
//imports for Tesseract OCR
import com.googlecode.tesseract.android.TessBaseAPI;
4
Variable declarations
//logcat variable
private static final String TAG = "OCVSample::Activity";
//camera view
private JavaCameraView mOpenCvCameraView;
//Variables for all the buttons in the interface
private Button reload;
private Button pkg_activation;
private Button chk_balance;
private Button manual_pin;
private Button topup_history;
//variables for sending messages and USSD codes
private String m_Text = "";
private String ussdCodeCheckBalance = Uri.encode("#")+ "456" + Uri.encode("#");
private String ussdCodeReload= Uri.encode("#")+"123"+Uri.encode("#");
//PIN number validation
private String regEx = "^[0-9]{12}$";
//variables to handle the PIN and to convert them to a usable format by the
messages and ussd
private String converted;
private String convertedRemovedSpace;
private String convertedFirstTwelveDigit;
//variables for image manipulation
private ImageView mimageView;
private Bitmap selectedBitmapFrame ;
private Bitmap croppedImageFinal;
private Mat frameToConvert;
//variables to handle toast string
String toastMesage = new String();
Initializing base loader callback
private BaseLoaderCallback mLoaderCallback = new BaseLoaderCallback(this) {
@Override
public void onManagerConnected(int status) {
switch (status) {
case LoaderCallbackInterface.SUCCESS:
{
Log.i(TAG, "OpenCV loaded successfully");
mOpenCvCameraView.enableView();
} break;
default:
{
super.onManagerConnected(status);
} break;
}
}
};
5
On Create method override
public void onCreate(Bundle savedInstanceState) {
Log.i(TAG, "called onCreate");
super.onCreate(savedInstanceState);
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
//set content to camera surface view
setContentView(R.layout.tutorial1_surface_view);
//button assigning to interface
reload=(Button)findViewById(R.id.button1);
pkg_activation=(Button)findViewById(R.id.button5);
chk_balance=(Button)findViewById(R.id.button2);
manual_pin=(Button)findViewById(R.id.button3);
topup_history=(Button)findViewById(R.id.button4);
//set image view to cameraview
mimageView=(ImageView)findViewById(R.id.imageView1);
mimageView.setVisibility(View.INVISIBLE);
mOpenCvCameraView = (JavaCameraView)
findViewById(R.id.tutorial1_activity_java_surface_view);
mOpenCvCameraView.setVisibility(SurfaceView.VISIBLE);
mOpenCvCameraView.setCvCameraViewListener(this);
}
6
On camera frame sent all the methods are used in this section
public Mat onCameraFrame( final CvCameraViewFrame inputFrame) {
//check balance function
chk_balance.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
startActivity(new Intent("android.intent.action.CALL",
Uri.parse("tel:" + ussdCodeCheckBalance)));
}
});
//manual pin enter function
manual_pin.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
AlertDialog.Builder builder = new
AlertDialog.Builder(MainActivity.this);
builder.setTitle("Input PIN to Topup");
// Set up the input
final EditText input = new EditText(MainActivity.this);
// Specify the type of input expected; this, for example,
sets the input as a password, and will mask the text
input.setInputType(InputType.TYPE_CLASS_NUMBER );
builder.setView(input);
// Set up the buttons
builder.setPositiveButton("OK", new
DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which)
{
m_Text = input.getText().toString();
if (m_Text.matches(regEx)) {
startActivity(new
Intent("android.intent.action.CALL", Uri.parse("tel:" +
ussdCodeReload+m_Text+Uri.encode("#"))));
}
else
{
7
{
Toast toast =
Toast.makeText(getApplicationContext(), " Number of inputs invalid.n Input valid 12
digit PIN",Toast.LENGTH_LONG);
toast.show();
}
}
});
builder.setNegativeButton("Cancel", new
DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which)
{
dialog.cancel();
}
});
builder.show();
}
});
// package activation function
pkg_activation.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
AlertDialog.Builder builderSingle = new
AlertDialog.Builder(
MainActivity.this);
builderSingle.setIcon(R.drawable.icon);
builderSingle.setTitle("Select One Package:-");
final ArrayAdapter<String> arrayAdapter = new
ArrayAdapter<String>(
MainActivity.this,
android.R.layout.select_dialog_singlechoice);
arrayAdapter.add("29/= internet and sms package");
arrayAdapter.add("49/= internet and sms package");
arrayAdapter.add("99/= internet and sms package");
arrayAdapter.add("30 min internet package");
arrayAdapter.add("1 hour internet package");
arrayAdapter.add("2 hour internet package");
arrayAdapter.add("5 hour internet package");
builderSingle.setNegativeButton("cancel",
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which)
{
dialog.dismiss();
}
});
builderSingle.setAdapter(arrayAdapter,
new DialogInterface.OnClickListener() {
8
@Override
public void onClick(DialogInterface dialog, int which)
{
String strName = arrayAdapter.getItem(which);
AlertDialog.Builder builderInner = new
AlertDialog.Builder(
MainActivity.this);
builderInner.setMessage(strName);
builderInner.setTitle("Your Selected Item is");
builderInner.setPositiveButton("Ok",
new DialogInterface.OnClickListener() {
@Override
public void onClick(
DialogInterface dialog,
int which) {
dialog.dismiss();
}
});
builderInner.show();
}
});
builderSingle.show();
}
} );
//the main top-up function
reload.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
frameToConvert=inputFrame.gray();
try{
//image processing for accurate OCR
Imgproc.medianBlur(frameToConvert,
frameToConvert,3);
Imgproc.threshold(frameToConvert, frameToConvert,
0, 200, Imgproc.THRESH_OTSU);
Imgproc.adaptiveThreshold(frameToConvert,
frameToConvert, 155, Imgproc.ADAPTIVE_THRESH_GAUSSIAN_C, Imgproc.THRESH_BINARY, 11,
2);
//convert mat to bitmap
Utils.matToBitmap(frameToConvert,
selectedBitmapFrame);
9
//crop image
croppedImageFinal =
Bitmap.createBitmap(selectedBitmapFrame, 360, 310, selectedBitmapFrame.getWidth() -
700, selectedBitmapFrame.getHeight() - 600);
//set image to imageiew for usercomparison
mimageView.setImageBitmap(croppedImageFinal);
mimageView.setVisibility(View.VISIBLE);
}
catch(CvException e){
Toast toast =
Toast.makeText(getApplicationContext(), e.getMessage(),Toast.LENGTH_LONG);
toast.show();
}
try{
//call the OCR function with the converted and
cropped bitmap image
converted=OCR_Converter(croppedImageFinal);
//String manipulation process
convertedRemovedSpace=converted.replace("
","").replace(" ", "").replace("n","");
convertedFirstTwelveDigit =
convertedRemovedSpace.substring(0, Math.min(convertedRemovedSpace.length(), 12));
//alert box for th user to compare the converted
number with the image
new AlertDialog.Builder(MainActivity.this)
.setTitle("ChecK if the PIN is correct ")
.setMessage(convertedFirstTwelveDigit).
setPositiveButton("Confirm Top-up",new
DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog,
int which) {
//send text message to perform top-up
sendTxt(convertedRemovedSpace, "123");
}
})
.setNegativeButton("no",new
DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog,
int which) {
10
//show toast about improving user
readability
Toast toast =
Toast.makeText(getApplicationContext(), "make sure the image is focused or change
lighting condition",Toast.LENGTH_LONG);
toast.show();
}
})
.setIcon(android.R.drawable.ic_dialog_alert)
.show();
}
catch(CvException e1){
//error handling
Toast toast =
Toast.makeText(getApplicationContext(), e1.getMessage(),Toast.LENGTH_LONG);
toast.show();
}
catch(IllegalArgumentException e1)
{
//error handling
Toast toast =
Toast.makeText(getApplicationContext(), e1.getMessage(),Toast.LENGTH_LONG);
toast.show();
}
}
});
return inputFrame.rgba();
11
//OCR conversion method
public String OCR_Converter(Bitmap selectedBitmapFrame2) {
String converted="";
TessBaseAPI tessapi=new TessBaseAPI();
//show tesseract the language data
tessapi.init(Environment.getExternalStorageDirectory().getPath()+"/tesseract/"
, "eng");
//Tell tesseract only use numbers
tessapi.setVariable(TessBaseAPI.VAR_CHAR_WHITELIST, "1234567890");
tessapi.setVariable(TessBaseAPI.VAR_CHAR_BLACKLIST, "!@#$%^&*()_+=-
qwertyuiop[]}{POIU" +
"YTREWQasdASDfghFGHjklJKLl;L:'"|~`xcvXCVbnmBNM,./<>?");
tessapi.setImage(selectedBitmapFrame2);
converted=tessapi.getUTF8Text();
tessapi.end();
return converted;
}
The Text message sending function
public boolean sendTxt(String message,String number){
try{
SmsManager.getDefault().sendTextMessage(number, null, message, null,
null);
}
catch(Exception e){
Toast toast = Toast.makeText(getApplicationContext(),
e.getMessage(),Toast.LENGTH_LONG);
toast.show();
}
return true;
}
1
Appendix III Project Specification
PROJECT SPECIFICATION - SEGM 2015
Student: Ismail M.I.M (IT13078010)
Date: 26/01/2015
Supervisor: Dr.Pradeepa Samarsinghe
Degree
Course:
BEng (Hons) in Software Engineering
Title of Project: Numver (Android app to Capture Number Based Data e.g.
Scratch Cards, Lottery Tickets, etc. And process them)
Elaboration
Almost all prepaid mobile users face the complexity of Topping-
up/Recharging their credit balance using Scratch cards ,if automatic reload
feature is out of reach .Most of themdo make mistake while keying in the
number in the Scratch card .And some might even not know the process if
toping it up. Adding people who are visually impaired face this difficulty the
most. This becomes versewhen you have to top up multiple cards at the
same time (if the desired denominator is not available you got to key in many
smaller denominator cards to reach the it)
Most of the people are not being update about special Packages (Talk Time,
Data, and SMS) and promotion offered by the mobile Service Providers.
Sri Lankan lottery Systemhas become one of the many growing income to
the Sri Lankan economy .People who buy lottery tickets either had to visit the
vendor or watch the television for the winning number.
The purpose of this project is to create a Standalone Mobile Application.
Which address the above issues.By combining latest mobile image
processing technology. The product would automatically track Numbers on
the material and automate the process for you.
Project Aims
Get a clear understanding of how image processing is used to extract
accurate and reliable results for subject images.
2
Produce (design, develop and test) a fully working “Numver” application for
at least two Mobile Service provider and also add support to at least 10
Lottery ticket with all added features.
Project deliverable(s)
The deliverable for this project will be fully functioning “Numver” mobile
application for both Android OS and IOS at its best.
This includes :
 Scan and activate scratch card using the rear camera for almost all
mobile operators in Sri Lanka automatically
 Maintain statistical data of all calls, data and text messages and
generate report. Includes cost calculation for talk time in a weekly or
monthly basis
 Predict best data plans, talk time packages and text message plans
using customer’s usage behavior.
 Enable or disable specific data, talk-time, and text message packages
with ease.
 Make subscribersaware of promotions, as most of these promotions
are not known by customers .for example star points to credit
conversion in dialog.
 Should support dual Sims, dual standby devices.
 Scan and retrieveLottery ticket Results (if published).
 Maintain records of used Lottery tickets.
3
Action plan
TASKS MILESTONE DATES
Investigate and choose the best two Mobile services
providers who sell the most amount of scratch cards from
almost six provide.
21st of January 2015
Investigate and select the best and the most selling lottery
tickets to be used in the application.
28th of January 2015
Investigate and Choose the best Image processing API to
be used with the Mobile application.
4th of February 2015
Design or sketch the ways on how the image processing
API handles the desired documents.
10th of February 2015
Identify different software applications and their
capabilities for creating cross platform apps which
supports both Android and IOS
17th of February 2015
Design the interface and other Software Engineering
Related Things.
24th of February
2015
Find the best Image processing technique to suit the Need 2nd of March 2015
Start Implementing the Design in a programmatic way 23rd of March 2015
Add and Test the Scratch card module
And produce the prototype
8th of April 2015
Add and Test the Lottery Ticket Module
And produce the prototype
20th of April 2015
4
Add the Extra Features
And produce the prototype
4th of May 2015
Begin the Testing Phase(alpha test) 18th of May 2015
Make any necessary changes to the Final product and
retest. (Repeat the process again if necessary).
2th of June 2015
Identify suitable participants for testing the product. 28th of Jne2015
Begin the second testing phase by distributing the
application to real users and get their feedbacks and
suggestion(Beta Testing)
4th of July 2015
Analyse the feedback and record results 21st of July 2015
Critically evaluate all aspects of the project. 24th of July 2015
Identify and report which areas of the product could be
improved.
26th of July 2015
Finalize the Project Report. 2nd of August 2015
Appendix IV Ethics Form
Question Yes/No
1. Does the project involve human participants? This includes
surveys, questionnaires, observing behaviour, testing etc.
If YES, then please answer questions 2 to 5.
If NO, please go to question 6.
YES
2.
Note
Will any of the participants be vulnerable?
‘Vulnerable’ means those who may not fully understand the
research, or the consequences of taking part. They include:
 children (i.e. under 18)
 people with learning disabilities
 people with physical disabilities (visible or not)
 people who may be limited by age or illness
If YES, then please answer question 2a
If NO, please go to question 3
YES
2a Will you ever be alone (i.e. not overseen) with any
vulnerable participants during the course of the
research?
If YES, then please answer question 2b
If NO, please go to question 2c.
NO
5
2b
Note
If you will be alone (i.e. not overseen) with any
vulnerable participants during the course of the
research, do you need to apply for a Disclosure and
Barring Service (DBS) check (previously known as a
Criminal Records Bureau (CRB) check)?
If you need a DBS check, you may be liable for the cost
of the application. More details regarding DBS checks
can be found at https://www.gov.uk/disclosure-barring-
service-check/overview.
2c
Note
If you will NOT be alone (i.e. you will be overseen)
with any vulnerable participants during the course of
the research, does your overseer have a DBS
Check?
If your overseer does NOT have a DBS check, you
may need to apply for a DBS check yourself. You may
be liable for the cost of the DBS application. More
details regarding DBS checks can be found at
https://www.gov.uk/disclosure-barring-service-
check/overview.
---
3.
Note
Will any participants be at risk of any physical or emotional
harm by taking part in your project?
Harm may be caused by:
 distressing or intrusive interview questions
 uncomfortable procedures involving the participant,
 invasion of privacy,
 topics relating to highly personal information,
 topics relating to illegal activity, etc.
NO
4. Will anyone be taking part without giving their informed
consent? (e.g. research involving covert study, coercion of
subjects, or where subjects have not fully understood the
research etc.)
NO
5. Will any part of the project allow the identification of any
individual who has not given their express consent to be
identified?
NO
Note If you answered YES to any of questions 2 – 5, then you MUST
address these ethical issues in your Project Specification,
ensure that you take all reasonable steps to avoid/mitigate these
issues during the execution of your project, and explain your
actions in your Critical Reflection.
Question Yes/No
6. Does the project involve the use of live animals? NO
Note If you answered YES to question 6, then the project proposal
must be submitted to the FREC for approval unless it falls into a
category/ programme of research that has already received
category approval.
7.
Note
Does the project involve the NHS?
For NHS research, this includes:
 any service evaluation work
 work concerning NHS patients (tissues, organs,
personal information or data)
 NHS staff, volunteers, or carers
 NHS premises or facilities
NO
If you answered YES to question 7, then your project proposal
MUST be submitted Project Module Ethics Committee for
6
review, and may be referred to the Faculty Research Ethics
Committee and/or to an NHS Research Ethics Committee. For
further details on NHS National Research Ethics Service, please
refer to http://www.nres.nhs.uk/applications/faq/before-
applying/#FAQsBeforeApplyingStudent
8. Does the project require approval from any other external
ethics committee?
Note If you answered YES to question 8, then the project proposal
must be submitted to the relevant external body. For further
advice, please contact the Faculty Research Ethics Committee
NO
Organizations
Question Yes/No
9. Will the project involve working with or within an organisation?
'Organisation' includes (but is not limited to):
 business
 charity
 museum
 government department
 international agency
 sports/social club
 volunteer organisation
NO
10.
Note
If you answered YES to question 9, do you have granted
access (permission) to conduct the project?
If YES, please show evidence to your supervisor and include this
evidence in the Appendix of your Final Report.
--
11. If you answered NO to question 10, is it because:
A. you have not yet asked
B. you have asked and not yet received and answer
C. you have asked and been refused access.
A / B / C
--
Note You will only be able to start this aspect of the project when you
have been granted access/permission.
12.
Note
Will covert research be part of the project?
‘Covert research’ refers to research that is conducted without the
knowledge of participants.
If you answered YES to question 12, then your project proposal
MUST be submitted Project Module Ethics Committee for review,
and may be referred to the Faculty Research Ethics Committee
NO
7
Question Yes/No
Question Yes/No
13
Note
Will the project involve using (e.g. citing / quoting / copying)
copyrighted materials?
Copyrighted materials includes (but is not limited to):
 books / e-books
 journals
 websites
 newspaper/magazine articles
 films / broadcasts
 photographs, artworks, images, diagrams
 designs, products
 computer programmes, code, databases
 networks
 processes
If YES, please go to question 14
If NO, please read the declaration at the end of the checklist
YES
14.
Note
Are the copyrighted materials you intend to use (citing / quoting
/ copying) in the public domain?
‘In the public domain’ does not mean the same thing as ‘publicly
accessible’.
 Information which is 'in the public domain' is no
longer protected by copyright (i.e. copyright has
either expired or been waived) and can be used
without permission.
 Information which is 'publicly accessible' (e.g. TV
broadcasts, websites, artworks, newspapers) is
available for anyone to consult/view. It is still
protected by copyright even if there is no
copyright notice. In UK law, copyright protection
is automatic and does not require a copyright
statement, although it is always good practice to
provide one. It is necessary to check the terms
and conditions of use to find out exactly how the
material may be reused etc.
If YES, please read the declaration at the end of the
checklist.
If NO, please go to question 15.
YES
15.
Note
Will the project involve copying/reproducing copyrighted
materials?
'Copying/reproducing' includes making physical copies (i.e.
photocopies) and electronic copies (i.e. cutting-and-pasting,
scanning, saving as separate files). It does not include citations
and quotes with appropriate references.
If YES, please go to question 15a.
If NO, please go to question 16.
--
15a
Note
Will you be copying more than 5% (or one chapter)
of an individual source?
You are allowed to copy/reproduce up to 5% of a
source (or one chapter) for your own personal research
usage without explicit permission. Please see
"Copyright - guidance for SHU Staff and Students" for
further information.
--
8
Question Yes/No
16.
Note
Do you have permission to use the copyrighted materials
under the "Exam Defence"?
If you are copying less than 5% (or one chapter) or citing/quoting
the copyrighted material, you have permission to use the
copyrighted material under the "Exam Defence". Please see
"Copyright - guidance for SHU Staff and Students" for further
information.
If YES, please read the declaration at the end of the
checklist.
If NO, please go to question 17.
--
Question Yes/No
17. Do you have explicit permission to use the copyrighted
materials?
If YES, please show any explicit evidence to your supervisor and
include in the Appendix of your Final Report. Please read the
declaration at the end of the checklist.
If NO, please go to question 18.
--
18. If you do not have explicit permission, is it because:
A. you have not yet asked permission
B. you have asked and not yet received and answer
C. you have asked and been refused access.
A / B / C
--
Note You will not be allowed to use the copyrighted material until you
have been granted permission to use it.
Adherence to SHU policy & procedures
Declaration
I can confirm that:
 I have read the Sheffield Hallam University Research Ethics Policy
(available at
https://staff.shu.ac.uk/enterprise/research/Documents/Research%20Ethics
%20Policy.pdf
 I agree to abide by its principles.
Signature ……………… Ismail M.I.M
(IT13078010)

More Related Content

What's hot

E.Leute: Learning the impact of Learning Analytics with an authentic dataset
E.Leute: Learning the impact of Learning Analytics with an authentic datasetE.Leute: Learning the impact of Learning Analytics with an authentic dataset
E.Leute: Learning the impact of Learning Analytics with an authentic datasetHendrik Drachsler
 
Photograph Database management report
Photograph Database management reportPhotograph Database management report
Photograph Database management reportAmrit Ranjan
 
Evaluation of Developing Electronic Sports Business in Chinese Game Market - ...
Evaluation of Developing Electronic Sports Business in Chinese Game Market - ...Evaluation of Developing Electronic Sports Business in Chinese Game Market - ...
Evaluation of Developing Electronic Sports Business in Chinese Game Market - ...Teng Ma
 
Agentless Monitoring with AdRem Software's NetCrunch 7
Agentless Monitoring with AdRem Software's NetCrunch 7Agentless Monitoring with AdRem Software's NetCrunch 7
Agentless Monitoring with AdRem Software's NetCrunch 7Hamza Lazaar
 
Microlearning Programs Calendar 2020
Microlearning Programs Calendar 2020Microlearning Programs Calendar 2020
Microlearning Programs Calendar 2020Manisha Khetarpal
 
Internship report about Research and deployment ISA Server 2006
Internship report about Research and deployment ISA Server 2006Internship report about Research and deployment ISA Server 2006
Internship report about Research and deployment ISA Server 2006Vũ Vương
 
Design and Development of a Knowledge Community System
Design and Development of a Knowledge Community SystemDesign and Development of a Knowledge Community System
Design and Development of a Knowledge Community SystemHuu Bang Le Phan
 
Computational thinking v0.1_13-oct-2020
Computational thinking v0.1_13-oct-2020Computational thinking v0.1_13-oct-2020
Computational thinking v0.1_13-oct-2020Gora Buzz
 
Yuhang Chen - Internship Report
Yuhang Chen - Internship ReportYuhang Chen - Internship Report
Yuhang Chen - Internship ReportYuhang Chen
 
Software architecture for developers
Software architecture for developersSoftware architecture for developers
Software architecture for developersChinh Ngo Nguyen
 
Internship report (1)
Internship report (1)Internship report (1)
Internship report (1)brhne fitsum
 
Smart attendance system using facial recognition
Smart attendance system using facial recognitionSmart attendance system using facial recognition
Smart attendance system using facial recognitionVigneshLakshmanan8
 
Cw comp1640 211453_mo233_20131120_214054_1314
Cw comp1640 211453_mo233_20131120_214054_1314Cw comp1640 211453_mo233_20131120_214054_1314
Cw comp1640 211453_mo233_20131120_214054_1314Owen Muzi
 

What's hot (16)

E.Leute: Learning the impact of Learning Analytics with an authentic dataset
E.Leute: Learning the impact of Learning Analytics with an authentic datasetE.Leute: Learning the impact of Learning Analytics with an authentic dataset
E.Leute: Learning the impact of Learning Analytics with an authentic dataset
 
Photograph Database management report
Photograph Database management reportPhotograph Database management report
Photograph Database management report
 
Evaluation of Developing Electronic Sports Business in Chinese Game Market - ...
Evaluation of Developing Electronic Sports Business in Chinese Game Market - ...Evaluation of Developing Electronic Sports Business in Chinese Game Market - ...
Evaluation of Developing Electronic Sports Business in Chinese Game Market - ...
 
Agentless Monitoring with AdRem Software's NetCrunch 7
Agentless Monitoring with AdRem Software's NetCrunch 7Agentless Monitoring with AdRem Software's NetCrunch 7
Agentless Monitoring with AdRem Software's NetCrunch 7
 
Java completed assignment
Java completed assignmentJava completed assignment
Java completed assignment
 
Dimensions iom training
Dimensions iom trainingDimensions iom training
Dimensions iom training
 
Microlearning Programs Calendar 2020
Microlearning Programs Calendar 2020Microlearning Programs Calendar 2020
Microlearning Programs Calendar 2020
 
Internship report about Research and deployment ISA Server 2006
Internship report about Research and deployment ISA Server 2006Internship report about Research and deployment ISA Server 2006
Internship report about Research and deployment ISA Server 2006
 
Design and Development of a Knowledge Community System
Design and Development of a Knowledge Community SystemDesign and Development of a Knowledge Community System
Design and Development of a Knowledge Community System
 
Computational thinking v0.1_13-oct-2020
Computational thinking v0.1_13-oct-2020Computational thinking v0.1_13-oct-2020
Computational thinking v0.1_13-oct-2020
 
Yuhang Chen - Internship Report
Yuhang Chen - Internship ReportYuhang Chen - Internship Report
Yuhang Chen - Internship Report
 
Software architecture for developers
Software architecture for developersSoftware architecture for developers
Software architecture for developers
 
Internship report (1)
Internship report (1)Internship report (1)
Internship report (1)
 
Smart attendance system using facial recognition
Smart attendance system using facial recognitionSmart attendance system using facial recognition
Smart attendance system using facial recognition
 
12.06.2014
12.06.201412.06.2014
12.06.2014
 
Cw comp1640 211453_mo233_20131120_214054_1314
Cw comp1640 211453_mo233_20131120_214054_1314Cw comp1640 211453_mo233_20131120_214054_1314
Cw comp1640 211453_mo233_20131120_214054_1314
 

Similar to Project Final Report Ismail MIM IT13078010 SHUID 24048259_final

NIC Project Final Report
NIC Project Final ReportNIC Project Final Report
NIC Project Final ReportKay Karanjia
 
Project final report
Project final reportProject final report
Project final reportALIN BABU
 
ImplementationOFDMFPGA
ImplementationOFDMFPGAImplementationOFDMFPGA
ImplementationOFDMFPGANikita Pinto
 
iGUARD: An Intelligent Way To Secure - Report
iGUARD: An Intelligent Way To Secure - ReportiGUARD: An Intelligent Way To Secure - Report
iGUARD: An Intelligent Way To Secure - ReportNandu B Rajan
 
digiinfo website project report
digiinfo website project reportdigiinfo website project report
digiinfo website project reportABHIJEET KHIRE
 
Im-ception - An exploration into facial PAD through the use of fine tuning de...
Im-ception - An exploration into facial PAD through the use of fine tuning de...Im-ception - An exploration into facial PAD through the use of fine tuning de...
Im-ception - An exploration into facial PAD through the use of fine tuning de...Cooper Wakefield
 
Design and implementation of a Virtual Reality application for Computational ...
Design and implementation of a Virtual Reality application for Computational ...Design and implementation of a Virtual Reality application for Computational ...
Design and implementation of a Virtual Reality application for Computational ...Lorenzo D'Eri
 
Capstone Report - Industrial Attachment Program (IAP) Evaluation Portal
Capstone Report - Industrial Attachment Program (IAP) Evaluation PortalCapstone Report - Industrial Attachment Program (IAP) Evaluation Portal
Capstone Report - Industrial Attachment Program (IAP) Evaluation PortalAkshit Arora
 
Thesis - Nora Szepes - Design and Implementation of an Educational Support Sy...
Thesis - Nora Szepes - Design and Implementation of an Educational Support Sy...Thesis - Nora Szepes - Design and Implementation of an Educational Support Sy...
Thesis - Nora Szepes - Design and Implementation of an Educational Support Sy...Nóra Szepes
 
QBD_1464843125535 - Copy
QBD_1464843125535 - CopyQBD_1464843125535 - Copy
QBD_1464843125535 - CopyBhavesh Jangale
 
Thesis-aligned-sc13m055
Thesis-aligned-sc13m055Thesis-aligned-sc13m055
Thesis-aligned-sc13m055Mohan Kashyap
 
Ddos attacks on the data and prevention of attacks
Ddos attacks on the data and prevention of attacksDdos attacks on the data and prevention of attacks
Ddos attacks on the data and prevention of attacksRanganathSri1
 
Report on e-Notice App (An Android Application)
Report on e-Notice App (An Android Application)Report on e-Notice App (An Android Application)
Report on e-Notice App (An Android Application)Priyanka Kapoor
 

Similar to Project Final Report Ismail MIM IT13078010 SHUID 24048259_final (20)

NIC Project Final Report
NIC Project Final ReportNIC Project Final Report
NIC Project Final Report
 
Project final report
Project final reportProject final report
Project final report
 
ImplementationOFDMFPGA
ImplementationOFDMFPGAImplementationOFDMFPGA
ImplementationOFDMFPGA
 
iGUARD: An Intelligent Way To Secure - Report
iGUARD: An Intelligent Way To Secure - ReportiGUARD: An Intelligent Way To Secure - Report
iGUARD: An Intelligent Way To Secure - Report
 
digiinfo website project report
digiinfo website project reportdigiinfo website project report
digiinfo website project report
 
Im-ception - An exploration into facial PAD through the use of fine tuning de...
Im-ception - An exploration into facial PAD through the use of fine tuning de...Im-ception - An exploration into facial PAD through the use of fine tuning de...
Im-ception - An exploration into facial PAD through the use of fine tuning de...
 
Design and implementation of a Virtual Reality application for Computational ...
Design and implementation of a Virtual Reality application for Computational ...Design and implementation of a Virtual Reality application for Computational ...
Design and implementation of a Virtual Reality application for Computational ...
 
Master's Thesis
Master's ThesisMaster's Thesis
Master's Thesis
 
Capstone Report - Industrial Attachment Program (IAP) Evaluation Portal
Capstone Report - Industrial Attachment Program (IAP) Evaluation PortalCapstone Report - Industrial Attachment Program (IAP) Evaluation Portal
Capstone Report - Industrial Attachment Program (IAP) Evaluation Portal
 
document
documentdocument
document
 
Thesis - Nora Szepes - Design and Implementation of an Educational Support Sy...
Thesis - Nora Szepes - Design and Implementation of an Educational Support Sy...Thesis - Nora Szepes - Design and Implementation of an Educational Support Sy...
Thesis - Nora Szepes - Design and Implementation of an Educational Support Sy...
 
Mobile d
Mobile dMobile d
Mobile d
 
QBD_1464843125535 - Copy
QBD_1464843125535 - CopyQBD_1464843125535 - Copy
QBD_1464843125535 - Copy
 
merged_document
merged_documentmerged_document
merged_document
 
Thesis-aligned-sc13m055
Thesis-aligned-sc13m055Thesis-aligned-sc13m055
Thesis-aligned-sc13m055
 
Report
ReportReport
Report
 
My PhD Thesis
My PhD Thesis My PhD Thesis
My PhD Thesis
 
Milan_thesis.pdf
Milan_thesis.pdfMilan_thesis.pdf
Milan_thesis.pdf
 
Ddos attacks on the data and prevention of attacks
Ddos attacks on the data and prevention of attacksDdos attacks on the data and prevention of attacks
Ddos attacks on the data and prevention of attacks
 
Report on e-Notice App (An Android Application)
Report on e-Notice App (An Android Application)Report on e-Notice App (An Android Application)
Report on e-Notice App (An Android Application)
 

Project Final Report Ismail MIM IT13078010 SHUID 24048259_final

  • 1. I Faculty of Arts, Computing, Engineering & Sciences Department of Computing Final Year Individual Project (SEGM) [55-6727] 2014/15 Author: Ismail M.I.M Date Submitted: Supervisor: Dr.Pradeepa Samarsinghe Degree Course: BEng (Hons) in Software Engineering Title of Project: Numver (Android app to Capture Number Based Data e.g. Scratch Cards ,and process them ) Confidentially Required? NO  YES 
  • 2. II Abstract The aim of this project is to create a mobile app which could capture an image from a scratch card and automatically top-up a mobile account, with the specific amount of credits for a leading mobile service provider. Users will not have to enter the scratch card numbers manually digit by digit, which is more prone to errors (typical scratch cards have either 16 digit or 12 digit to enter to top-up). The app uses latest image processing and optical character recognition technology to obtain accurate results from a given scratch card. Adding more the app would also feature some extra functionality like package activation (data, voice, SMS), which is usually done through inputting series of USSD codes or through sending SMS messages to the service provider. And app would also maintain user statistics about top-ups made in the course of the app usage.
  • 3. III Acknowledgment First and foremost I would like to thank Dr.Pradeepa Samarasinghe, my project supervisor, for guiding, encouraging and supporting me during all the stages of this project as well as helping me and guiding me through the 3 year degree program. I would also like to show my gratitude to Mr.Nuwan kodagoda, module leader for the projects module for approving this project and for aiding me in finding all necessary requirements to start my project. Furthermore I would like thank both the past and the present lectures and instructors of Srilanka Institute of information technology who thought me , for guiding me with the proper skill set within this three year study in this institution, without them I would not have accomplished up to this level. I would also like to thank George Xian from New Zealand, mentor of Tron academy for his continues support in helping me out with some of the technical issues I faced during the course of this project via the internet. Last but not least I would like to thank my papa, my sisters and my younger brother for caring, encouraging and supporting me to complete this project on time.
  • 4. 1 Table of Contents Abstract..................................................................................................II Acknowledgment ....................................................................................III List of figures ..........................................................................................4 List of tables............................................................................................5 1. Introduction ........................................................................................6 2. The Usual Way ....................................................................................7 2.1 Through automatic top-up via a local store. ..................................7 2.2 Manually entering a recharge card number....................................7 2.3 Usual way for package activation..................................................8 3 Specification .....................................................................................9 3.1 Requirements ..............................................................................9 3.1.1 Scan and activate scratch card using the rear camera for a mobile operator in Sri Lanka ..............................................................9 3.1.2 Maintain data of all top-up’s made and generate report..........10 3.1.3 Activate specific data, talk-time, and text message packages with ease........................................................................................10 3.1.4 Enter scratch card PIN manually ...........................................10 3.1.5 Check account balance automatically ....................................10 4 Feasibility Study..............................................................................11 4.1 Why choose prepaid connections over postpaid connection for this project...............................................................................................11 4.1.1 Results from the survey .......................................................11 5 Existing Application .........................................................................13 5.1 OCR - Text Scanner by Rishi Apps (Apps, 2015)..........................13 5.2 Invoice123 by Arlen Tung (Tung, 2015)......................................14 5.3 Text Fairy (OCR Text Scanner) by Renard Wellnitz (Wellnitz, 2015) 15 6 Software Development Methodologies ..............................................17 6.1 Scrum/Solo Scrum (Bell, 2015) ..................................................17 6.2 PXP (personal Xtreme programming) ..........................................18 6.3 Prototyping................................................................................19 6.4 Selecting the most suitable methodology for the project..............19 6.5 Use case diagram ......................................................................20 7 Selecting appropriate Technologies ..................................................21 7.1 Choosing the platform for the app to run.....................................21
  • 5. 2 7.1.1 Google’s android Operating system.......................................21 7.1.2 Apple’s IOS..........................................................................21 7.1.3 Android Operating System or IOS .........................................22 7.1.4 Development difficulty.............................................................22 7.2 More users than IOS ..................................................................23 7.2.1Questioner report Results ........................................................23 7.3 Choosing the image processor....................................................23 7.3.1 OpenCV...............................................................................23 7.3.2 Matlab.................................................................................23 7.3.3 FastCV from Qualcomm........................................................24 7.4 Choosing the Optical Character Recognition Engine .....................25 7.4.1 ABBYY Mobile OCR Engine ....................................................25 7.4.2 Tesseract OCR Engine ..........................................................26 7.4.3 Tested image data (for test carried out mentioned in table 3) 27 7.5 Database management ..............................................................29 7.5.1 Comparison between DBMS..................................................29 7.6 Workbench Selection (android studio or eclipse ADT)...................30 7.6.1 Android studio .....................................................................30 7.6.2 Eclipse adt...........................................................................30 7.6.3 Comparison between different IDE’s......................................31 8 Design ............................................................................................32 8.3 Folder structure .........................................................................32 8.4 Brief detail about the folder structures ........................................32 8.5 Class Diagram ...........................................................................37 8.6 Use case scenarios.....................................................................38 8.7 Wireframe models......................................................................40 9 Implementation...............................................................................43 9.3 Setting up the workbench...........................................................43 9.3.1 Installing eclipse Juno and setting up the ADT bundle ............43 9.3.2 Installing the Android NDK, CDT plugin and setting it up with eclipse (Xian, 2015) ........................................................................44 9.3.3 Installing libraries (OpenCV, Tesseract).................................46 9.4 The process of extracting text from image ..................................47 9.5 Running the application..............................................................48 9.6 System requirements ..............................................................48 9.7 Final application.........................................................................48 9.7.1 The Numver Logo.................................................................48
  • 6. 3 9.7.2 Application Screenshots........................................................48 10 Testing the Application..................................................................50 10.3 Character recognition test .......................................................50 10.4 Application stability test ..........................................................51 11 Problems faced during the course of the project .............................53 11.3 Setting up the NDK .................................................................53 11.4 OCR never recognized the characters from an image accurately 53 11.5 Portrait mode did not work......................................................53 12 Further Development ....................................................................55 13 Personal Development...................................................................56 Bibliography ..........................................................................................57 Glossary................................................................................................59 Appendix I Questionnaire for Mobile phone users ......................................1 Appendix II Coding snippets.....................................................................2 Application permission and more from the manifest.xml file....................2 Imports for the application....................................................................3 Variable declarations.............................................................................4 On Create method override ...................................................................5 On camera frame sent all the methods are used in this section ...............6 Appendix III Project Specification .............................................................1 Appendix IV Ethics Form ..........................................................................4 Organizations .......................................................................................6 Adherence to SHU policy & procedures ..................................................8
  • 7. 4 List of figures Figure 1 image (front) of a typical mobile data/sms scratch card in Srilanka from dialog axiata....................................................................................9 Figure 2 image (rear) of a typical mobile data/sms scratch card in Srilanka from dialog axiata....................................................................................9 Figure 3 image (rear) of a typical mobile value scratch card in Srilanka from dialog axiata..........................................................................................10 Figure 4 image (front) of a typical mobile value scratch card in Srilanka from dialog axiata..................................................................................10 Figure 5 Pie Chart for results obtained in the survey “prepaid user compared with postpaid users" ..............................................................................11 Figure 6 Pie Chart for results obtained in the survey “prepaid user compared with postpaid users for different operating system" .................................12 Figure 7 screenshots of similar apps "OCR-Scanner by rishi" ....................13 Figure 8 screenshots of similar apps "OCR-Scanner by rishi" ....................13 Figure 9 screenshot of similar apps “Invoice123 by Arlen Tung” ...............14 Figure 10 screenshot of similar apps “Text Fairy (OCR Text Scanner) by Renard Wellnitz .....................................................................................15 Figure 11 Scrum Flow chart....................................................................18 Figure 12 PXP flowchart.........................................................................18 Figure 13 prototyping work flow diagram ................................................19 Figure 14 Use case scenario for the Numver mobile application................20 Figure 15 comparison of different programming difficulties for different Operating system ..................................................................................22 Figure 16 pie chart results from the survey "different operating users within the university".......................................................................................23 Figure 17 Test image for courier/black....................................................27 Figure 18test image for courier/gray.......................................................27 Figure 19 Test image for justy/black.......................................................28 Figure 20 Test image for justy/gray........................................................28 Figure 21 Test image for times/black......................................................28 Figure 22 Test image for times/gray.......................................................28 Figure 23 Test image for verdana/black ..................................................28 Figure 24 Test image for verdana/grey ...................................................29 Figure 25 folder structure for android using eclipse ide ............................32 Figure 26 Class diagram for Numver application......................................37 Figure 27 wireframe diagram of the main user inteface ...........................40 Figure 28 wireframe showing user balance..............................................41 Figure 29 wireframe showing the manual PIN input screen ......................41 Figure 30 wireframe showing the package selection menu .......................42 Figure 31 features of the phone used to develop the application ..............43 Figure 32 layers of android mobile architecture .......................................44 Figure 33 presumed time taken for code execution normal for java..........44 Figure 34 presumed time taken for code execution normal for compiled language...............................................................................................45 Figure 35 illustration for multiplatform support with android ndk..............45 Figure 36 flow of a scratch card frame throughout many process .............47 Figure 37 logo of the scratch card...........................................................48
  • 8. 5 Figure 38 this is how the main interface looks like ...................................48 Figure 39 the confirm reload dialog box..................................................49 Figure 40 the package selection menu....................................................49 Figure 41 Number pad to input scratch card PIN manually .......................49 Figure 42 dialog box before performing a manual reload..........................49 Figure 43 setting up environment variable for Android NDK .....................53 List of tables Table 1 Comparison of three image processing libraries...........................25 Table 2 comparison between the two OCR ..............................................26 Table 3 comparison of 4 best OCR in the market .....................................27 Table 4 comparison between databases..................................................30 Table 5 comparison between workbenches..............................................31 Table 6 brief description about all the directories in the eclipse IDE ..........36 Table 7 use case scenario to perform an auto top-up...............................38 Table 8 use case scenario to check balance............................................39 Table 9 use case scenario to perform a manual top-up...........................39 Table 10 use case scenario to activate a package...................................39 Table 11 use case scenario to view top up history ..................................40 Table 12 test results for character recognition.........................................50 Table 13 Test case for auto top-up .........................................................51 Table 14 Test case for manual reload......................................................51 Table 15 Test case for package activation...............................................52 Table 16 Test case to display top-up History ...........................................52 Table 17 Test case to show balance........................................................52
  • 9. 6 1. Introduction Topping up a mobile account with a scratch card has always been a trouble to mobile subscribers all over Sri Lanka. Subscribers who wish to add credit to their account either has to buy a scratch card or use the reload feature from a local store. Most of the users do make mistake while keying in the number from the scratch card .And some might not even know the process of toping it up. Adding, people who are visually impaired face this difficulty the most. This becomes verse when you have to top up multiple cards at the same time (if the desired denominator is not available you got to key in many smaller denominator cards to reach it) Most of the people are not being update about special Packages (Talk Time, Data, and SMS) and promotion offered by the mobile Service Providers. The target of this project is to propose design and implement an android app named “Numver” to quote the above complications.
  • 10. 7 2. The Usual Way Usually users who possess a mobile phone with a prepaid mobile connection would top-up their account either.  Through automatic top-up via a local store.  Manually entering a recharge card number. 2.1 Through automatic top-up via a local store. A typical user would go to a retail outlet which provides a top-up facility and the user will hand over his/her mobile number to the store keeper with the money she wish to top up ,and then the store keeper would enter the mobile number into his system, select a service provider and will top-up the account. Drawbacks Users will have to handover their mobile number to an unknown. person (store keeper), which a typical user would consider confidential to him or herself. At times, the funds in the store keepers system would not be enough to perform a requested top-up. 2.2 Manually entering a recharge card number To cater to the drawbacks present in the above method, user could use this method, where a user could purchase a scratch card and type in the scratch cards PIN number to perform a top-up. Drawbacks Users will have to enter the PIN manually which will lead to many errors, whereas the user is prompt to enter the PIN once again. Really annoying when a user is in a hurry. User who have an impaired vision or user who wears spectacles will find it difficult to read the PIN numbers at optimal view distance as the text in the scratch card is only 5.2mm in size.
  • 11. 8 2.3 Usual way for package activation Users who like to activate specific data, sms or talk time package will either have to dial in a series of USSD codes or will have to send specific messages to the mobile subscriber. Which at times will the user tired to do it repeatedly.
  • 12. 9 Figure 1 image (front) of a typical mobile data/sms scratch card in Srilanka from dialog axiata 3 Specification Requirements for this project was not clear, that is why prototyping model was chosen (for more information look section 6) but to initiate the project some of requirements were assumed as below. 3.1 Requirements 3.1.1 Scan and activate scratch card using the rear camera for a mobile operator in Sri Lanka A typical user should be able to capture a scratch card and top up his mobile account with aid of his/her smartphone’s built in rear camera. A couple of scratch cards from Dialog axiata, which is used to top up an account 5.2mm M
  • 13. 10 Figure 4 image (front) of a typical mobile value scratch card in Srilanka from dialog axiata Figure 3 image (rear) of a typical mobile value scratch card in Srilanka from dialog axiata 3.1.2 Maintain data of all top-up’s made and generate report User is prompted to enter the amount that he/she is going to top-up before proceeding with a top-up so that all top-up data will be stored ,which in turn would help users to review their top-up data. 3.1.3 Activate specific data, talk-time, and text message packages with ease. Users will also have the freedom to activate or deactivate data /text/talk time plans via the app its self .Which makes it easier ,whereas usually users will have to send multiple text message or USSD codes. 3.1.4 Enter scratch card PIN manually User will also be able to enter a scratch card manually, as due to bad lighting if the application fails to identify the PIN number from the scratch card. 3.1.5 Check account balance automatically User will be able to check their account balance without leaving the app to make sure a top-up was success full or not. 5.2mm M
  • 14. 11 4 Feasibility Study A feasibility study was carried out before the commencement of the project, to make sure the project was a successful one. Many aspects of the project was discussed along with the supervisor to make sure this app was success, decision were derived after a survey which was conducted within the university premises for around 100 participants (university students) (Appendix I), the results obtained is briefed below . 4.1 Why choose prepaid connections over postpaid connection for this project It’s obvious that users cannot top-up a postpaid account, furthermore it was researched that most users in Sri Lanka own a prepaid connection rather than a postpaid connection, after gazing at the results that was obtained during the survey within the university it was decided that this project will be of great use for many people who own a prepaid connection. 4.1.1 Results from the survey Prepaid Users vs Postpaid users Prepaid user post paid users Figure 5 Pie Chart for results obtained in the survey “prepaid user compared with postpaid users"
  • 15. 12 As it is demonstrated in the above diagram, number of students who own a postpaid connection is as less as 27% than who own a prepaid connection who stay in a peak of 73%, when considering android users it is the same case too. This is also the same when considering the mobile connections provided by one of the top services provider in Sri Lanka .Dialog axiata PLC limited, in their fact sheets (Axiata, 2015) say that they have 8,714,005 customers over all and out of which only 962,892 are postpaid customers and rest of the 7,751,113 are prepaid customers this shows that more users are prepaid. This was why prepaid connection was chosen rather than a postpaid connection. After a vigorous study, the project was finalized by the supervisor as a feasible one. And then the project began its Design pace. android - prepaid and post paid IOS Android postpaid Prepai Figure 6 Pie Chart for results obtained in the survey “prepaid user compared with postpaid users for different operating system"
  • 16. 13 5 Existing Application There are no specific application which resembles “Numver” directly, some of these OCR apps which were found on Google’s Play store which uses similar features as Numver are listed below. 5.1 OCR - Text Scanner by Rishi Apps (Apps, 2015) Figure 7 screenshots of similar apps "OCR-Scanner by rishi" Figure 8 screenshots of similar apps "OCR-Scanner by rishi" This app lets users load a Pre captured image and then enhance it, after which the image is passed to an ocr engine and then the text is extracted.
  • 17. 14 Drawbacks The main drawback using this app is that users cannot capture an image in app, rather they will have to use an image which is already captured. 5.2 Invoice123 by Arlen Tung (Tung, 2015) Figure 9 screenshot of similar apps “Invoice123 by Arlen Tung” This app keeps track of all your invoice by scanning the invoice number and then by scanning the price it also has more added features like scanning bar codes, QR codes and so on. Drawbacks Poor Language support (does not support English).
  • 18. 15 5.3 Text Fairy (OCR Text Scanner) by Renard Wellnitz (Wellnitz, 2015) Figure 10 screenshot of similar apps “Text Fairy (OCR Text Scanner) by Renard Wellnitz Text Fairy (OCR Text Scanner) by Renard Wellnitz does a similar work like what Numver does. It also uses the back camera of an android device and captures an image and extracts all the texts from it .Main purpose of the app is to convert font styles so that users could read the text they prefer in a font style which they prefer. Some other features of Text Fairy • Perform OCR (optical character recognition). • Correct the viewpoint of an image. • Edit extracted text. • Copy extracted text into the clipboard for use in other apps. • Convert the scanned page into PDF. • Recognizes printed text from more than 50 languages. Benefits Could customize the size of area to be scanned. Drawbacks Because Text Fairy is still in its testing phase most of its functionality are still buggy. So at times results might not be accurate
  • 19. 16 After considering all these application, there were no specific app to read a scratch card and perform an operation with it, rather all the above listed apps where mainly used to extract text’s only.
  • 20. 17 6 Software Development Methodologies To keep track of project and to maintain and optimize both time and quality of the project a Software Development Life cycle has to be chosen. After some heavy effort of research, found out some of the SDLC which will suit the requirements of Numver .They are listed below  Scrum/Solo SCRUM  Prototyping  PXP (personal Xtreme programming). 6.1 Scrum/Solo Scrum (Bell, 2015) Solo Scrum is also known as scrum for one. Scrum is an iterative and incremental methodology based and responsive to project development. A key principle of scrum is the recognition that for a customer project can change their minds about what they want and need (often called " requirements churn " ) , and that unforeseen challenges cannot be handled easily, predictively or traditional planned. As such, it adopts a mixed approach accepting that the problem cannot be fully understood or defined, focusing on maximizing the team's ability to deliver quickly and respond to new empirical requirements. And what Dr.Jeff (Sutherland, 2015) says in his article .Scrum divides complex work into simple pieces, large organizations into small teams and far-reaching projects into a series of short time horizons called sprints. When complex work is divided into simple pieces it is easier to map out what needs to be done. With a clear roadmap the team can start working immediately, know what items need to be worked on together and understand when the job has been completed. Small bites of work, just like food, are easier to chew, swallow and digest. So solo scrum is where a single person is going to perform all the task of multiple stakeholders in a project .Even though it is not an official SDLC people who have tried it say that they can perform and accomplish really heavy tasks with ease (Bell, 2015) Benefits No need for a team .A single person could work as if he is a team.
  • 21. 18 Drawbacks Not official, so no proper documentation to follow. No Client in project, as Numver is not a bespoke project, so cannot evaluate with a client time to time Figure 11 Scrum Flow chart 6.2 PXP (personal Xtreme programming) Personal extreme programming is once again another agile based SDLC for autonomous developers which allows two individuals to perform all the stages of the project. While an individual works on a single aspect of the software the next persons monitors it and the vice versa. This is done in iterative way until the final stage of the project. As mentioned by (Yani Dzhurov, 2009) and also what the figure depticts . Figure 12 PXP flowchart
  • 22. 19 6.3 Prototyping The prototype model is a systems development methodology in which to realize the project requirements of a prototype system is made that implements the known characteristics , this then can be presented , used and tested by all stakeholders before going back to the development team to be reformulated for the next prototype stage to be made (Rouse, 2005). This model is advantageous when you need a solution quickly. The prototyping model allows users to participate actively in the development, allowing any bugs to be detected early and corrected before the final release (ISTQB Exam Certification, 2015). Figure 13 prototyping work flow diagram 6.4 Selecting the most suitable methodology for the project After vigorous research it was decided that prototyping would rather suit best for this project as the features that would be available in the final product could be depicted, then a prototype could be made and after letting a user use the developed prototype further adjustments could be made to suit the feedback of the user so that all the requirements could accurately cater to user’s requirements.
  • 23. 20 6.5 Use case diagram Application User Scan a scratch card and perform a top-up Check Balance input scratch card PIN manually activate data,sms,talk time packages share application online generate report on all top-ups performed using the app Figure 14 Use case scenario for the Numver mobile application
  • 24. 21 7 Selecting appropriate Technologies 7.1 Choosing the platform for the app to run 7.1.1 Google’s android Operating system Google maintains an operating system called Android. It has all the low - level "stuff” as well as the necessary middleware power use an electronic device, and is freely given to anyone who will take the code and build the operating system from it. There is even a complete application framework included, so third party applications can be built and installed then available for the user to run as they like. The name for this is the project of the Android Open Source Project, and that's what people mean when they say things like Android is open and free. Android, in this iteration, is free for anyone to use as they like. (Hildenbrand, 2015) 7.1.2 Apple’s IOS IOS is the mobile operating system from Apple used to run the iPhone, iPad and iPod Touch popular. Formerly known as iPhone OS, there are more than 900,000 applications available for download on Apple IOS App Store, the most popular application store any mobile device. IOS uses a multi -touch interface, where simple gestures are used to operate the device, such as swipe the screen to move to the next page or pinch your fingers to zoom out. Since its release, IOS has gone through several updates, with recent updates by adding the ability to create folders for application icons and the ability to multi- task. Updates are usually free for iPhone and iPad users, while iPod Touch users are sometimes required to pay a fee. (Nations, 2015)
  • 25. 22 7.1.3 Android Operating System or IOS Choosing between Google’s android OS with Apple’s IOS was a difficult task. Development vise both of them had enough resources. But choosing the best for this project was a tough job .At first it was decided that the app would run on both platform, but after performing the survey (appendix I), it was found that most prepaid mobile users used an android based device rather than IOS device. So it was worthless to spend more time developing for both the platform thus android operating system was chosen also with the following points considered. 7.1.4 Development difficulty Figure 15 comparison of different programming difficulties for different Operating system This shows that android is somewhere in the middle of difficulty in developing apps as mentioned by (Pundits, 2015).
  • 26. 23 OS Users Android IOS other Figure 16 pie chart results from the survey "different operating users within the university" 7.2 More users than IOS After considering the results obtained from the survey it was found that more students use an android based device rather than an ios device. 7.2.1Questioner report Results 7.3 Choosing the image processor OpenCV (open computer vision), Mathworks Matlab or Qualcomm’s FastCV Choosing one from these was a difficult task. 7.3.1 OpenCV OpenCV is an open source image processing Library which could be used develop application which features image recognition or image processing, recommended by most of the developers (anonymous, OPENCV, 2015),OpenCV runs directly on androids kernel which makes it one of the faster image processing libraries. 7.3.2 Matlab Matlab is a relatively easy language to start. Matlab is really a high-level scripting language, which means you do not have to worry about libraries, declaring variables, memory management or other low-level programming
  • 27. 24 problems. As such, it can be very easy to throw together some code to prototype your image processing idea. (anonymous, matworks, 2015). 7.3.3 FastCV from Qualcomm FastCV provides an optimized mobile computer vision library that packs if image processing tools most widely used for use in a wide variety of mobile devices, even mass-marketdevices. (Qualcomm, 2015). OPENCV MATLAB FASTCV specificity Made for image processing only Made as a generic image processor Made for image processing only Speed 30 frames per second( real time) 3-4 frames per second(not real time) Not real time Efficiency Less resources needed (good for mobile devices with less resources) More resources needed compared to OpenCV Moderate amount of resources needed Ease of programming Hard compared to Matlab Easy moderate IDE availability No specific IDE (should configure an IDE with OpenCV before use) Matlab integrated IDE available No specific IDE (should configure an IDE with FastCV before use) Memory management Really low considered to Matlab High memory management unknown Price Free(open source) List price for the base (no toolboxes) free
  • 28. 25 MATLAB (commercial, single user License) is around €1500 euros Mobile support OpenCV for android Not supported supported Mobile Architecture support All leading mobile architecture Not applicable ONLY ARM based processors Table 1 Comparison of three image processing libraries 7.4 Choosing the Optical Character Recognition Engine After the frame is captured and processed using OpenCV image processing libraries, the processed frame will be passed on to an OCR which will extract the PIN number from the frame so that the pin number can be manipulated and can be used for the top up process (see section 9 for more info). To select the best OCR libraries available a comparison was made between “ABBYY Mobile OCR Engine” and “Tesseract OCR”. 7.4.1 ABBYY Mobile OCR Engine Abbyy OCR Engine aids developers integrate OCR into smartphones, the SDK provided by them helps users to convert images and photographs into a digital source which can be edited and used to search and so forth (unknown, 2015) Abbyy OCR Engine is by far the best OCR available in the market its rates of recognition is really good in compared to other OCR engines (look table 2) in the market, the only drawback it has is that it comes as a commercial version where developers have to pay to get a license.
  • 29. 26 7.4.2 Tesseract OCR Engine Released under the Apache License 2.0. (apache, 2015), On the other hand Tesseract is rated for its best accuracy among three other OCR engine in the market. It has its advantage as it is open source so it is free of charge. Comparison of the two selected OCR. Abbyy OCR Tesseract OCR specificity Made for character recognition Made for character recognition Speed Really low compared to Tesseract Fast Efficiency Less resources needed (good for mobile devices with less resources) More resources needed compared to Abbyy Ease of programming Hard Easy Price 15 000 USD with ABBYY Mobile Imaging OCR SDK Free(open source) Mobile support yes yes Mobile Architecture support All leading mobile architecture All leading Mobile architecture Table 2 comparison between the two OCR
  • 30. 27 Comparison of leading OCR for Linux based operating system courtesy (Gohr, 2015) . ABBYY OCR CUNEIFORM GOCR OCRAD TESSERACT License Proprietary BSD GPL2 GPL3 Apache 2.0 Version 8.0 0.9.0 0.48 0.19 SVN r402 Input-Format PNG1) PNM PNM PNM TIF2) Recognition rates and time spent: courier/black 100% (2.92s) 61% (1.11s) 67% (0.09s) 21% (0.02s) 81% (0.63s) courier/gray 100% (2.85s) 67% (0.09s) 21% (0.03s) 81% (0.63s) justy/black 11% (3.62s) 3% (1.14s) 31% (0.11s) 1% (0.02s) 15% (0.61s) justy/gray 14% (3.45s) 31% (0.10s) 1% (0.02s) 15% (0.60s) times/black 100% (2.80s) 96% (1.07s) 76% (0.16s) 82% (0.03s) 92% (0.74s) times/gray 100% (2.87s) 76% (0.16s) 82% (0.03s) 92% (0.74s) verdana/black 100% (2.90s) 95% (1.07s) 98% (0.10s) 98% (0.03s) 98% (0.45s) verdana/gray 100% (2.85s) 98% (0.10s) 98% (0.02s) 98% (0.46s) Table 3 comparison of 4 best OCR in the market 7.4.3 Tested image data (for test carried out mentioned in table 3) Figure 17 Test image for courier/black Figure 18test image for courier/gray
  • 31. 28 Figure 19 Test image for justy/black Figure 20 Test image for justy/gray Figure 21 Test image for times/black Figure 22 Test image for times/gray Figure 23 Test image for verdana/black
  • 32. 29 Figure 24 Test image for verdana/grey Images and tables used for above test are the courtesy of (Gohr, 2015). After many consideration, a final decision was made as to use Tesseract, because Tesseract is really fast in generating outputs (table 3) and it is also praised for its accuracy which are some of the vital requirements for this project. 7.5 Database management To manage data within the app a local database was required for this purpose. Two already existing database management system was selected and compared. 7.5.1 Comparison between DBMS SQLite H2 database engine Footprint 350KiB ~1MB License Public domain Dual: Modified MPL 1.1 / EPL 1.0(commercial friendly) Self-contained ✔ ✔ Single file ✔ ✔ Server less ✔ ✔ Server-mode ✖ ✔ Zero- configuration ✔ ✔ Transactions ✔ ✔
  • 33. 30 Indices ✔ (B-tree, R- tree, full-text) ✔ (B-tree, tree, hash, full-text) Encryption ✖ ✔ In-memory databases ✔ ✔ Android native support ✔ ✖ Table 4 comparison between databases SQLite was chosen as it was really user friendly and it had native support for android so that adding extra libraries to the application is omitted thus reducing the file size of the final application. 7.6 Workbench Selection (android studio or eclipse ADT) This was one of the toughest choice to make, both of them had their pros and cons, and some of them are tabulated below. 7.6.1 Android studio Android studio is the official IDE to develop android application which was released on December 2014 as version 1.0, it is based on Jetbrain’s IntelliJ IDEA (IDEA, 2015) it supports multiple operating system like Windows, Mac OS X and Linux. (anonymous, android, 2015). 7.6.2 Eclipse adt Eclipse Android development tool is really a plugin for the already existing eclipse IDE, both the ADT and the android sdk has to be installed before using eclipse for android application developed (anonymous, android, 2015).
  • 34. 31 7.6.3 Comparison between different IDE’s Android studio Eclipse ADT Ease of use Easy Easy Bugs As it is new might possess some bugs Less chances of finding a bug Online helps Very few as it is new Sufficient amount of help available IDE Performance/Stability Not stable as it contains bugs but overall experience is smooth Stable but is resource hungry need more ram for pure smooth experience Project Organization Good Good User Interface Design Really good Somewhat better Table 5 comparison between workbenches
  • 35. 32 8 Design The android app which will later be packed and deployed as a single apk, will first be created using the selected Eclipse IDE, the folder structure of a typical android application is briefed below. 8.3 Folder structure 8.4 Brief detail about the folder structures Directory Description src This is where all the user defined logics is coded. gen This directory on an Android application consists of all the files automatically generated. You can Figure 25 folder structure for android using eclipse ide
  • 36. 33 see R.java within this folder, which is a generated class that contains references to certain project assets. R.java is created automatically by the Eclipse IDE and any manual changes are not necessary. res This directory on an Android application consists of all the files automatically generated. You can see R.java within this folder, which is a generated class that contains references to certain project assets. R.java is created automatically by the Eclipse IDE and any manual changes are not necessary. /res/values It is used to set styles, strings, colors, dimensions and static arrays. By convention each type is stored in a separate file, for example, strings are defined in the file res / values / strings.xml, so on and so on. / Res / values - v16 is the API version of the 16 values (android version 4.1 Jellybean), and / res / values - v15 is the API version of the 15 values (version 4.0.1 android ice- cream sandwich). /res/animator This directory includes XML animation for animation API property that lets you animate properties of random objects over time. /res/layout This directory contains the layouts to be used in the application. A
  • 37. 34 layout feature shows the architecture for the user interface in an activity or a component of a UI.As Android device support multiple screen sizes, these resource directories in an application provides several layout templates for different screen sizes. /res/layout - layout for normal screen size or default screen size. /res/layout-small - layout for small screen size. /res/layout-large - layout for large screen size. /res/layout-xlarge -layout for extra-large screen size. /res/layout-xlarge-land - layout for extra-large in landscape orientation. /res/layout-sw600dp - layout for tablets or layout for 7” tablets (600density pixel (dp) wide and bigger). /res/layout-sw720dp - layout for 10” tablets (720dp wide and bigger) /res/layout-w600dp - layout for Multi-pane (any screen with 600dp available width or more). ./res/menu This directory menu consist of resources to be used in the application. /res/raw Resource materials that can be searched by their resource IDs are stored in this directory. These
  • 38. 35 features can be referenced from all other resources in the same way we do with other resources. /res/drawable The folders are resource directories in an application that provides different bitmap drawable for medium , high screens , and extra high density./res/drawable-mdpi - bitmap for medium density /res/drawable-hdpi - bitmap for high density /res/drawable-xhdpi - bitmap for extra high density /res/drawable-nodpi - bitmap with no pre-scaling. libs External library files are placed in this folder. If you want to add any external library in place the jar library project within this folder will be added to the class path automatically. Assets This directory has the gross structure of files and directories without other capabilities. It's just a hierarchy of unstructured files , allowing you to put whatever you want there and later recover as raw Byte streams. bin Bin is that the use of the compiler to prepare the files to be finally packaged for application APK file. this includes • Compile your Java code into class files.
  • 39. 36  Place your resources (including images) in a structure to be compressed to the APK. AndroidManifest.xml This is an XML control file that stores key information about the application to the Android system, the system information should have been added to it before it can run any application code. This control file describes the nature of the application and each of its components, such as the granting of permission to access device features. project.properties Project.properties is the main project properties file with the extension “.properties “containing information on the construction platform destination and the library dependencies. Project.properties file was renamed default.properties in older versions of the SDK. This file is essential for the project to be executed. Table 6 brief description about all the directories in the eclipse IDE
  • 40. 37 8.5 Class Diagram This basic class diagram shows the classes and functions of the application. Android Activity Numver main Activity -pin_number:int -last_balance:float -topup_history:float[0.*] -total_top_made:float +scanCard(output:int) +sendTextToReload(input:int,output:bo ol) manupilateString(input:string,output:stri ng) +checkBalance(output:int) +activatePackage(input:string) +manual_reload(input:double) Scratch Card -scartc_card_number:double -maxminm_price_LKR:float +setScratchCardPIN(input:double) +getScratchCardPIN(output:double) Data/SMS card data_value:int sms_value:int +setDataValue(input:int) +getDataValue(output:int) +setSmsValue(input:int) +getSmsValue(output:int) Talktime card -taltime_value:int +setTalktimeValue(input:int) +getTalktimeValue(output:int) IDD card -idd_talktime:int +setIDDTalktimeValue(input:int) +getIDDTalktimeValue(output:int) Package -package_name:string -package_id:int -packge_details:String +activatePackage(input:String,output:bo ol) +deactivatePackage(input:String,Outut;b ool) 1 0 ..* User 1 0..* 1 1 Figure 26 Class diagram for Numver application A user can have many packages, he/she can also activate as many scratch card as possible from the app. scratch cards are of 3 different types they are Data/sms cards, Talk time only cards and IDD cards, all these cards possess their own properties and they also possess some properties in common, which is centralized in a class called scratch card.
  • 41. 38 8.6 Use case scenarios 1.Use case name: Perform automated reload 2.precondions: Have a valid scratch card 3.Primary Actor: App user 4. Main Flow of Events: 1.User aims the scratch card towards the rear camera 2. Selects the value of the scratch card. 4. Aligns the PIN number with the aid of the green box. 5. Taps the top up button. 6. Taps the dialog box PIN value with the scratch card PIN value. 7. Taps okay button 8. App performs the reload 4.extensions 4(a). If the pin number is less than or greater than 12 digits or 16 digits (depending on the mobile subscriber) 4(a) 1.show dialog box saying wrong integer count 4(a) 2.start from step 2 Table 7 use case scenario to perform an auto top-up 1.Use case name: Check user account balance 2.precondions: Started the application. 3.Primary Actor: App user 4. Main Flow of Events: 1.Taps check balance button 2. App checks the balance and displays it.
  • 42. 39 4.extensions Table 8 use case scenario to check balance 1.Use case name: Perform manual Top-up 2.precondions: Have a valid scratch card 3.Primary Actor: App user 4. Main Flow of Events: 1. Taps the manual top-up button. 2. Enters the PIN with the number pad. 3. Taps okay. 4. Taps confirm in the dialog box. 4.extensions 2(a). If the pin number is less than or greater than 12 digits or 16 digits (depending on the mobile subscriber) 4(a) 1.shows a dialog box saying wrong integer count 4(a) 2.start from step 2 Table 9 use case scenario to perform a manual top-up 1.Use case name: Activate packages 2.precondions: App is open and loaded 3.Primary Actor: App user 4. Main Flow of Events: 1.Taps on package selection button 2. Select appropriate package the user requires. 3. App activates the package. 4.extensions Table 10 use case scenario to activate a package 1.Use case name: Display top up history 2.precondions: App is open and loaded 3.Primary Actor: App user 4. Main Flow of Events: 1.Taps on top-up history button 3. App displays the top-up history.
  • 43. 40 4.extensions Table 11 use case scenario to view top up history 8.7 Wireframe models Wireframes for the GUI, developed using the above requirements Figure 27 wireframe diagram of the main user inteface Designed using ninja mock (ninjamock, 2015) Wireframe is accessible via here A This will redirect to package selections page. B Shows the logo of the mobile subscriber the smartphone is registered to. C This will prompt the user with the current balance of his connection. D Enables user to manual input a pin if the scanning of the scratch card gives an inaccurate result. E This green box is a guideline to the user, it helps the user to align the PIN number for the scan to proceed. F Once the user aligns the PIN number within the green box he/she has to press this button to proceed with the top up. G This shows a brief report of all the top the user has during the use of this app. H The camera view which shows the camera in the background.
  • 44. 41 I User will have to select one of this option based on the card they top-up, so that it would be helpful to generate reports. More wireframes Figure 28 wireframe showing user balance This dialog will be shown after the user presses the check Balance button Figure 29 wireframe showing the manual PIN input screen This dialog is shown when the user presses the input PIN button
  • 45. 42 Figure 30 wireframe showing the package selection menu This dialog is shown when the user press he activate package button
  • 46. 43 9 Implementation After the designing phase, the implementation phase began, where the workbench was set and all the resources where optimized to its best. 9.3 Setting up the workbench Setting up the workbench can be divided into three  Installing eclipse Juno and setting up the ADT bundle.  Installing Android NDK, CDT plugin and setting it up with Eclipse.  Installing libraries (OpenCV, Tesseract). 9.3.1 Installing eclipse Juno and setting up the ADT bundle This was a piece of cake compared to others, the eclipse package was downloaded from their official website (ecllipse.org, 2015) , after which android adt bundle was installed within eclipse with the help of the built in software installer, which is found under help –>install new software. A real device was used for debugging purpose as the project uses a compulsory rear facing camera For this purpose an ASUS zenfone 5 was used 9.3.1.1 Asus zenfone 5 features Screen Size 5.0 inches (~63.9% screen-to-body ratio), 720 x 1280 pixels (~294 ppi pixel density) Camera 8 Megapixel, 3264 x 2448 pixels with autofocus Processor Dual-core 2 GHz, Intel Atom Z2580 Ram 2 GB Network GSM / HSPA Platform Android OS, v5.0.2 (Lollipop). Figure 31 features of the phone used to develop the application
  • 47. 44 Figure 32 layers of android mobile architecture 9.3.2 Installing the Android NDK, CDT plugin and setting it up with eclipse (Xian, 2015) 9.3.2.1 About android NDK Now this is where things get a bit complicated .First let’s have a look at what Android NDK is. Android NDK or Android native development kit is a set of tools which allows a developer to implement parts of their app using native-code languages such as C and C++. Typically, good use cases for the NDK are CPU-intensive applications such as game engines, signal processing, and physics simulation. Usually all android apps run in the dalvik virtual Machine, as it takes time to execute a code it will not suite our use case where top-up should be processed in real time. This is were android executes the code usually. Android code execution goes through JVM(which is the dalvik virtual machine in android) and then the Hardware layer after which it is executed,which consumes a lot of time. Figure 33 presumed time taken for code execution normal for java For real-time image processing the code should execute in here
  • 48. 45 Figure 34 presumed time taken for code execution normal for compiled language *Diagrams are not an actual depiction of time taken of a CPU fetch-decode-execution cycle, only for illustrative purpose. But if we use android NDK we could bypass the dalvik VM and execute the code directly in the Linux kernel (hardware decode only) (Xian, 2015) So in this case Android NDK is used by the OPENCV library to process images in real-time. Drawbacks The only drawback in this is that the application should carry libraries for all CPU architecture which considerable increases the package file size. Figure 35 illustration for multiplatform support with android ndk 9.3.2.2.Installing Android NDK and CDT plugin First the setup file was downloaded from android NDK (android, 2015) website, after installing the ndk with the help of the setup file .eclipse was configured with android ndk this documentation gave a helping hand in setting up the ndk (opencv, 2015) , the CDT plugin was also downloaded like the adt plugin with the help of Eclipse’s built in software manger
  • 49. 46 These are the steps taken to setup android NDK and CDT plugin  Install NDK setup in a convenient location. (An important point to consider when installing the ndk is to omit any spaces in the installation file path names).  Open Eclipse IDE and install the NDK plugin provided by android from help->install new software menu and restart eclipse  Now in eclipse go to windows-> preferences-> NDK and provide the folder path where you have installed all the ndk files before on step one. This is how the android NDK was supposed to be installed with the help of the document (opencv, 2015) but there was a problem using this method which will be briefed on ‘problems faced’ section 11. 9.3.3 Installing libraries (OpenCV, Tesseract) Installing libraries was simple, within eclipse you have to import the library as an existing android project, then go to project properties of the imported Library->Android-> and select ‘is Library’ option under Library. This was done for both OpenCV 3.0 and Tesseract. Additionally for Tesseract the whole library has to build for all processor architecture. In command prompt change the working directory to where the library is and then run the “ndk-build” command. It took around 2 hours for the whole library to build. (Raghavan, 2015). And to run Tesseract extra language data files were needed which could be found in (google, 2015). This file was placed on the device’s SD card root folder so that Tesseract library could access it. After which a new project was created for Numver application. Information about code samples is present in the appendix II section
  • 50. 47 9.4 The process of extracting text from image Figure 36 flow of a scratch card frame throughout many process The above diagram shows the flow of a selected frame, which is passed between a couple of libraries for text to be extracted. Within OpenCV the following image manipulation is processed with the incoming frame  Crop the area with PIN number separately so that the image will be processed quickly, rather than processing a whole frame, processing a small position of screen is more efficient and further more unwanted data which will be present on the frame will not be processed.  Change the cropped frame to grayscale for maximum efficiency.  Apply a median Blur for the cropped frame o “The median filter run through each element of the signal (in this case the image) and replace each pixel with the median of its neighboring pixels (located in a square neighborhood around the evaluated pixel).” (OpenCV, 2015)  Apply an adaptive threshold and then send it to Tesseract o “In this, the algorithm calculate the threshold for a small regions of the image. So we get different thresholds for different regions of the same image and it gives us better results for images with varying illumination.” (author, 2105)
  • 51. 48 Figure 38 this is how the main interface looks like 9.5 Running the application. After implementation of the code, it should run on the following device 9.6 System requirements Minimum requirements  Android device with an API level 16 or more (android 4.1 jelly bean)  A rear camera.  A single core 1000mhz or more CPU Recommended requirements  Android device with an API level 21 or more (android 5.0 lolipop)  A rear camera 5 megapixel sensor or more.  A dual core 2.0 GHz or more CPU. 9.7 Final application These were some of the screenshots captured from the Numver application 9.7.1 The Numver Logo 9.7.2 Application Screenshots Figure 37 logo of the scratch card
  • 52. 49 Figure 39 the confirm reload dialog box Figure 40 the package selection menu Figure 41 Number pad to input scratch card PIN manually Figure 42 dialog box before performing a manual reload
  • 53. 50 10 Testing the Application Many test where carried out to make sure the application was stable and to make sure that the users had the best user experience. Some such test are listed below 10.3 Character recognition test The app was tested for its Character recognition accuracy on scanning different scratch cards under different lighting conditions, and the results are tabulated below. Scratch card Pin Value Scanned results 1 3566 9208 9321 356692089321 2 9184 5765 8971 918457658971 3 7251 0780 7854 725107807854 4 9584 8475 7384 958484757384 5 7683 6572 7682 768300727682 6 6748 2642 7583 674826427583 7 5738 7485 2637 573874852637 8 8593 0473 8237 859304738237 9 7584 6423 8492 758462238492 10 8694 3838 8483 869438388483 Table 12 test results for character recognition Character recognition test was not one hundred present successful as there were some numbers that Tesseract miss extracted, the reason for this inaccuracy should be due to bad lighting, and if a user face this problem he/she might use the manual PIN enter function.
  • 54. 51 10.4 Application stability test The application was vigorously tested for possible bugs and the results are as follows TEST TYPE Auto Top-up STEPS 1. Aim scratch card towards the camera 2. Select the value of the scratch card. 4. Align the PIN number. 5. Tap the top up button. 6. Tap OK in the dialog box PIN value with the scratch card PIN value. 7. Tap okay button TEST RESULTS App performs the automatic top-up successfully after performing the above steps. Table 13 Test case for auto top-up TEST TYPE Perform manual top-up. STEPS 1.tap the manual top-up button 2.enter the PIN with the number pad 3.tap okay 4.input the amount to top-up 5.tap confirm in the dialog box TEST RESULTS App performs the manual top-up successfully after performing the above steps. Table 14 Test case for manual reload TEST TYPE Activate specific packages
  • 55. 52 STEPS 1. Tap activate package button. 2. Tap a specific package. 3. Confirm the dialog box. TEST RESULTS App Activates the specified package and displays a success dialog box Table 15 Test case for package activation TEST TYPE Display top up history STEPS 1. Tap top-up history. TEST RESULTS App Display all top history Table 16 Test case to display top-up History TEST TYPE Check user account balance. STEPS 1.tap check balance button TEST RESULTS App Display balance credit Table 17 Test case to show balance
  • 56. 53 11 Problems faced during the course of the project Projects are meant to find solutions for a specific problem, but this project had more problems than what was expected. Some such are briefed below 11.3 Setting up the NDK As mentioned in section 9, both the OpenCV and the Tesseract OCR never worked as suggested by (Xian, 2015) after some searching, found out that setting up Android ndk path within the eclipse ide did not work for OpenCV but setting the Android ndk path as separate variable within windows environment variables was detected by OpenCV, and he libraries worked as expected. Figure 43 setting up environment variable for Android NDK 11.4 OCR never recognized the characters from an image accurately At first after receiving a frame from OpenCV and passing it to Tesseract just gave garbage values, after applying many filters to the frame some accurate results were obtained. This was one of the toughest problem to overcome, After many trial and error method of changing the parameters which was passed to the filters the results started to turn better and after days of tweaking the parameters, Accuracy was increased to a level so that results where even better at low light. 11.5 Portrait mode did not work OpenCV natively supported only landscape mode, but users’ preferred to use this application in portrait mode. Steps were taken to convert the
  • 57. 54 application to portrait mode, for this purpose Library files where altered, after altering the library files the application worked in portrait mode, but the performance was considerable low, So when compared to user satisfaction and usability, usability should be given a high priority, so portrait problem was ignored, thus the application was developed in landscape mode. There were more small problems which were later resolved with the help of the internet.
  • 58. 55 12 Further Development Many aspects of this application could be improved. Firstly this app could be developed to support multiple mobile service providers rather than just one, so that more users could benefit from this application. Furthermore the accuracy of the character recognizer could be increased by either training the already existing Tesseract engine or changing the OCR engine to a more reliable one. The interface of the application should be improved as currently it is not that user friendly The application does not support multiple SIM devices, only the first active SIM is taken to consideration when the application is used. But this application could be developed to support multiple SIM devices.
  • 59. 56 13 Personal Development Throughout the development of this project a great quantity of wisdom was learned, from Image processing, character recognition, android app designing even to time management in real world project. It was a great experience heading along with the project alone, but still there was the encouragement of the people, which made this project a great success. In the beginning programming with android was new, after design and research, it became clear that it would be the best choice for the development of this application, and not only that, this technology can also be used to deploy powerful applications quickly and effectively. Thus this project has highly helped me in pushing whatever I have learned for the last 3 years into a reality, with the help of this project I have discovered the real potential of me. The way I could cope with deadlines, the way I could face real world challengers. Once again this project has given me a great amount of experience to face the industry, and I guess I am ready to face it.
  • 60. 57 Bibliography android. (2015, 5 12). android developer. Retrieved from android ndk: https://developer.android.com/ndk/downloads/index.html anonymous. (2015, 06 12). android. Retrieved from android adt: http://developer.android.com/tools/sdk/eclipse-adt.html anonymous. (2015, 07 26). android. Retrieved from android devloper: http://developer.android.com/tools/studio/index.html anonymous. (2015, 05 30). matworks. Retrieved from matlab: http://in.mathworks.com/products/matlab/ anonymous. (2015, 06 12). OPENCV. Retrieved from opencv for android : http://opencv.org/platforms/android.html apache. (2015, 12 07). license. Retrieved from http://www.apache.org/licenses/LICENSE-2.0 Apps, R. (2015, 07 23). OCR - Text Scanner. Retrieved from https://play.google.com/store/apps/details?id=com.offline.ocr.english .image.to.text author, m. (2105, 05 09). Doc.opencv. Retrieved from OpenCV thresholding : http://docs.opencv.org/master/d7/d4d/tutorial_py_thresholding.html Axiata, D. (2015, 07 24). dialog.lk. Retrieved from factsheet: https://www.dialog.lk/fact-sheet Bell, B. P. (2015, 07 24). Solo Scrums. Retrieved from http://www.pbell.com/index.cfm/2007/6/17/Solo-Scrums ecllipse.org. (2015, 07 17). eclipse. Retrieved from eclipse juno: https://eclipse.org/juno/ Gohr, A. (2015, 12 22). Splitbarain.org. Retrieved from Linux OCR Software Comparison: http://www.splitbrain.org/blog/2010-06/15- linux_ocr_software_comparison google. (2015, 6 12). tesseract. Retrieved from language data: https://code.google.com/p/tesseract-ocr/downloads/list Hildenbrand, J. (2015, 06 29). Android Central. Retrieved from What is android : http://www.androidcentral.com/what-android IDEA, i. (2015, 06 23). intelij IDEA. Retrieved from intelij IDEA: https://www.jetbrains.com/idea/ ISTQB Exam Certification. (2015). What is Prototype model- advantages, disadvantages and when to use it? Retrieved 03 03, 2015, from ISTQB Exam Certification: http://istqbexamcertification.com/what-is- prototype-model-advantages-disadvantages-and-when-to-use-it/ Nations, B. D. (2015, 07 24). about tech. Retrieved from what is iOS: http://ipad.about.com/od/iPad-Glossary/g/What-Is-iOS.htm
  • 61. 58 ninjamock. (2015, 04 26). ninjamock. Retrieved from wirframe creator for Android apps: http://ninjamock.com/home/index OpenCV. (2015, 05 23). OPENCV. Retrieved from Image filters : http://docs.opencv.org/doc/tutorials/imgproc/gausian_median_blur_ bilateral_filter/gausian_median_blur_bilateral_filter.html OpenCV vs Matlab. (2015, 07 17). Retrieved from http://blog.fixational.com/post/19177752599/opencv-vs-matlab opencv, o. (2015, 05 12). openCV. Retrieved from setting opencv for android: http://docs.opencv.org/doc/tutorials/introduction/android_binary_pac kage/android_dev_intro.html Pundits, M. (2015, 07 17). Cross-Platform App Development in C#. Retrieved from http://www.slideshare.net/poojarunija/crossplatform- app-development-in-c Qualcomm. (2015, 07 26). developer.qualcomm. Retrieved from fastcv: https://developer.qualcomm.com/software/fastcv-sdk Raghavan, k. (2015, 06 04). www.kaustubhraghavan.com. Retrieved from Tesseract OCR: http://www.kaustubhraghavan.com/ocr.html Rouse, M. (2005, 08). Prototyping Model. Retrieved 03 03, 2015, from TechTarget: http://searchcio.techtarget.com/definition/Prototyping- Model Sutherland, J. (2015, 07 24). basic of scrum. Retrieved from https://www.google.lk/url?sa=t&rct=j&q=&esrc=s&source=web&cd= 1&cad=rja&uact=8&ved=0CB0QFjAAahUKEwjwocKk9vLGAhUhraYKHY aCBJ4&url=http%3A%2F%2Fwww.scruminc.com%2Fwp- content%2Fuploads%2F2014%2F06%2FThe-Basics-of- Scrum.pdf&ei=NL6xVfC3LqHamgWGhZLwCQ&usg=AFQjCNH Tung, A. (2015, 07 23). invoice 123. Retrieved from https://play.google.com/store/apps/details?id=tw.idv.arlen&hl=en unknown. (2015, 07 23). ABBYY. Retrieved from ABBYY mobile OCR: http://www.abbyy.com/mobile-ocr/ Wellnitz, R. (2015, 07 23). Text Fairy (OCR Text Scanner). Retrieved from https://play.google.com/store/apps/details?id=com.renard.ocr&hl=en Xian, G. (Director). (2015). Tron Academy Episode 2- Setting Up Android NDK and OpenCV on Eclipse [Motion Picture]. New Zealand. Retrieved 04 12, 2015, from https://www.youtube.com/watch?v=N2onPuDZQVY Yani Dzhurov, I. K. (2009). Personal Extreme Programming – An Agile Process. Proceedings of International Conference on SOFTWARE, SERVICES & SEMANTIC TECHNOLOGIES (pp. 253-259). Sofia, Bulgaria: Demetra EOOD.
  • 62. 59 Glossary Top up A way to add money to your mobile phone connection Scratch Cards Sold in shops ,where some secret content is hidden under, a customer who buys one of them could scratch the surface of the card so that the secret content is revealed , In this context used to top up a mobile phone connection Numver Name of the application which is developed in this project Workbench A tool used to make something, in this context tools used to build the application API Short form for application program interface, it is a set SDK Short form for software development kit used to develop software specific application NDK Short form for Native development kit used to develop software with support for Native language support in Android, NDK allows users to partly develop their app in C or C++ languages Postpaid connection A mobile connection providers system of receiving money, an invoice will be dispatched to the connection owners resident and the owner would submit the invoice at an outlet to pay his/her mobile bill.
  • 63. 60 Prepaid Connection A mobile connection providers system of receiving money, A typical user should maintain a specific amount of money in his/her account to use any feather provided by the service provider( for E.g. make or call or browse the internet) A user could add money to his account via any method specified by the service provider. IDE Another word for workbench
  • 64. 1 Appendix I Questionnaire for Mobile phone users 1. Do you own a working cellular phone? a. Yes I do b. No I don’t 2. If yes, is it a smartphone or not a. Yes it is a smartphone b. No it is not a smartphone 3. If yes, what operating system the phone is running on a. Android Operating System b. Apple’s I Operating system c. Microsoft windows phone operating system d. Others 4. How many working mobile or cell phones do you currently have? 5. Do you use a multi SIM phone, a. Yes I use a multi SIM phone. b. No I don’t use a multi SIM phone. 6. Are you registered to valid mobile service provider in Sri Lanka or not a. Yes I am registered. b. No I am not registered. 7. If yes, what mobile service provider are you registered to a. Mobitel telecom b. Dialog axiata c. Airtel d. Etisalat e. Hutch 8. Please specify whether you are a prepaid customer or a postpaid customer? a. I am a prepaid customer. b. I am a postpaid customer. _____________________ Signature
  • 65. 2 Appendix II Coding snippets Application permission and more from the manifest.xml file <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="org.ISDCF.Numver" android:versionCode="21" android:versionName="2.1"> <supports-screens android:resizeable="true" android:smallScreens="true" android:normalScreens="true" android:largeScreens="true" android:anyDensity="true" /> <application android:allowBackup="true" android:label="@string/app_name" android:icon="@drawable/icon" android:theme="@android:style/Theme.NoTitleBar.Fullscreen" > <activity android:name=" MainActivity" android:label="@string/app_name" android:screenOrientation="landscape" android:configChanges="keyboardHidden|orientation"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> </application> <uses-sdk android:minSdkVersion="8" /> <uses-permission android:name="android.permission.CAMERA"/> <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/> <uses-permission android:name="android.permission.SEND_SMS" /> <uses-permission android:name="android.permission.CALL_PHONE"/> <uses-feature android:name="android.hardware.camera" android:required="false"/> <uses-feature android:name="android.hardware.camera.autofocus" android:re- quired="false"/> <uses-feature android:name="android.hardware.camera.front" android:re- quired="false"/> <uses-feature android:name="android.hardware.camera.front.autofocus" android:re- quired="false"/> </manifest>
  • 66. 3 Imports for the application //imports for opencv import org.opencv.android.BaseLoaderCallback; import org.opencv.android.CameraBridgeViewBase.CvCameraViewFrame; import org.opencv.android.CameraBridgeViewBase.CvCameraViewListener2; import org.opencv.android.JavaCameraView; import org.opencv.android.LoaderCallbackInterface; import org.opencv.android.OpenCVLoader; import org.opencv.android.Utils; import org.opencv.core.CvException; import org.opencv.core.Mat; import org.opencv.imgproc.Imgproc; //default imports import android.app.Activity; import android.app.AlertDialog; import android.content.DialogInterface; import android.content.Intent; import android.graphics.Bitmap; import android.net.Uri; import android.os.Bundle; import android.os.Environment; import android.telephony.SmsManager; import android.text.InputType; import android.util.Log; import android.view.Menu; import android.view.MenuItem; import android.view.SurfaceView; import android.view.View; import android.view.WindowManager; import android.widget.ArrayAdapter; import android.widget.Button; import android.widget.EditText; import android.widget.ImageView; import android.widget.Toast; //imports for Tesseract OCR import com.googlecode.tesseract.android.TessBaseAPI;
  • 67. 4 Variable declarations //logcat variable private static final String TAG = "OCVSample::Activity"; //camera view private JavaCameraView mOpenCvCameraView; //Variables for all the buttons in the interface private Button reload; private Button pkg_activation; private Button chk_balance; private Button manual_pin; private Button topup_history; //variables for sending messages and USSD codes private String m_Text = ""; private String ussdCodeCheckBalance = Uri.encode("#")+ "456" + Uri.encode("#"); private String ussdCodeReload= Uri.encode("#")+"123"+Uri.encode("#"); //PIN number validation private String regEx = "^[0-9]{12}$"; //variables to handle the PIN and to convert them to a usable format by the messages and ussd private String converted; private String convertedRemovedSpace; private String convertedFirstTwelveDigit; //variables for image manipulation private ImageView mimageView; private Bitmap selectedBitmapFrame ; private Bitmap croppedImageFinal; private Mat frameToConvert; //variables to handle toast string String toastMesage = new String(); Initializing base loader callback private BaseLoaderCallback mLoaderCallback = new BaseLoaderCallback(this) { @Override public void onManagerConnected(int status) { switch (status) { case LoaderCallbackInterface.SUCCESS: { Log.i(TAG, "OpenCV loaded successfully"); mOpenCvCameraView.enableView(); } break; default: { super.onManagerConnected(status); } break; } } };
  • 68. 5 On Create method override public void onCreate(Bundle savedInstanceState) { Log.i(TAG, "called onCreate"); super.onCreate(savedInstanceState); getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); //set content to camera surface view setContentView(R.layout.tutorial1_surface_view); //button assigning to interface reload=(Button)findViewById(R.id.button1); pkg_activation=(Button)findViewById(R.id.button5); chk_balance=(Button)findViewById(R.id.button2); manual_pin=(Button)findViewById(R.id.button3); topup_history=(Button)findViewById(R.id.button4); //set image view to cameraview mimageView=(ImageView)findViewById(R.id.imageView1); mimageView.setVisibility(View.INVISIBLE); mOpenCvCameraView = (JavaCameraView) findViewById(R.id.tutorial1_activity_java_surface_view); mOpenCvCameraView.setVisibility(SurfaceView.VISIBLE); mOpenCvCameraView.setCvCameraViewListener(this); }
  • 69. 6 On camera frame sent all the methods are used in this section public Mat onCameraFrame( final CvCameraViewFrame inputFrame) { //check balance function chk_balance.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { startActivity(new Intent("android.intent.action.CALL", Uri.parse("tel:" + ussdCodeCheckBalance))); } }); //manual pin enter function manual_pin.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this); builder.setTitle("Input PIN to Topup"); // Set up the input final EditText input = new EditText(MainActivity.this); // Specify the type of input expected; this, for example, sets the input as a password, and will mask the text input.setInputType(InputType.TYPE_CLASS_NUMBER ); builder.setView(input); // Set up the buttons builder.setPositiveButton("OK", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { m_Text = input.getText().toString(); if (m_Text.matches(regEx)) { startActivity(new Intent("android.intent.action.CALL", Uri.parse("tel:" + ussdCodeReload+m_Text+Uri.encode("#")))); } else {
  • 70. 7 { Toast toast = Toast.makeText(getApplicationContext(), " Number of inputs invalid.n Input valid 12 digit PIN",Toast.LENGTH_LONG); toast.show(); } } }); builder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.cancel(); } }); builder.show(); } }); // package activation function pkg_activation.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { AlertDialog.Builder builderSingle = new AlertDialog.Builder( MainActivity.this); builderSingle.setIcon(R.drawable.icon); builderSingle.setTitle("Select One Package:-"); final ArrayAdapter<String> arrayAdapter = new ArrayAdapter<String>( MainActivity.this, android.R.layout.select_dialog_singlechoice); arrayAdapter.add("29/= internet and sms package"); arrayAdapter.add("49/= internet and sms package"); arrayAdapter.add("99/= internet and sms package"); arrayAdapter.add("30 min internet package"); arrayAdapter.add("1 hour internet package"); arrayAdapter.add("2 hour internet package"); arrayAdapter.add("5 hour internet package"); builderSingle.setNegativeButton("cancel", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); builderSingle.setAdapter(arrayAdapter, new DialogInterface.OnClickListener() {
  • 71. 8 @Override public void onClick(DialogInterface dialog, int which) { String strName = arrayAdapter.getItem(which); AlertDialog.Builder builderInner = new AlertDialog.Builder( MainActivity.this); builderInner.setMessage(strName); builderInner.setTitle("Your Selected Item is"); builderInner.setPositiveButton("Ok", new DialogInterface.OnClickListener() { @Override public void onClick( DialogInterface dialog, int which) { dialog.dismiss(); } }); builderInner.show(); } }); builderSingle.show(); } } ); //the main top-up function reload.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { frameToConvert=inputFrame.gray(); try{ //image processing for accurate OCR Imgproc.medianBlur(frameToConvert, frameToConvert,3); Imgproc.threshold(frameToConvert, frameToConvert, 0, 200, Imgproc.THRESH_OTSU); Imgproc.adaptiveThreshold(frameToConvert, frameToConvert, 155, Imgproc.ADAPTIVE_THRESH_GAUSSIAN_C, Imgproc.THRESH_BINARY, 11, 2); //convert mat to bitmap Utils.matToBitmap(frameToConvert, selectedBitmapFrame);
  • 72. 9 //crop image croppedImageFinal = Bitmap.createBitmap(selectedBitmapFrame, 360, 310, selectedBitmapFrame.getWidth() - 700, selectedBitmapFrame.getHeight() - 600); //set image to imageiew for usercomparison mimageView.setImageBitmap(croppedImageFinal); mimageView.setVisibility(View.VISIBLE); } catch(CvException e){ Toast toast = Toast.makeText(getApplicationContext(), e.getMessage(),Toast.LENGTH_LONG); toast.show(); } try{ //call the OCR function with the converted and cropped bitmap image converted=OCR_Converter(croppedImageFinal); //String manipulation process convertedRemovedSpace=converted.replace(" ","").replace(" ", "").replace("n",""); convertedFirstTwelveDigit = convertedRemovedSpace.substring(0, Math.min(convertedRemovedSpace.length(), 12)); //alert box for th user to compare the converted number with the image new AlertDialog.Builder(MainActivity.this) .setTitle("ChecK if the PIN is correct ") .setMessage(convertedFirstTwelveDigit). setPositiveButton("Confirm Top-up",new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { //send text message to perform top-up sendTxt(convertedRemovedSpace, "123"); } }) .setNegativeButton("no",new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) {
  • 73. 10 //show toast about improving user readability Toast toast = Toast.makeText(getApplicationContext(), "make sure the image is focused or change lighting condition",Toast.LENGTH_LONG); toast.show(); } }) .setIcon(android.R.drawable.ic_dialog_alert) .show(); } catch(CvException e1){ //error handling Toast toast = Toast.makeText(getApplicationContext(), e1.getMessage(),Toast.LENGTH_LONG); toast.show(); } catch(IllegalArgumentException e1) { //error handling Toast toast = Toast.makeText(getApplicationContext(), e1.getMessage(),Toast.LENGTH_LONG); toast.show(); } } }); return inputFrame.rgba();
  • 74. 11 //OCR conversion method public String OCR_Converter(Bitmap selectedBitmapFrame2) { String converted=""; TessBaseAPI tessapi=new TessBaseAPI(); //show tesseract the language data tessapi.init(Environment.getExternalStorageDirectory().getPath()+"/tesseract/" , "eng"); //Tell tesseract only use numbers tessapi.setVariable(TessBaseAPI.VAR_CHAR_WHITELIST, "1234567890"); tessapi.setVariable(TessBaseAPI.VAR_CHAR_BLACKLIST, "!@#$%^&*()_+=- qwertyuiop[]}{POIU" + "YTREWQasdASDfghFGHjklJKLl;L:'"|~`xcvXCVbnmBNM,./<>?"); tessapi.setImage(selectedBitmapFrame2); converted=tessapi.getUTF8Text(); tessapi.end(); return converted; } The Text message sending function public boolean sendTxt(String message,String number){ try{ SmsManager.getDefault().sendTextMessage(number, null, message, null, null); } catch(Exception e){ Toast toast = Toast.makeText(getApplicationContext(), e.getMessage(),Toast.LENGTH_LONG); toast.show(); } return true; }
  • 75. 1 Appendix III Project Specification PROJECT SPECIFICATION - SEGM 2015 Student: Ismail M.I.M (IT13078010) Date: 26/01/2015 Supervisor: Dr.Pradeepa Samarsinghe Degree Course: BEng (Hons) in Software Engineering Title of Project: Numver (Android app to Capture Number Based Data e.g. Scratch Cards, Lottery Tickets, etc. And process them) Elaboration Almost all prepaid mobile users face the complexity of Topping- up/Recharging their credit balance using Scratch cards ,if automatic reload feature is out of reach .Most of themdo make mistake while keying in the number in the Scratch card .And some might even not know the process if toping it up. Adding people who are visually impaired face this difficulty the most. This becomes versewhen you have to top up multiple cards at the same time (if the desired denominator is not available you got to key in many smaller denominator cards to reach the it) Most of the people are not being update about special Packages (Talk Time, Data, and SMS) and promotion offered by the mobile Service Providers. Sri Lankan lottery Systemhas become one of the many growing income to the Sri Lankan economy .People who buy lottery tickets either had to visit the vendor or watch the television for the winning number. The purpose of this project is to create a Standalone Mobile Application. Which address the above issues.By combining latest mobile image processing technology. The product would automatically track Numbers on the material and automate the process for you. Project Aims Get a clear understanding of how image processing is used to extract accurate and reliable results for subject images.
  • 76. 2 Produce (design, develop and test) a fully working “Numver” application for at least two Mobile Service provider and also add support to at least 10 Lottery ticket with all added features. Project deliverable(s) The deliverable for this project will be fully functioning “Numver” mobile application for both Android OS and IOS at its best. This includes :  Scan and activate scratch card using the rear camera for almost all mobile operators in Sri Lanka automatically  Maintain statistical data of all calls, data and text messages and generate report. Includes cost calculation for talk time in a weekly or monthly basis  Predict best data plans, talk time packages and text message plans using customer’s usage behavior.  Enable or disable specific data, talk-time, and text message packages with ease.  Make subscribersaware of promotions, as most of these promotions are not known by customers .for example star points to credit conversion in dialog.  Should support dual Sims, dual standby devices.  Scan and retrieveLottery ticket Results (if published).  Maintain records of used Lottery tickets.
  • 77. 3 Action plan TASKS MILESTONE DATES Investigate and choose the best two Mobile services providers who sell the most amount of scratch cards from almost six provide. 21st of January 2015 Investigate and select the best and the most selling lottery tickets to be used in the application. 28th of January 2015 Investigate and Choose the best Image processing API to be used with the Mobile application. 4th of February 2015 Design or sketch the ways on how the image processing API handles the desired documents. 10th of February 2015 Identify different software applications and their capabilities for creating cross platform apps which supports both Android and IOS 17th of February 2015 Design the interface and other Software Engineering Related Things. 24th of February 2015 Find the best Image processing technique to suit the Need 2nd of March 2015 Start Implementing the Design in a programmatic way 23rd of March 2015 Add and Test the Scratch card module And produce the prototype 8th of April 2015 Add and Test the Lottery Ticket Module And produce the prototype 20th of April 2015
  • 78. 4 Add the Extra Features And produce the prototype 4th of May 2015 Begin the Testing Phase(alpha test) 18th of May 2015 Make any necessary changes to the Final product and retest. (Repeat the process again if necessary). 2th of June 2015 Identify suitable participants for testing the product. 28th of Jne2015 Begin the second testing phase by distributing the application to real users and get their feedbacks and suggestion(Beta Testing) 4th of July 2015 Analyse the feedback and record results 21st of July 2015 Critically evaluate all aspects of the project. 24th of July 2015 Identify and report which areas of the product could be improved. 26th of July 2015 Finalize the Project Report. 2nd of August 2015 Appendix IV Ethics Form Question Yes/No 1. Does the project involve human participants? This includes surveys, questionnaires, observing behaviour, testing etc. If YES, then please answer questions 2 to 5. If NO, please go to question 6. YES 2. Note Will any of the participants be vulnerable? ‘Vulnerable’ means those who may not fully understand the research, or the consequences of taking part. They include:  children (i.e. under 18)  people with learning disabilities  people with physical disabilities (visible or not)  people who may be limited by age or illness If YES, then please answer question 2a If NO, please go to question 3 YES 2a Will you ever be alone (i.e. not overseen) with any vulnerable participants during the course of the research? If YES, then please answer question 2b If NO, please go to question 2c. NO
  • 79. 5 2b Note If you will be alone (i.e. not overseen) with any vulnerable participants during the course of the research, do you need to apply for a Disclosure and Barring Service (DBS) check (previously known as a Criminal Records Bureau (CRB) check)? If you need a DBS check, you may be liable for the cost of the application. More details regarding DBS checks can be found at https://www.gov.uk/disclosure-barring- service-check/overview. 2c Note If you will NOT be alone (i.e. you will be overseen) with any vulnerable participants during the course of the research, does your overseer have a DBS Check? If your overseer does NOT have a DBS check, you may need to apply for a DBS check yourself. You may be liable for the cost of the DBS application. More details regarding DBS checks can be found at https://www.gov.uk/disclosure-barring-service- check/overview. --- 3. Note Will any participants be at risk of any physical or emotional harm by taking part in your project? Harm may be caused by:  distressing or intrusive interview questions  uncomfortable procedures involving the participant,  invasion of privacy,  topics relating to highly personal information,  topics relating to illegal activity, etc. NO 4. Will anyone be taking part without giving their informed consent? (e.g. research involving covert study, coercion of subjects, or where subjects have not fully understood the research etc.) NO 5. Will any part of the project allow the identification of any individual who has not given their express consent to be identified? NO Note If you answered YES to any of questions 2 – 5, then you MUST address these ethical issues in your Project Specification, ensure that you take all reasonable steps to avoid/mitigate these issues during the execution of your project, and explain your actions in your Critical Reflection. Question Yes/No 6. Does the project involve the use of live animals? NO Note If you answered YES to question 6, then the project proposal must be submitted to the FREC for approval unless it falls into a category/ programme of research that has already received category approval. 7. Note Does the project involve the NHS? For NHS research, this includes:  any service evaluation work  work concerning NHS patients (tissues, organs, personal information or data)  NHS staff, volunteers, or carers  NHS premises or facilities NO If you answered YES to question 7, then your project proposal MUST be submitted Project Module Ethics Committee for
  • 80. 6 review, and may be referred to the Faculty Research Ethics Committee and/or to an NHS Research Ethics Committee. For further details on NHS National Research Ethics Service, please refer to http://www.nres.nhs.uk/applications/faq/before- applying/#FAQsBeforeApplyingStudent 8. Does the project require approval from any other external ethics committee? Note If you answered YES to question 8, then the project proposal must be submitted to the relevant external body. For further advice, please contact the Faculty Research Ethics Committee NO Organizations Question Yes/No 9. Will the project involve working with or within an organisation? 'Organisation' includes (but is not limited to):  business  charity  museum  government department  international agency  sports/social club  volunteer organisation NO 10. Note If you answered YES to question 9, do you have granted access (permission) to conduct the project? If YES, please show evidence to your supervisor and include this evidence in the Appendix of your Final Report. -- 11. If you answered NO to question 10, is it because: A. you have not yet asked B. you have asked and not yet received and answer C. you have asked and been refused access. A / B / C -- Note You will only be able to start this aspect of the project when you have been granted access/permission. 12. Note Will covert research be part of the project? ‘Covert research’ refers to research that is conducted without the knowledge of participants. If you answered YES to question 12, then your project proposal MUST be submitted Project Module Ethics Committee for review, and may be referred to the Faculty Research Ethics Committee NO
  • 81. 7 Question Yes/No Question Yes/No 13 Note Will the project involve using (e.g. citing / quoting / copying) copyrighted materials? Copyrighted materials includes (but is not limited to):  books / e-books  journals  websites  newspaper/magazine articles  films / broadcasts  photographs, artworks, images, diagrams  designs, products  computer programmes, code, databases  networks  processes If YES, please go to question 14 If NO, please read the declaration at the end of the checklist YES 14. Note Are the copyrighted materials you intend to use (citing / quoting / copying) in the public domain? ‘In the public domain’ does not mean the same thing as ‘publicly accessible’.  Information which is 'in the public domain' is no longer protected by copyright (i.e. copyright has either expired or been waived) and can be used without permission.  Information which is 'publicly accessible' (e.g. TV broadcasts, websites, artworks, newspapers) is available for anyone to consult/view. It is still protected by copyright even if there is no copyright notice. In UK law, copyright protection is automatic and does not require a copyright statement, although it is always good practice to provide one. It is necessary to check the terms and conditions of use to find out exactly how the material may be reused etc. If YES, please read the declaration at the end of the checklist. If NO, please go to question 15. YES 15. Note Will the project involve copying/reproducing copyrighted materials? 'Copying/reproducing' includes making physical copies (i.e. photocopies) and electronic copies (i.e. cutting-and-pasting, scanning, saving as separate files). It does not include citations and quotes with appropriate references. If YES, please go to question 15a. If NO, please go to question 16. -- 15a Note Will you be copying more than 5% (or one chapter) of an individual source? You are allowed to copy/reproduce up to 5% of a source (or one chapter) for your own personal research usage without explicit permission. Please see "Copyright - guidance for SHU Staff and Students" for further information. --
  • 82. 8 Question Yes/No 16. Note Do you have permission to use the copyrighted materials under the "Exam Defence"? If you are copying less than 5% (or one chapter) or citing/quoting the copyrighted material, you have permission to use the copyrighted material under the "Exam Defence". Please see "Copyright - guidance for SHU Staff and Students" for further information. If YES, please read the declaration at the end of the checklist. If NO, please go to question 17. -- Question Yes/No 17. Do you have explicit permission to use the copyrighted materials? If YES, please show any explicit evidence to your supervisor and include in the Appendix of your Final Report. Please read the declaration at the end of the checklist. If NO, please go to question 18. -- 18. If you do not have explicit permission, is it because: A. you have not yet asked permission B. you have asked and not yet received and answer C. you have asked and been refused access. A / B / C -- Note You will not be allowed to use the copyrighted material until you have been granted permission to use it. Adherence to SHU policy & procedures Declaration I can confirm that:  I have read the Sheffield Hallam University Research Ethics Policy (available at https://staff.shu.ac.uk/enterprise/research/Documents/Research%20Ethics %20Policy.pdf  I agree to abide by its principles. Signature ……………… Ismail M.I.M (IT13078010)