Automated Train Ticket System
(MobiTiki)
By
Athukorala A.U.B.
Dissanayake C.P.
Kumara M.G.C.P.
Priyadarshana G.V.J.
This report is submitted in partial
fulfillment of the requirements for the
award of the degree of
Bachelor of Science of Engineering
At
University of Moratuwa,
Sri Lanka.
2008
Abstract
MobiTiki
By
Athukorala A.U.B.
Dissanayake C.P.
Kumara M.G.C.P.
Priyadarshana G.V.J.
Supervised by
Dr. Sanath Jayasena
MobiTiki is an automated train ticketing system designed to reduce the long ticket queues which occur in peak hours. The aim of this project to come up with a low cost and efficient model of a system which can be used to reduce the congestion at ticketing queues. At present the entire process of issuing tickets is done manually. This result is long queues which can be observed just after office hours. MobiTiki uses the train commuter’s cellular phones to store the authentication data. The users will then authenticate themselves at the train station via an automated system. As the tickets are issued using a prepaid system we expect the process to be much faster than the current manual system.
This report gives a detailed description about the project including literature survey, research, design and development stages and final outcome of the project. It also suggests further improvements that can be carried out for achieving a better system.
Acknowledgement
First of all, we would like to thank our project supervisor Dr. Sanath Jayasena and the project coordinator Mr. Shantha Fernando. Also our gratitude goes to Mr.Indika Perera and Mr.Praveenan for providing us with proper guidance, encouragement and knowledge at needed situations. They were always behind this effort showing us the correct path when we were deviating from our targets.
In addition to that we would like to extend our gratitude to Mr. M.G. Indrasena, Station Master of Panadura Railway Station and Mrs. Lalitha Wickramarachchi, Chief Clerk of Sri Lanka Railway Department who helped us to obtain the domain knowledge of how the Railway system works is many instances.
We sincerely thank all the other academic staff members at the Department of Computer Science and Engineering. They provided us required resources and advices throughout the whole academic year so that we could reach the completion of our project successfully. The support given by the non academic staff members is also appreciated highly. We would also like to thank all our batch mates very warmly. They were always willing to listen to our problems and to suggest very practical solutions. They also made the life we spent at the lab very interesting and enjoyable.
At last but not least, we would like to thank our parents who have always been behind encouraging us in doing this project successfully.
Table of Contents
Introduction ... 10 Project Objectives ... 12 Background and Literature Review ... 13 2.1 What’s Semacode ... 13 2.2 Advantages of using semacode ... 14 2.3 Why we choose to use the Semacode... 15 2.4 Where we can use the Semacode ... 16 2.4.1 Industries where Semacode is widely used ... 16 2.4.2 How the Semacode came to the Mobile ... 18 2.5 Existing Systems which are similar ... 20 2.6 Why world uses Semacode... 22 2.7 Image Processing ... 23 2.7.1 Threshold ... 23 2.7.2 Edge detection ... 29 2.7.2.1 Step Edge detection by differentiation ... 29 2.7.2.2 Canny edge detection ... 30 2.7.2.3 Laplacian edge detection ... 31 2.7.2.4 Robert edge detection ... 33 2.7.2.5 Prewitt edge detection ... 33 2.7.3 Projective Transformation ... 35 2.7.3.1 Image Wrapping ... 35 2.7.3.2 Two‐Dimensional Mappings ... 362.7.4 Research on IEC/ISO 16022 speciation ... 39 2.7.4.1 The standard in ECC ... 39 2.7.4.2 Data Encodation Schema ... 40 2.7.4.3 Error detection and correction... 41 2.7.4.4 Error correction capacity ... 41 2.7.4.5 Module placement in matrix ... 43 2.8 Image capturing devices (Barcode readers) ... 47 2.8.1 Types of barcode scanner ... 47 2.8.2 Types of technology ... 48 2.8.3 Example of 2‐D barcode reader ... 50 Design ... 51 3.1 Overall System Architecture ... 51 3.2 2D Barcode Based Authentication System ... 52 3.2.1 Semacode Encoder ... 52 3.2.2 Semacode Capturing ... 54 3.2.3 Image Enhancement ... 55 3.2.4 Error Correction ... 57 3.2.5 Semacode Decoder ... 59 3.3 Prepaid Service Portal ... 61 3.3.1 Semacode Encoder ... 62 3.3.2 Cached Data Manager ... 63 3.3.3 Session Manager ... 63 3.3.4 Data Manager ... 63 3.3.5 Localizer ... 63
3.3.6 Main and Localization Databases ... 64 3.4 Mobile Application ... 66 3.4.1 Common Services ... 67 3.4.2 User Specific Services ... 67 3.4.3 Data Storage Layer ... 67 3.4.4 Security Features used ... 67 3.4.5 Use of J2ME Polish ... 67 3.4.6 External String Based Web service ... 68 3.4.4 Message and Connection Handling Layer ... 68 3.5 Database ... 71 Test Results ... 72 Discussion ... 75 Conclusion ... 77 Future Work ... 78 References ... 80 Appendix A ... 84 Appendix B ... 87
List of Tables
Table 2. 1: Space usage of semacode ... 14 Table 2. 2 Comparison of the Space usage of semacode ... 14 Table 2. 3: Schemas ... 40 Table 2. 4: Data matrix size ... 43 Table 2. 5: Boundary placement matrix ... 44 Table 4.1: Test Results ………70List of Figures
Figure 2. 1 : Clothing & footwear Industry ... 16 Figure 2. 2: Book & Magazine Industry ... 17 Figure 2. 3: Land Industry ... 18 Figure 2. 4: Chiltern Railways ... 20 Figure 2. 5: The Japanese airline ... 21 Figure 2. 6: Samples of Semacode ... 22 Figure 2. 7: Quick threshold ... 25 Figure 2. 8 : Captured Image ... 26 Figure 2. 9: After apply Quick threshold ... 26 Figure 2. 10: After applying Global Mean threshold ... 27 Figure 2. 11: Laplacian edge detection ... 31 Figure 2. 12: ECC standard... 39 Figure 2. 13: 8x8 Data matrix ... 46 Figure 3. 1: Overall System Architecture ... 51 Figure 3. 2 : Semacode Encoder Module ... 52 Figure 3. 3: Class diagram of Semacode Encoder Module ... 53 Figure 3. 4: Image Capturing Module ... 54 Figure 3. 5: Image Enhancement Module ... 55 Figure 3. 6: Class diagram of Image Enhancement Module ... 56 Figure 3. 7: Error Correction Module ... 57 Figure 3. 8: Class diagram of Error Correction Module ... 58Figure 3. 9: Semacode Decode module ... 59 Figure 3. 10: Class diagram of Semacode Decode module ... 60 Figure 3. 11: Prepaid Service Portal design diagram ... 61 Figure 3. 12: Semacode Encode Module ... 62 Figure 3. 13: Class diagram of Web portal ... 65 Figure 3. 14: J2ME module ... 66 Figure 3. 15: Class diagram of J2ME module ... 70 Figure 3. 16: Relation Schema of the database ... 71 Figure 4.1: Image capture ... 73 Figure 4. 2: Edge detection ………… ... 73 Figure 4.3 : Region detection ………72 Figure 4.4: Corner Dection ... 74 Figure 4.5: Decoded Image ... 74
Chapter
1
Introduction
A long queue at the ticket counter is something regularly experienced by the train commuters using the Sri Lankan railways. The gravity of this problem is clearly visible in the morning and in the evening, just after office hours have ended. Other than the obvious wastage of time in the queues, the stress and frustration created by this problem, on people daily, is another major concern.
In the developed countries of Europe and in the USA there are automated ticketing systems which use smart cards. Through the use of these cards they have successfully addressed the above questions. In fact most of these smart card systems have almost eliminated the queues. In some countries this transaction can be done via the user’s credit card.
One reason for long queues at ticket counters is, in most stations there are not enough ticket counters to handle the peak time crowd. But it is not practicable to increase the number of ticket counters just to serve at peak time. Another reason is the time taken for one passenger to buy a ticket. The person at the counter has to issue the ticket and deal with the “change”. This increases the time taken to complete the transaction.
The solution to this problem is to automate the system. But we have to consider the Sri Lankan context when deciding how to automate the system. The credit card system is obviously not suited since a significant number of train commuters do not use credit cards. If we consider
the smart card systems the initial cost of these systems are huge. And the cost of maintaining such high tech system will most probably outweigh the benefits provided by it.
The system we have suggested is an automated pre‐paid system. The automated part addresses the problem of long queues. The pre‐paid part aims to solve the problem of dealing with actual money. By this way, the time taken in exchanging money and receiving the correct balance will be completely eliminated. Our alternative to credit cards and smart cards is to use a special two dimensional barcode. This barcode will be saved as an image in the users’ cell phone. A smart device equipped with which will issue the ticket after identifying the user a web cam will be installed at the station.
Project Objectives
The main goal of this project is to develop a prototype of an automated train ticketing system which is cost effective and suits the Sri Lankan context. The system will effectively reduce the time taken to obtain a ticket at a ticketing counter. It will aim to reduce long queues at ticket counters thus reducing time wastage. The scope of our objective is as follows
¾ Identification and evaluation of existing automated ticket issuing systems.
¾ The study of these systems to understand their functionality and features so that we may incorporate some of the features to our system.
¾ Identification of the usages of the 2D barcode “semacode”.
¾ Identification of the processing power and decoding time of semacode compared to other 2D barcodes and determining its efficiency.
¾ Determining the appropriateness of the semacode as an identification mechanism. ¾ Development of a semacode based authentication system.
¾ Identification of the usefulness of a real time web based system on providing information useful to railway commuters.
¾ Development of such a web based system.
¾ Make all the railway schedules easily accessible to the general public.
¾ Development of a prepaid ticketing system embedding it in the web based system ¾ Determining the usage of cellular phones as a means of authentication opposed to
smart cards and other card systems, taking in to consideration the Sri Lankan context. ¾ Development of a J2ME application to be used as an authentication mechanism, as well as provide a stripped down version of the services provided by the web base system. ¾ Identification of the options available, when placing a smart device at the train stations, to issue tickets. ¾ Development of a system to emulate the functionality of a smart device.
¾ In the end, reduce long ticket queues, save time and ultimately make the journey pleasant for the commuters.
Chapter
2
Background and Literature Review
2.1 What’s Semacode
Semacode [1] is a system for universal computing, combining camera phones, bar codes and URLs, in order to bring the real world into the virtual world. The bar code is a 2D‐image that stores the data in a hidden manner. As Semacode only needs a small processing capacity the concept is rapidly growing in mobile applications[2]. The location‐based data, commercial data & many embedded systems can use the Semacode. The Semacode technology requires the direct interaction (using mobile devices) with the user & that helps to make quick connections with different types of users. Sri Lanka also intends to use the Semacode applications in near future. But the world has already been keen to use the semacode applications with confidence.
The world moves with the mobile devices & the mobile devices deal with concepts like “Semacode” because it enhances the processing power & rapidness. Semacode is a method to store data in a 2‐D data format. The data can be represented in a “Data Matrix” [3] format so the processing of the data is very much efficient than the other storing techniques[4].
2.2 Advantages of using semacode
¾ The Space usage of semacode compared with other data store technique[5]
QR Code Data Matrix (Semacode) Space Savings
42 x 42 24 x 24 67% 25 x 25 18 x 18 48% 29 x 29 20 x 20 52% 29 x 29 26 x 26 20% Table 2. 1: Space usage of semacode QR Code Data Matrix (Semacode) Space Savings http://semacode.org/about/technical 29 x 29 22 x 22 42% http://en.wikipedia.org/wiki/Semapedia 29 x 29 24 x 24 32% http://google.com 25 x 25 18 x 18 61% Table 2. 2 Comparison of the Space usage of semacode
¾ The number of different combinations that can make
A single data word has lesser number of different combinations. But when using a 2‐D barcode, the amount of data that can be stored is very large (it has a two dimensional data storage capacity). With the increase of the market competitors & the different brands the higher the number connects with higher data capacity.
¾ Accepted as a world standard
In the current world it is accepted as a standard. Different mobile phone vendors use their own techniques to process the data. But when the mobile phones are used for a common purpose all should follow a common technique. Otherwise the users will be uncomfortable when using those applications. So the unofficial standard usage of semacode will be much more effective in the near future.
2.3 Why we choose to use the Semacode
As we observed in our literary survey the best two‐dimensional barcode format varies with different formats. With the data matrix type storage we considered major factors as to how much data that can store, how the data keep their uniqueness, how to make a large amount of data variations.[6] (In Sri Lanka, major transport medium is locomotive transportation, so the millions of passengers will use this mechanism in Sri Lanka).
2.4 Where we can use the Semacode
This is a very important topic to talk in a literary survey. Semacode can be used in the offline world, to link with the online and mobile worlds. There are thousands of possibilities. For example, business cards can have a semacode on the back. The semacode is unique to that person and stores his/her contact and company information and other Meta data. A user could use a mobile phone to scan for movie information on a particular movie, playing at a particular theatre on a specified time & date. Mobile ticketing is a buzzword in Sri Lanka that can co‐op with semacode. The potential that relates with movies & the mobile devices is like “BAT & BALL”. The world already has been moved towards the semacode usage, in many commercial arrears, as well as in personal life.
2.4.1 Industries where Semacode is widely used
¾ Clothing & footwear IndustryFigure 2. 1 : Clothing & footwear Industry
In this case, the customer uses her mobile phone to capture the semacode shown in the cut‐out (advertising board). When she visits the shop (clothes) next time she can use her mobile captured image to get the description of the dress. She even makes sure at what places, that particular dress is available. After that she/he can obtain the price, brand name & much more. This is a really famous technique that is used in European countries. The efficiency & the attraction of the customers are on a much higher level [7].
¾ Book & Magazine Industry
Figure 2. 2: Book & Magazine Industry
Here the example demonstrates how the Semacode is used to identify a particular magazine. The author, publications & price can be viewed instantly after capturing the 2‐D barcode. This is the impact of new technologies. The number of different combination that can be supplied from a small data matrix will be higher.
¾
Land IndustryFigure 2. 3: Land Industry This is another emerging commercial approach in European countries. The 2‐D barcode stores the data of land, owner & the sales person & price details. This can also be used in renting houses, leasing houses & sale of houses. This is another efficient method & the user can get the data within a few seconds.
These are the few examples of usage of semacode in mobile devices. These three different scenarios imply that the wide variations of the fields that can use simple data matrix.
2.4.2 How the Semacode came to the Mobile
Ericsson Mobile Application technology enables barcode scanning with camera‐ equipped mobile phones. Codes can be printed in newspapers and magazines, on posters or on the product itself. It is an independent code, and needs no additional scanner hardware to turn camera‐enabled devices into universal code readers. It is easy to integrate into current and future camera‐enabled mobile phones. The system allows camera phones to read Data Matrix and a variety of other two‐dimensional printed codes, as well as traditional one‐dimensional
barcodes.
It is not just a one‐way system. In addition to scanning barcodes, the camera phone can display codes to be read by a scanner. Possible uses include e‐ticking applications and electronic
vouchers. Also it has introduced SMS barcodes that can be used in point‐of‐sale transactions. The M‐Scan device communicates with the Server via GPRS, and then issues a physical ticket from an internal thermal printer and the mobile phone user presents it as a ticket, or as a promotional offer. Semacode is a free mobile barcode‐scanning system created by Simon Woodside. The system encodes standard URLs as two‐dimensional Data Matrix codes. An application on the user's phone converts the Data Matrix code back into a URL and passes the information to the phone's browser.
2.5 Existing Systems which are similar
¾ Chiltern Railways
Chiltern Railways [8] was the first to supply rail passengers with Railway Tickets delivered to their mobile phones. Also Cubic Transportation Systems, they provided the first rail gate solution able to read mobile phone tickets.
Chiltern Railways announced a world first in mobile ticketing that means passengers can buy a rail ticket direct from their mobile and travel. Fifty passengers were selected to take part in this pioneering trial which will allow them to simply, securely and quickly purchase and display train tickets on their mobile phone. Figure 2. 4: Chiltern Railways Rail travelers can simply purchase tickets from their mobile phone and then board the train. Even first time users can purchase without pre‐registration ‐ securely and simply. Mobile ticket purchasing has several advantages over conventional purchase.
¾ The Japanese airline
Figure 2. 5: The Japanese airline
The Japanese airline [9] JAL relies on two‐dimensional barcodes for the sale of flight tickets. These processes can be technically realized because of the support of the Japanese telephone company NTT.
2.6 Why world uses Semacode
Figure 2. 6: Samples of Semacode
Figure 2.6 demonstrates some screened captures of a Semacode in a mobile device. When the user uses a mobile device to capture an image, definitely it would have inclined images. When the decoding proceeds, the rotation of the image is compulsory. With a complex data set it would be a very difficult task. But with a familiar 2‐D data matrix it wouldn’t be very tough like other task. This is a great advantage over all other techniques. As mentioned earlier the efficiency & the higher different combinations prefer Semacode other than a different data storing methods.
2.7 Image Processing
2.7.1 Threshold
Threshold [10] is the simplest method of image segmentation. Individual pixels in a grayscale image are marked as “object” pixels if their value is greater than some threshold value (assuming an object to be brighter than the background) and as “background” pixels otherwise. Typically, an object pixel is given a value of “1” while a background pixel is given a value of “0.”
The key parameter in thresholding is obviously the choice of the threshold. Several different methods for choosing a threshold exist. The simplest method would be to choose the mean or median value, the rationale being that if the object pixels are brighter than the background, they should also be brighter than the average. In a noiseless image with uniform background and object values, the mean or median will work beautifully as the thresholds, however generally speaking; this will not be the case. A more sophisticated approach might be to create a histogram of the image pixel intensities and use the valley point as the threshold. The histogram approach assumes that there is some average value for the background and object pixels, but that the actual pixel values have some variation around these average values. However, computationally this is not as simple as we’d like, and many image histograms do not have clearly defined valley points. Ideally we’re looking for a method for choosing the threshold, which is simple, does not require too much prior knowledge of the image, and works well for noisy images. Such a good approach is an iterative method, as follows: 1. An initial threshold (T) is chosen; this can be done randomly or according to any other method desired. 2. The image is segmented into object and background pixels as described above, creating two sets: 1. G1 = {f(m,n):f(m,n) > T} (object pixels) 2. G2 = {f(m,n):f(m,n) T} (background pixels) 3. The average of each set is computed. f(m,n) is the value of the pixel located in the mth column & nth row)
1. m1 = average value of G1 2. m2 = average value of G2
4. A new threshold is created that is the average of m1 and m2
T’ = (m1 + m2)/2
5. Go back to step two, now using the new threshold computed in step four, keep repeating until the new threshold matches the one before it (i.e. until convergence has been reached).
This iterative algorithm is a special one‐dimensional case of the k‐means clustering algorithm, which has been proven to converge at a local minimum—meaning that a different initial threshold may result in a different final result.
There are many types of thresholdings that can be used in image enhancement. Simple thresholding, Quick thresholding, local Mean Thresholding, global Mean Thresholding, Global Min‐Max Average Thresholding are a few examples. But we define our own threshold value to a particular image enhancement process depending on the image that we captured.
¾ Quick Threshold
In order to explain how this algorithm works, we initially treat the image as a linear array of pixels constructed by concatenating the entire image rows together. This yields the data structure shown below which is processed from left to right.
Figure 2. 7: Quick threshold
Let fs(n) be the sum of the last s pixels encountered at point n in the pixel array
∑
− =−
=
1 0)
(
s ii
n
n
s
P
f
⎪ ⎪ ⎩ ⎪⎪ ⎨ ⎧ ⎟ ⎠ ⎞ ⎜ ⎝ ⎛ − ⎟ ⎟ ⎠ ⎞ ⎜ ⎜ ⎝ ⎛ < = otherwise 255 100 100 ) ( if 0)
(
t n s ns
f
P
n
T
fs(n)/s
is the average pixel value of the last s pixels encountered. This quantity is known as the moving average since it is recalculated for every position in the pixel array. This moving average is then used in a thresholding function T(n) to produce the binarized image.p
n=
the grayscale value of a pixel located at position n.Captured Image Figure 2. 8 : Captured Image After applying Quick threshold Figure 2. 9: After apply Quick threshold
¾ Local Mean Threshold
Here the concept is to identify a particular image or special data in an image using a local value. The local threshold value will be applied to that particular area & the data will be retrieved. This method is useful when we want to identify a portion of an image that only includes an object. So this value is effected to the specific area. This technique is also very useful in image enhancement. ¾ Global Mean Threshold Captured Image
After applying Global Mean threshold
Figure 2. 10: After applying Global Mean threshold
Here we apply a common value to the whole image. This is a direct approach, hence this is very fast. But when we think about the accuracy of the data this is the worst. Because any image can have error data, electrical noise & the environmental effects without uniformity. So applying a global value to an image will be very bad when we think about the accuracy. But if we only want to identify a big picture of an image this will be much faster, though not a very practical approach.
¾ Global Min‐Max Average Threshold
To overcome the bad effects of the unwanted data in an image we use Min‐Max Average threshold. The min‐Max value can be assigned according to the image & it gives an idea of the image at the start. The whole data will be analyzed before applying thresholding to the image. This is another common method that is used in image enhancement. Testing revealed that Global Min‐Max Average Threshold produced better quality binary images than global thresholding on the majority of test images. Even though global thresholding was more efficient, it usually failed to produce clear images. Since clarity is vital at this stage in the decoding process, the Global Min‐Max Average Threshold is used widely.
2.7.2 Edge detection
2.7.2.1 Step Edge detection by differentiation Captured image First DerivationApply threshold
Detect the Edge
The first step in segmenting images into regions is to determine where the edges are. We can use several different edge‐detection filters including true Sobel, true Prewitt, Canny Edge detection, Laplacian of Gaussian, and a mix of Sobel and Prewitt[10].
2.7.2.2 Canny edge detection
Basically there are four steps that need to be followed in the Canny Edge detection algorithm. [11]
¾ Smooth the image with a Gaussian filter. For the smoothing step, the Canny detector employs a Gaussian low pass filter. The standard deviation, determines the width of the filter and hence the amount of smoothing.
¾ Compute the gradient magnitude and orientation using finite difference approximations for the partial derivations. An edge in an image may point in a variety of directions, so the Canny algorithm uses four filters to detect horizontal, vertical and diagonal edges in the blurred image. The edge detection operator returns a value for the first derivative in the horizontal direction (Gy) and the vertical direction (Gx). ¾ Apply non‐maximum suppression to the gradient magnitude.
(
)
(
)
( )
edge an to normal direction the along in of neighbors the are and x ,y x,y S y , x′ ′ ′′ ′′ Δ( )
( )
( )
( )
(
(
)
)
⎪ ⎩ ⎪ ⎨ ⎧ ′′ ′′ Δ > Δ ′ ′ Δ > Δ Δ = otherwise 0 , , & , , if , , S x y S x y y x S y x S y x S y x M¾ Hysteresis threshold Thresholding with hysteresis requires two thresholds ‐ high and low, which is use double thresholding algorithm to detect and link edge. o If the gradient at a pixel is above ‘High’, declare it an ‘edge pixel’ o If the gradient at a pixel is below ‘Low’, declare it a ‘non‐edge‐pixel’ o If the gradient at a pixel is between ‘Low’ and ‘High’ then declare it an ‘edge pixel’ if and only if it is connected to an ‘edge pixel’ directly or via pixels between ‘Low’ and ‘ High’ 2.7.2.3 Laplacian edge detection
This technique uses the partial derivation of the image pixels to identify the image edges. This is another common & practical method that is used in image enhancement to find an edge. It deals with the second derivatives of the image & it can be used to identify the correct edges even in a small image. Figure 2. 11: Laplacian edge detection
Laplacian Operators Approximation of second derivative (horizontal)
y)
(x,
f'
y)
1,
(x
f'
y)
(x,
'
f'
X
f
2 2−
+
=
=
∂
∂
=[
f
(
x
+
1
,
y
)
−
f
(
x
,
y
)]
−
[
f
(
x
,
y
)
−
f
(
x
−
1
,
y
)]
=f
(
x
+
1
,
y
)
−
2
f
(
x
,
y
)
+
f
(
x
−
1
,
y
)
Convolution with[
1 −2 1]
Approximation of second derivative (vertical) Convolution with ⎥ ⎥ ⎥ ⎦ ⎤ ⎢ ⎢ ⎢ ⎣ ⎡ − 1 2 1 Apply Laplacian operator as follows ⎟ ⎟ ⎟ ⎠ ⎞ ⎜ ⎜ ⎜ ⎝ ⎛∂
∂
+
∂
∂
=
∇
2 22 22Y
X
2.7.2.4 Robert edge detection
In computer vision, the Roberts' Cross operator is one of the earliest edge detection algorithms, which works by computing the sum of the squares of the differences between diagonally adjacent pixels. This can be accomplished by convolving the image with two 2x2 kernels: +1 0 0 ‐1 In other words, each pixel in the output image is calculated as follows: tmp1 = input_image(x,y) ‐ input_image(x+1,y+1); tmp2 = input_image(x+1,y) ‐ input_image(x,y+1); output_image(x,y) = absolute_value(tmp1) + absolute_value(tmp2)
Roberts' Cross is still in use, due to the speed of computation, but performance compared to the alternatives is poor, with noise sensitivity a significant problem. It produces finer lines than other edge detection methods.
2.7.2.5 Prewitt edge detection
Prewitt is a method of edge detection in computer graphics, which calculates the maximum response of a set of convolution kernels to find the local edge orientation for each pixel. Various kernels can be used for this operation. The whole set of 8 kernels is produced by taking one of the kernels and rotating its coefficients circularly. Each of the resulting kernels is sensitive to an edge orientation ranging from 0° to 315° in steps of 45°, where 0° corresponds to a vertical edge. 0 +1 ‐1 0
The maximum response for each pixel is the value of the corresponding pixel in the output magnitude image. The values for the output orientation image lie between 1 and 8, depending on which of the 8 kernels produced the maximum response.
This edge detection method is also called edge template matching, because a set of edge templates is matched to the image, each representing an edge in a certain orientation. The template that matches the local area of the pixel the best then determines the edge magnitude and orientation of a pixel.
The Prewitt edge detector is an appropriate way to estimate the magnitude and orientation of an edge. Although differential gradient edge detection needs a rather time‐ consuming calculation to estimate the orientation from the magnitudes in the x‐ and y‐ directions, the Prewitt edge detection obtains the orientation directly from the kernel with the maximum response. The set of kernels is limited to 8 possible orientations; however experience shows that most direct orientation estimates are not very much accurate.
On the other hand, the set of kernels needs 8 convolutions for each pixel, whereas the set of kernels in gradient method needs only 2, one‐kernel being sensitive to edges in the vertical direction and one to the horizontal direction. The result for the edge magnitude image is very similar with both methods, provided the same convolving kernel is used.
Mathematically, the operator uses two 3×3 kernels which are convolved with the original image to calculate approximations of the derivatives ‐ one for horizontal changes, and one for vertical. If we define A as the source image, and Gx and Gy are two images which at each point contain the horizontal and vertical derivative approximations, the latter are computed as:
2.7.3 Projective Transformation
2.7.3.1 Image Wrapping Image warping is the act of distorting a source image into a destination image according to a mapping between source space (u, v) and destination space (x, y). The mapping is usually specified by the functions x (u, v) and y (u, v).[12]Image warping is used in image processing primarily for the correction of geometric distortions introduced by imperfect imaging systems. Camera lenses sometimes introduce pincushion or barrel distortions, perspective views introduce a projective distortion, and other nonlinear optical components can create more complex distortions. In image processing, we do image warping typically to remove the distortions from an image, while in computer graphics we are usually introducing one.
For image processing applications, the mapping may be derived given a model of the geometric distortions of a system, but more typically the mapping is inferred from a set of corresponding points in the source and destination images.
2.7.3.2 Two‐Dimensional Mappings Our research focus on the 2‐D images mapped to planar surfaces. The simplest classes of 2‐D mappings are the bilinear and projective transformations. These mappings are well known in mathematics. A two‐dimensional mapping is a mapping (transformation) that distorts a 2‐D source space into a 2‐D destination space. It maps a source point (u, v) to a destination point (x, y), according to the functions x (u, v) and y (u, v). We will discuss two classes of mappings are bilinear and projective. ¾ Bilinear Mappings
Bilinear mappings are most commonly defined as a mapping of a square into a quadrilateral. In bellow figure, this mapping can be computed by linearly interpolating by fraction u along the top and bottom edges of the quadrilateral, and then linearly interpolating by fraction v between the two interpolated points to yield destination point (x, y).
¾ Projective Mappings
The projective mapping, also known as the perspective or homogeneous transformation, is a projection from one plane through a point onto another plane. Homogeneous transformations are used for perspective camera transformations. The general form of a projective mapping is a rational linear mapping:
A projective mapping has 8 degrees of freedom, which can be determined from the source and destination coordinates of the four corners of a quadrilateral. There have two cases in calculation. 1. ∑X = 0 and ∑Y = 0 This is implies that the XY polygon is a parallelogram, so the mapping is affine, and a = x1 ‐ x0 b = x2 – x1 c = x0 d = y1 – y0 e = y2 – y1 f = y0 g = 0 h = 0
2. ∑X ≠ 0 and ∑Y ≠ 0
2.7.4 Research on IEC/ISO 16022 specification
2.7.4.1 The standard in ECC
Each Data Matrix symbol[13] consists of data regions which contain nominally square modules, set out in a regular array. In larger ECC 200 symbols, data regions are separated by alignment patterns. The data region is surrounded by a finder pattern, and this shall be surrounded on all four sides by a quiet zone border. Below illustrates an ECC 140 and a representation of an ECC 200 symbol.
ECC 200 ECC 140 Figure 2. 12: ECC standard ECC 200 symbols have an even number of rows and an even number of columns. Some symbols are square with sizes from 10 x 10 to 144 x 144 not including quiet zones. But ECC 000 ‐ 140 symbols have an odd number of rows and an odd number of columns. Symbols are square with sizes from 9 x 9 to 49 x 49 (modules) not including quiet zones. These symbols can be recognized by the upper right corner module being dark.
2.7.4.2 Data Encodation Schema
The data may be encoded using any combination of several encodation schemata. ASCII Encodation is the basic scheme. All other encodation schemes are invoked from ASCII encodation and return to this scheme. The best scheme for a given set of data may not be the one with the fewest bits per data character. It is important to switch between Encodation Schemes and Code sets In such a way that the number of code words is minimized. (For further information see appendix) Table 2. 3: Schema
2.7.4.3 Error detection and correction
ECC 200 symbols employ Reed‐Solomon error correction. For ECC 200 symbols with less than 255 total codewords, the error correction codewords are calculated from data codewords with no interleaving. For ECC 200 symbols with more than 255 total codewords, the error correction codewords are calculated from data codewords with the interleaving procedure. Each ECC 200 symbol has a specific number of data and error correction codewords which are divided into a specific number of blocks.
The polynomial arithmetic for ECC 200 shall be calculated using bit‐wise modulo 2 arithmetic and byte‐wise modulo 100101101 (decimal 301) arithmetic. This is a Galois field of 2 with 100101101 representing the field's prime modulus polynomial: x8 + x5 + x3 + x2 + 1. Sixteen different generator polynomials are used for generating the appropriate error correction codewords.
2.7.4.4 Error correction capacity
The error correction codewords can correct two types of erroneous codewords, erasures (erroneous codewords at known locations) and errors (erroneous codewords at unknown locations). An erasure is not scanned or undetected decodable symbol character. An error is a missed decoded symbol character.
The number of erasures and errors that can be corrected is given by the following formula:
e + 2t =< d ‐ p
Where: e = number of erasures t = number of errors d = number of error correction codewords p = number of codewords reserved for error detection.¾ In the general case, p = 0. However, if most of the error correction capacity is used to correct erasures, then the possibility of an undetected error is increased. ¾ In the general case, p = 3 if the number of erasures is more than half the number of error correction codewords.
2.7.4.5 Module placement in matrix There are 24 square symbols available in ECC 200. The table below describes the Symbol size, mapping matrix size, number of Data codewords, error codewords and maximum data capacity. Table 2. 4: Data matrix size
Because the standard symbol character shape cannot always fit the data module boundaries of the symbol and at some corners, a small set of non‐standard symbol characters is required. There are six conditions: two boundary conditions which affect all symbol formats, and four different corner conditions which apply to certain symbol formats:
Table 2. 5: Boundary placement matrix Left and right symbol characters
Top and bottom symbol characters Corner condition 1 Corner condition 2
Corner condition 4 This is the 8x8 matrix after set all the boundary condition. Figure 2. 13: 8x8 Data matrix
2.8 Image capturing devices (Barcode readers)
Semacode is not a new barcode format. It appears to be a slight variation of the standard Data Matrix code. Our understanding is that there are some special ways which data has been encoded into the code structure to make the code proprietary. As such, Semacode is subject to the inherent limitations of Data Matrix, and it is not sure that there's any value added by the changes that have been made from the standard. Both QR and Data Matrix were originally developed for industrial purposes. When the codes were conceived, laser scanning was the primary code reading technology, image sensors were costly and CPUs were slow. No one was expecting that these codes would be decoded by battery operated, hand held mobile devices in uncontrolled conditions. Neither code is well adapted to the problems of mobile cameras. Neither is designed to take advantage of the current know‐how in machine vision.
2.8.1 Types of barcode scanner
Barcode Readers are usually offered from three lines of heritage: ¾ Handheld readers for semi‐automatic reading ¾ Fix‐mount readers for automatic reading ¾ Reader gates for automatic scanningThis leads to the segregation of in‐line reading, semi‐automatic reading, and automatic scanning.
2.8.2 Types of technology
The reader types can be differentiated as follows: ¾ Laser scanners
Laser scanners work the same way as pen type readers except that they use a laser beam as the light source and typically employ either a reciprocating mirror or a rotating prism to scan the laser beam back and forth across the bar code. With the pen type reader, a photodiode is used to measure the intensity of the light reflected back from the bar code. In laser scanners, the light emitted by the reader is tuned to a specific frequency and the photodiode is designed to detect only this modulated light of the same frequency.
¾ CCD Readers
CCD readers use an array of hundreds of tiny light sensors lined up in a row in the head of the reader. Each sensor can be thought of as a single photodiode that measures the intensity of the light immediately in front of it.
¾ Camera‐Based Readers
2D imaging scanners are the fourth and newest type of bar code reader currently available. They use a small video camera to capture an image of a bar code. The reader then uses sophisticated digital image processing techniques to decode the bar code. Video cameras use the same CCD technology as in a CCD bar code reader except that instead of having a single row of sensors, a video camera has hundreds of rows of sensors arranged in a two dimensional array, so that they can generate an image.
¾ Matrix‐CCD‐Camera system This scanner operates with a two‐dimensional matrix‐ccd‐camera system which enables it to read QR‐codes of LC‐displays regardless of resolution, colors, or reflection. This is the basis to turn mobile phones into information carriers for encoded signals. The range of applicability is wide.
E‐Ticketing, the electronic sale of tickets, is an important target area. Potential fields of application are plane and train tickets, tickets for the theatre, concerts, sports events or skiing permits.
2.8.3 Example of 2‐D barcode reader
¾ 4600r Retail 2D Special Focus Barcode Image Scanner Combine Streaming Presentation™ Mode and Advanced Illumination System for a cost‐ effective solution with retail applications. Fast reading barcode imager for linear and 2D barcodes such as ISBT 128, GS1 Databar, PDF417, Matrix.¾ Opticon CR2 ‐ 2D Barcode Reader
Dynamic Optimization Technology automatically decodes linear, 2D and postal barcodes like RSS, Postnet, I2of5, PDF417, Data Matrix, Composite and OCR.
Chapter
3
Design
3.1 Overall System Architecture
Figure 3. 1: Overall System ArchitectureData Access Layer
Main Database Localization Database
Ticketing Terminal
Semacode Decoder Transaction Handler
Image Capturer
Mobile Front End
Transaction Handler Semacode
Prepaid Service Portal
Semacode Encoder Transaction Handler User Code Generator
Service Layer
3.2 2D Barcode Based Authentication System
The main authentication into the system is done through a 2D Barcode identified as Semacode. If the user needs to enter into the system to buy a railway ticket he or she should show this barcode to the Image capturing device. If the barcode is a valid one the user will be authenticated in to the system in less than a second.
3.2.1 Semacode Encoder
Semacode encoder gets a string as an input and outputs a unique 2D image which is used as an authentication mechanism into the system. After getting the input word Lexical analyzer returns the tokens related to the characters provided. These tokens are used to generate code words according to the encoding schema selected. The schema is selected to minimize the number of Code words generated. Depending on the number of code words the size of the data matrix is selected and the relevant bit pattern is generated. Finally this bit pattern is used to generate a Bitmap image (Semacode). Figure 3. 2 : Semacode Encoder Module Semacode Semacode Encoder Middle Layer ECC200 Encoder Bit Pattern Generator Lexical Analyzer ECC200 Translation Table Encoding Schema ASCII Byte256 C40 EditFact Bit Pattern FactoryClass Diagram Figure 3. 3: Class diagram of Semacode Encoder Module
3.2.2 Semacode Capturing
This component is used to capture the Semacode image in a mobile phone. This part is integrated to the Terminal applications in the Railway stations for issuing tickets. We are using a Web Cam device to capture the image. The Avicap32.DLL is a System DLL which is used to connect to an Image Capturing Device. We are using the User32.DLL to communicate with Avicap32.DLL. The device continuously generates a video stream and once the user displays his mobile phone to the Web Cam a Video frame is copied from the Video stream. This image is provided as an input to the Image enhancer. Figure 3. 4: Image Capturing Module
Front Interface
Capture Device
3.2.3 Image Enhancement
When the capturing device sends an image, the Image enhancement process will be fired. First it takes the image & converts it into a bitmap. Then the bitmap will be passed through a thresholding process. After that it takes to detect the edges of the image. The edges can be varied with the thresholding values. When it finds edges[14], it passes through a region detection mechanism that helps to identify possible regions in that image. After finds all possible regions the last process is activated to find the edge points of the captured image. The output of the process is the points of the image that includes Semacode image[15][16]. Figure 3. 5: Image Enhancement Module Input Data Image Enhancement Region Finder Points Bitmap Data Point Detector Edge Detection Region Finder Edge Points
Figure 3. 6: Class diagram of Image Enhancement Module
3.2.4 Error Correction
We are using the Reed Solomon Error Correction in the Encoding Process as well as in the Decoding process. In the encoding process Error Code words are generated using the Data Code words. In the Decoding process The Reed Solomon Decoder gets both the Data Code Words & Error Code Words and identify whether there is an error using Syndrome Calculation. If an error exists in the Code Words, Reed Solomon Decoder will determine the correct code words that should be in place of the error code words. However the Reed Solomon Decoder can correct errors if the error percentage is less than 16% in the code words. Figure 3. 7: Error Correction Module
Encoder Error Correction Decoder
Semacode Decoder ERROR_CORRECTION ReedSoloman Encoder ReedSoloman Decoder Semacode Decoder
Figure 3. 8: Class diagram of Error Correction Module
3.2.5 Semacode Decoder
Semacode Decoder gets the 4 points provided by the Image Enhancer Module and the size (Number of Cells) of the Data Matrix is identified using the Bit Pattern Sampler and the Perspective Transform. After that the Bit pattern of the Data Matrix is identified using the ECC200 Translation Table. Then the Code words are generated and these are used to generate the decoded text using the Encoding Schema. Figure 3. 9: Semacode Decode module Semacode Semacode Decoder Middle Layer ECC200 Decoder Bit Pattern Sampler Perspective Transform ECC200 Translation Table Encoding Schema ASCII Byte256 C40 EditFact Bit Pattern Factory
Figure 3. 10: Class diagram of Semacode Decode module
3.3 Prepaid Service Portal
This is the starting point of the MobiTiki service. Users register for the service via the Web Portal. In addition to the registration users can perform various tasks such as Recharge the Account, Check Transaction History, Search Railway Schedule, Search Railway Ticket Charges, etc. Figure 3. 11: Prepaid Service Portal design diagram
Web Front End
Data Manager
Semacode
Encoder
Main Database Localization DatabaseCached Data Manager
Session Manager
Localizer
3.3.1 Semacode Encoder
Encoding component of the Semacode is integrated with in the Web Portal. Once a user registers for the service a new Semacode will be generated using the Encoder. The user will download this image to his Mobile Phone using the MobiTiki Mobile Application. This downloaded image will be used as the Authentication mechanism to the Service at railway stations. Figure 3. 12: Semacode Encode Module Semacode Semacode Encoder Middle Layer ECC200 Encoder Bit Pattern Generator Lexical Analyzer ECC200 Translation Table Encoding Schema ASCII Byte256 C40 EditFact Bit Pattern Factory
3.3.2 Cached Data Manager
Caching is used within the Web Portal to minimize Database access. Cached Data Manager is responsible for caching the frequently used data such as Schedule details, Rates details, News, Announcements, etc. Depending on the nature of volatility of the Data different cache periods will be used. For example Announcements will have a cache period of 10 Seconds since they are highly volatile.3.3.3 Session Manager
Session Manager is responsible for handling Authentication into the system.3.3.4 Data Manager
This is the proxy for the Web front end to communicate with the databases to perform transactions.3.3.5 Localizer
The portal facilitates both English and Sinhala Languages. The task of the Localizer is to dynamically change the controls of the web page according to the user preference. Label Control Class Fields languageDictionary m_bUseDictionary m_sKey Properties Key UseDictionary Methods Label Render Translator Page Class Fields dbCon m_sLanguage selectCommand Properties Language Methods GetLabel (+ 1 ov… GetLabels InitPage LoadLabels Translator3.3.6 Main and Localization Databases
There are 2 Databases within the system. Main database stores the transaction details of the MobiTiki service. Localization database stores the Sinhala and English words required for supporting Bi‐Language support. Constants Class Fields CACHE_ANNOUNCEMENTS CACHE_CHARGES CACHE_DAYS CACHE_FARE_TYPES CACHE_LIMITED_SCHEDULE CACHE_NEWS CACHE_RAILWAY_STATIONS CACHE_RATES CACHE_SEARCHED_SCHEDULES CACHE_SECONDARY_STOPPINGS CACHE_STOPPINGS SESSION_ACCOUNT_BALANCE SESSION_LAST_LOGGED_IN SESSION_USER_DEFAULT_ROU… SESSION_USER_DETAILS SESSION_USER_NAME RandomCodeGe… Class Fields Lower Number Symbol Upper Methods GenerateCode GetCharacter IsChecked RandomCodeGen…
Figure 3. 13: Class diagram of Web portal
UtilsDataSetManage Class Methods GetAnnouncements GetNews GetscheduleForTicker GetSecondaryStoppings GetTicketCharges SearchRates SearchScheduleByStationsAndTime SearchTimeScheduleByStations UtilsDataSetManage TransactionsDataSetManage Class Methods GetAccountBalance GetTransactionHistory RechargeAccount TransactionsDataSetManage CommonDataSetManage Class Methods CommonDataSetManage GetDays GetFareTypes GetRailwayStations UsersDataSetManage Class Methods AuthenticateUser ChangePassword CheckAvailability GetUserData GetUserDefaultRoute IsSemaCodeAvailable RegisterUser SetUserDefaultroute UpdateUserData UsersDataSetManage
3.4 Mobile Application
The mobile application provides a striped down version of the services provided by the web portal. The user can check time tables, reload the account, check account balance and check transaction summary. The mobile application also holds the Semacode. The user can invoke a serene displaying the Semacode which will be used to authenticate him/her at the station. Figure 3. 14: J2ME module
Login
User Specific Services
Common Services
Data Storage Layer
Message and Connection handling Layer
3.4.1 Common Services
Common services include the Checking of railway time tables and ticket charges.3.4.2 User Specific Services
User specific services include Account Reload, Account Balance Check, and Check Transaction History. User needs to log in to the system to access these services.3.4.3 Data Storage Layer
The data storage layer handles all the incoming and outgoing data. This part acts as a data cache. This is where the credentials of the user are saved. It also holds session ID s which are used to communicate with the server. The storage layer acts as agent between the user interface and the back end. It accepts the requests from the user interfaces and connects with the message connection and handling layer to retrieve data.3.4.4 Security Features used
The best way to secure the communication between the J2ME application and the web service was to use an HTTPS connection[17]. But there are a range of difficulties which are different for each phone type, when HTTPS is used[18]. The fact that most phones with GPRS capability do not have HTTPS capability made HTTPs an unsuitable option.Instead we relied upon an encryption library written in java called “Bouncycastle” [19]. The J2ME application uses an DES encryption algorithm with a key length of 8 characters. [20][21].