Anda di halaman 1dari 19

Bar Code Data

A barcode is a machine-readable representation of information (usually dark ink on a light background to create high and low reflectance which is converted to 1s and 0s). Originally, barcodes stored data in the widths and spacing of printed parallel lines, but today they also come in patterns of dots, concentric circles, and text codes hidden within images. Barcodes can be read by optical scanners called barcode readers or scanned from an image by special software. Barcodes are widely used to implement Auto ID Data Capture (AIDC) systems that improve the speed and accuracy of computer data entry.[Ref. 1] 1.2Uses of Barcodes Since their invention in the 20th century, barcodes have slowly become an essential part of modern civilization. Their use is widespread, and the technology behind barcodes is constantly improving. Some modern applications of barcodes include:

Practically every item purchased from a grocery store, department store, and mass merchandiser has a barcode on it. This greatly helps in keeping track of the large number of items in a store and also reduces instances of shoplifting (since shoplifters could no longer easily switch price tags from a lower-cost item to a higher-priced one). Since the adoption of barcodes, both consumers and retailers have benefited from the savings generated. Document Management tools often allow for bar coded sheets to facilitate the separation and indexing of documents that have been imaged in batch scanning applications. The tracking of item movement, including rental cars, airline luggage, nuclear waste, mail and parcels. Recently, researchers have placed tiny barcodes on individual bees to track the insects' mating habits. Many tickets now have barcodes that need to be validated before allowing the holder to enter sports arenas, cinemas, theatres, fairgrounds, transportation etc. Used on automobiles, can be located on front or back. [Ref 1]

1.3Symbology The mapping between messages and barcodes is called a symbology. The specification of a symbology includes the encoding of the single digits/characters of the message as well as the start and stop markers into bars and space, the size of the quiet zone required to be before and after the barcode as well as the computation of a checksum. Linear symbologies can be classified mainly by two properties:

Continuous vs. discrete: Characters in continuous symbologies usually abut, with one character ending with a space and the next beginning with a bar, or vice versa.

Characters in discrete symbologies begin and end with bars; the intercharacter space is ignored, as long as it is not wide enough to look like the code ends.

Two-width vs. many-width: Bars and spaces in two-width symbologies are wide or narrow; how wide a wide bar is exactly has no significance as long as the symbology requirements for wide bars are adhered to (usually two to three times more wide than a narrow bar). Bars and spaces in many-width symbologies are all multiples of a basic width called the module; most such codes use four widths of 1, 2, 3 and 4 modules.

Some symbologies use interleaving. The first character is encoded using black bars of varying width. The second character is then encoded, by varying the width of the white spaces between these bars. Thus characters are encoded in pairs over the same section of the barcode. [Ref. 1] The different bar code symbologies support different types and amounts of data therefore you normally choose a particular symbology based on the type and amount of data that you want to encode in your bar codes. [Ref. 1] Symbology UPC-A UPC-E EAN-8 EAN-13 Code 39 Code 93 Code 128 EANUCC 128 Data Capacity 12 numeric digits - 11 user specified and 1 check digit. 7 numeric digits - 6 user specified and 1 check digit. 8 numeric digits - 7 user specified and 1 check digit. 13 numeric digits - 12 user specified and 1 check digit. Variable length alphanumeric data - the practical upper limit is dependent on the scanner and is typically between 20 and 40 characters. Code 128 is more efficient at encoding data than Code 39 or Code 93. Code 128 is the best choice for most general bar code applications. Code 39 and Code 128 are both very widely used while Code 93 is rarely used. Variable length numeric data - the practical upper limit is dependent on the scanner and is typically between 20 and 50 characters. Data can consist of any type of data including binary or alphanumeric and be up to 3116 bytes in length. Data can consist of any type of data including binary or alphanumeric and be up to 3750 bytes in length. Maxicode can hold up to 93 alphanumeric characters or 138 numeric digits. Maxicode is used almost exclusively for United Parcel Service package identification.

I 2 of 5

Data Matrix

Aztec

Maxicode

PDF417

PDF417 is a little more complex and it is difficult to say exactly what its capacity is because it depends greatly on the type of data that you encode in a PDF417 symbol as well as the amount of error correction capacity that you choose to use in a PDF417 symbol. For general binary data with no error correction enabled, a single PDF417 symbol can hold up to 1108 bytes. If the data consists of all numeric digits, then a single PDF417 symbol can hold up to 2725 digits. If the data consists of alphanumeric data, you can encode a maximum of 1850 bytes. If you have a mix of alphanumeric and binary data, the capacity will be somewhere between 1108 and 1850 bytes and will depend on the content of the data. All of our bar code software products use an extremely efficient encoding algorithm that will squeeze the maximum number of bytes possible into a PDF417 symbol however it still must work within the limits of the symbology specification.

1.4Benefits of using barcodes In point-of-sale management, the use of barcodes can provide very detailed up-to-date information on key aspects of the business, enabling decisions to be made much more quickly and with more confidence. For example:

Fast-selling items can be identified quickly and automatically reordered to meet consumer demand, Slow-selling items can be identified, preventing a build-up of unwanted stock, The effects of repositioning a given product within a store can be monitored, allowing fast-moving more profitable items to occupy the best space, Historical data can be used to predict seasonal fluctuations very accurately. Items may be repriced on the shelf to reflect both sale prices and price increases.

Besides sales and inventory tracking, barcodes are very useful in shipping/receiving/tracking.[Ref. 1]

When a manufacturer packs a box with any given item, a Unique Indentifying Number (UID) can be assigned to the box. A relational database can be created to relate the UID to relevant information about the box; such as order number, items packed, qty packed, final destination, etc The information can be transmitted through a communication system such as Electronic Data Interchange (EDI) so the retailer has the information about a shipment before it arrives.

Tracking results when shipments are sent to a Distribution Center (DC) before being forwarded to the final destination. When the shipment gets to the final destination, the UID gets scanned, and the store knows where the order came from, what's inside the box, and how much to pay the manufacturer.

The reason bar codes are business friendly is that bar code scanners are relatively low cost and extremely accurate - only about 1/100,000 entries will be wrong.[Ref. 2] 1.5Types of barcode readers There are currently four different types of bar code readers available. Each uses a slightly different technology for reading and decoding a bar code. There are pen type readers (e.g. bar code wands), laser scanners, CCD readers and camera-based readers. Pen Type Readers and Laser Scanners: Pen type readers consist of a light source and a photo diode that are placed next to each other in the tip of a pen or wand. To read a bar code, you drag the tip of the pen across all the bars in a steady even motion. The photo diode measures the intensity of the light reflected back from the light source and generates a waveform that is used to measure the widths of the bars and spaces in the bar code. Dark bars in the bar code absorb light and white spaces reflect light so that the voltage waveform generated by the photo diode is an exact duplicate of the bar and space pattern in the bar code. This waveform is decoded by the scanner in a manner similar to the way Morse code dots and dashes are decoded. 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. Just the same as with the pen type reader, a photo diode is used to measure the intensity of the light reflected back from the bar code. In both pen readers and laser scanners, the light emitted by the reader is tuned to a specific frequency and the photo diode is designed to detect only this same frequency light.[Ref. 3] CCD Readers: CCD (Charge Coupled Device) 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 photo diode that measures the intensity of the light immediately in front of it. Each individual light sensor in the CCD reader is extremely small and because there are hundreds of sensors lined up in a row, a voltage pattern identical to the pattern in a bar code is generated in the reader by sequentially measuring the voltages across each sensor in the row. The important difference between a CCD reader and a pen or laser scanner is that the CCD reader is measuring emitted ambient light from the bar code whereas pen or laser scanners are measuring reflected light of a specific frequency originating from the scanner itself. [Ref. 3] Camera-Based Readers: The fourth and newest type of bar code reader currently available are camera-based readers that 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.[Ref. 3] 1.6INSIDE A BARCODE SCANNER Bar code is a popular method of numbering or identification of objects. Every bar code is composed of a combination of bars and spaces to denote particular alpha-numeric identification to an object. The use of bar code reduces the clerical error in data entry or modification, saves time for manual entry and increases efficiency in terms of tracking, locating a particular object. Every bar code follows a certain standard rule. These rules guide the representation of any human-readable characters (or numbers) into specific combination of bars and spaces. There are several such rules available (and details can be obtained from internet). Typically bar codes are read using hand held devices. One limitation of such devices is that an operator needs to be close to the object to scan the code. As opposed to it, image based bar-code reading can potentially read barcodes from any image taken by a camera. In principle, an image can be searched for the presence of the barcode and then obtained bar code can be read utilizing image processing technologies. [Ref.4] CHAPTER 2 : CHOOSING AN APPROPRIATE CODE FOR SIMULATION 2.1Code UPC - A For the purpose of sample testing, we will consider a barcode of the UPC-A format. The reason for this, is that the size of a UPC-A barcode is always the same - 95 bits. The UPC-A code consists of 12 digits, and each digit is represented by a series of black and white bars. The corresponding digits are deciphered as : UPC-A barcode digits are coded such that the left 6 digits and the right 6 digits are separated by a middle guard of 0-1-0-1-0, that is, space-bar-space-bar-space. The left hand side codes have 10 possible space-bar combinations, with odd parity. It is evident, that the left hand codes start with a space. The bit patterns and widths are as follows: [Ref.3] Left Hand Side Codes: 0: 0001101 3-2-1-1 1: 0011001 2-2-2-1 2: 0010011 2-1-2-2

3: 0111101 1-4-1-1 4: 0100011 1-1-3-2 5: 0110001 1-2-3-1 6: 0101111 1-1-1-4 7: 0111011 1-3-1-2 8: 0110111 1-2-1-3 9: 0001011 3-1-1-2 On the other hand, the right hand side bit patterns relating to each digit are essentially ones complements of the left hand side pattern. They have an even parity and start with a bar. The bit patterns are as follows: Right Hand Side Codes (Remember these are the ones complement!): 0: 1110010 1: 1100110 2: 1101100 3: 1000010 4: 1011100 5: 1001110 6: 1010000 7: 1000100 8: 1001000 9: 1110100 One thing to note is that at the start and end of each barcode, there is a particular bit pattern, 101, indicating to the deciphering program where the barcode is initialised and concluded. Barcodes, as stated above, due to the differing widths of the bars and spaces can essentially be composed of binary code, i.e. 1s or 0s. Thinking about the notion of barcode recognition within MATLAB is probably much simpler as we need to determine a way to convert the barcode image of bars and spaces into perhaps a graph, with the vertical axis ranging from 0 to 1, corresponding to the bars and spaces, etc. To convert the image to a graph as such would then allow us to manipulate MATLAB to read the graph and determine the numbers involved. [Ref.5]

The UPC-A barcode is the most common and well-known symbology in the United States. You can find it on virtually every consumer goods in your local supermarket, as well as books, magazines, and newspapers. There are a number of UPC variants, such as UPC-E, UPC 2-digit Supplement, UPC 5-digit supplement. UPC-A encodes 11 digits of numeric data along with a trailing check digit, for a total of 12 digits of barcode data. [Ref. 5] 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 2.2Structure of a UPC number An UPC-A number consists of four areas: (1) The number System; (2)The manufacturer code; (3) the product code; (4)The check digit. Normally the number system digit is printed to the left of the barcode, and the check digit to the right. The manufacturer and product codes are printed just below the barcode, separated by the guard bar. NS 0 1 2 3 4 5 6 7 8 9 Description Regular UPC code Reserved Weight Items Drug/Health Items In-store use on non-food items Coupons Reserved Regular UPC code Reserved Reserved

Number System. The number system is the first digit in the UPC number to identify the type of the product. For example, if the barcode starts with digit 5, this barcode is a coupon code. Manufacturer Code. The manufacturer code is assigned by UCC council to each manufacturer or company which distributed goods that uses UPC-A barcode. To apply for a

manufacturer code, visit http://www.uc-council.org/. Note that UCC has started to assign manufacturer code longer than 5 digits to conserve the numbering resource. Product Code. The product code is assigned by the manufacturer. The product code is a 5digit number so it can accommodate 99,999 possible product codes for each manufacturer. That is far enough for any manufacturer in the world! Check Digit. The check digit is used to verify that the barcode is generated or scanned correctly. The check digit is calculated based on the rest of the barcode digits. Read the following section to learn how to calculate the check digit. [Ref. 5] 2.3Reason for choosing the UPC-A code The main purpose of selection of this code is that the length of the barcode is always a standard 95 bits long. This length does not vary depending on its usage, or the number of products that it represents. Initially, Code 39 was chosen as a standard to run the simulation in, but the length of a code 39 Barcode varies greatly depending on the product for which it is made. Hence, using a standard 95 bit format makes it easier to implement the Image processing algorithms as the image cropping and barcode reading algorithms become easier to define. CHAPTER 3: MATLAB SIMULATION OF BARCODE SCANNER 3.1Simulating a Barcode Reader using MATLAB The aim of the program designed is :

To provide the user with an interface when he can input any scanned image containing a barcode To correctly scan the barcode segment from the scanned input image Decode the barcode segment Present the user with the decoded output

In order to ensure that the barcode segment is read as accurately as possible, we need to perform the following operations on the scanned image once it has been input by the user:

Image rotation (the barcode is rotated with respect to the camera) Noise (poor signal to noise ratio, bad lighting conditions, image taken through glass, and so on) Blurriness of the image (the camera is out of focus)

Now, Barcode Recognition involves a wide range of activities to ensure that the give image is properly processed and deciphered by the program. This project aims to correctly decode as many images as possible, though it may not be possible to accurately decipher each image. Hence, the order followed to process a scanned image will be : 1) Create a GUI for the user 2) Clean the image by debluring it or by removing noise (if required) 3) Angular rotation of the image in case it isn't properly aligned 4) Barcode Image recognition 5) Barcode Decoding 6) Display the output 3.2GUI.m The GUI.m file is required for creating an interface that the user will utilize to select the kind of pre-processing image that he wants, and then can process that desired image to be decoded to give the final output. This step is simply used for the purpose of image acquisition. % Start of GUI.m % clearing the screen and clearing memory before starting clear all; close all; output = 'empty'; % creating the GUI window barwindow = figure('Name', 'Barcode recognition'); %setting the position for image display input_image_axis = axes('position', [.05, .3, .9, .55]); % setting the example list examples_list = 'Perfect Image|blurred image|blurred image_2'; load_popup = uicontrol ('Style', 'popupmenu', 'string', examples_list, 'position', [30,55,100,25], 'callback', 'index_file'); % creating options for user interface input_title = uicontrol('Style', 'text', 'string', 'INPUT', 'Units', 'pixels', 'position', [180, 370, 200, 40], 'BackgroundColor', 'r', 'FontSize', 18);

exit_button = uicontrol ('Style', 'pushbutton', 'string', 'Exit', 'position', [450, 55, 80, 25], 'callback', 'close'); process_button = uicontrol ('Style', 'pushbutton', 'string', 'Process', 'position', [330, 55, 80, 25], 'callback', 'main'); deblur_checkboxx = uicontrol ('Style', 'checkbox', 'string', 'Perform Debluring', 'position', [170, 55, 120, 25], 'callback', 'deblur'); % End of GUI.m 3.3Index.m This file is only meant to load the entire list of images available to the user in a drop down menu in the GUI. The user can select the desired image, a preview of which is available on GUI itself % Start of Index.m index = get(load_popup,'Value'); if index == 1 name = 'PerfectI.jpg'; elseif index == 2 name = 'blur.jpg'; elseif index == 3 name = 'blurrandom.jpg'; end bar = imread(name); image(bar); % End of Index.m 3.4 Output.m Once the image file has been stored in the memory for processing, the user will choose the options provided in the GUI to process the file as he wants. But once the file has been processed, it also needs to be shown to the user. The output.m file provides an interface wherein the user is able to see the final cropped image that is obtained by the MATLAB processor as well as the decoded value of the barcode that the program was aimed to perform. % Start of Output.m function output_data(final_image, barcode_string, flag_1, flag_2, flag_3) ouput_window = figure('Name', 'Extracted Barcode');

exit_button = uicontrol ('Style', 'pushbutton', 'string', 'Close', 'position', [450, 55, 80, 25], 'callback', 'close'); output_title = uicontrol('Style', 'text', 'string', 'OUTPUT', 'Units', 'pixels', 'position', [180, 370, 200, 40], 'BackgroundColor', 'r', 'FontSize', 20); output_image_axis = axes('position', [.05, .5, .9, .3]); output_text = uicontrol('Style', 'text', 'string', barcode_string, 'position', [30, 100, 200, 30], 'BackgroundColor', 'w', 'FontSize', 14); read_error_check = uicontrol('Style', 'checkbox', 'string', 'Read Error', 'position', [280, 150, 140, 15], 'BackgroundColor', 'w', 'FontSize', 10, 'Value', flag_1); check_sum_error = uicontrol('Style', 'checkbox', 'string', 'Checksum Correct', 'position', [280, 120, 140, 15], 'BackgroundColor', 'w', 'FontSize', 10, 'Value', flag_2); Rotation_error = uicontrol('Style', 'checkbox', 'string', 'Image Reversed', 'position', [280, 90, 140, 15], 'BackgroundColor', 'w', 'FontSize', 10, 'Value', flag_3); imshow(final_image); % End of Output.m 3.5 Noise.m The wiener2 function is a 2 dimensional, adaptive filter. It determines the variance values of neighboring pixels to determine noise. We chose this filter as it is able to preserve the edges of our barcode. This file mainly is concerned with image cleaning. wiener2 estimates the local mean and variance around each pixel, where n is the N-by-M local neighbourhoods of each pixel in the image A. wiener2 then creates a pixelwise Wiener filter using these estimates, [Ref.7] % Start of Noise.m RGB = imread('blur.jpg'); I = rgb2gray(RGB); J = imnoise(I,'gaussian',0,0.025); imshow(J) K = wiener2(J,[5 5]); figure, imshow(K) % End of Noise.m 3.6 Deblur.m

This algorithm is used for deblurring an image. The image scanned may be blurred if moved while scanning, or even if the scanning device used may have imperfections. In this case, we use the program as shown below, which, in essence, will sample each pixel of the image after converting into a black and white image, for a certain sampling frequency, using image synthesis. Then, we try and find the threshold width of the image and then correspondingly calculate if the surrounding image is black or white by the process of image sampling. The description of the functions used in the program are given below : % Start of Deblur.m end%FUNCTION 'Deblur.m' function [bar_out] = deblur(bar) val = get(deblur_check,'value'); if (val == 1) %convert the image into gray scale image I = rgb2gray(bar); % Initialized the Gaussian filter that % represents a point-spread function, PSF. PSF = fspecial('gaussian',7,10); figure(1);imshow(I);title('Original Image'); % initialized the array 4 pixels less than the PSF UNDERPSF = ones(size(PSF)-4); [J1 P1] = deconvblind(I,UNDERPSF); figure(2);imshow(J1);title('Deblurring with Undersized PSF'); % initialized the array 4 pixels bigger than the PSF OVERPSF = padarray(UNDERPSF,[4 4],'replicate','both'); [J2 P2] = deconvblind(I,OVERPSF); figure(3);imshow(J2);title('Deblurring with Oversized PSF'); % initialized the INITPSF with the same size of the PSF INITPSF = padarray(UNDERPSF,[2 2],'replicate','both');

[J3 P3] = deconvblind(I,INITPSF); figure(4);imshow(J3);title('Deblurring with same size PSF'); % Improving the restortion % get the global threshold value of the image thresh = graythresh(I); WEIGHT = edge(I,'canny',thresh); %To widen the area, we use imdilate and pass in a structuring element, se. se = strel('disk',2); WEIGHT = 1-double(imdilate(WEIGHT,se)); % Assigned the value 0 to the pixels close to the bordes WEIGHT([1:3 end-[0:2]],:) = 0; WEIGHT(:,[1:3 end-[0:2]]) = 0; figure(5);imshow(WEIGHT);title('Weight array'); % restoredthe image by calling deconvblind with the WEIGHT array and an increased % number of iterations (30). [J P] = deconvblind(I,INITPSF,30,[],WEIGHT); figure(6);imshow(J);title('Deblurred Image-B4 Additionl tec'); % Using additional constraints on the PSF restoration % function, FUN, below returns a modified PSF array which deconvblind uses % for the next iteration. P1 = 2; P2 = 2; FUN = @(PSF) padarray(PSF(P1+1:end-P1,P2+1:end-P2),[P1 P2]); % Deconvled using modified PSF array [bar_out PF] = deconvblind(bar_out,OVERPSF,30,[],WEIGHT,FUN);

[bar_out PF] = deconvblind(I,OVERPSF,30,[],WEIGHT,FUN); bar = imread(JF); %return the deblur image to the next function figure(7);imshow(JF);title('Deblurred Image-Final'); imshow (bar_out); imwrite(JF,test_deblur,jpg); imshow(JF); % else if deblur not checked then display original image elseif (valuee == 0) bar = imread(name); imshow (bar); end % End of Deblur.m Rgb2gray - Converts RGB images into greyscale images. RGB (red,green,blue) images are typically in true colour and therefore are required to be altered for processing so it can be filtered. Grayscale images are typically black and white images, depicting the true nature of the barcodes we wish to process. This step is necessary as the majority of the functions evident within our processing process use 2 dimensional matrices, rather than the 3 dimensions represented by RGB images. Fspecial - Creates 2D special filters based on the selection of the following algorithms Gaussian, sobel, prewitt, laplacian, log, average and unsharp. Within our deblurring process, we utilise the fspecial function of the Gaussian type. Our particular function returns a rotationally symmetric Gaussian lowpass filter of size 7 and a standard deviation of 10. The resultant is the point-spread-function (PSF). Graythresh - Determines the global image threshold using Otsu's method. Using this method, the image is ensured to be a binary image. Edge - The edge function is very important to the processing process as it determines the edges of the bars within the barcode. Within the program, we use an edge function of type canny. By inputting the determined global threshold value, the program is able to detect strong and weak edges within the barcode. We chose the canny filter as it is much more adequate and powerful in comparison to the other filters available as it uses two different thresholds. This ensures that it can notice noise within the image more sufficiently. Strel - The strel function used within the deblurring process is of a type disk. This means that a structuring element of radius 2 is identified.

Imdilate - After the strel function, we pass the edged image and the structuring element though an imdilate morphological function. This expands the image to be processed. The modified image array is then processed by adding 0s close to the border of the image where it is then further deconvolved using the blind convolution algorithm. Deconvblind - This is used as no information about the blurring and noise of the image is known. This is usually the case with a new image. Since we do not know the blurring and nosies level of the image we employed deconvblind function,alone with the fspecial function of the Gaussian type 3.7 Readimage.m Barcode Image Recognition is an important step within our program as it aims to determine the position and hence, extract the barcode image from the surrounding area. The next important step is to crop the barcode image. The function is designed such that it scans the image, both vertically and horizontally, determining the end values associated with the edge of the barcode. Once these edges are established, the imcrop function within the image processing toolbox is utilised to crop the image to only include the barcode, eliminating any space that surrounds it. Now, the following steps are used when designing a barcode image recognition software : The function initially converts the barcode image, into a 1 dimensional array of 1s and 0s. We have designed it such that the 1s correspond to the bars, and the 0s correspond to the spaces of the barcode. 1) After loading the image, the first thing to be done is to convert the image into a black and white image, so that the entire image can be converted into a series of 0s and 1s. bar = imread ('PerfectI.jpg'); imshow (bar); The above functions will load the image in a window, which is to be further processed on. 2) We now require to convert the input image into a series of 0's and 1's to ease the process of decoding. For this, we do the following : size_bc = size(bar); for i=1:size_bc(2) bar1(i)=bar(round(size_bc(1)/2), i); end Here, we see that the sample image has a white border around it. So these white spaces are read as 1s and the black bars in the barcode are read as 0s. We can see that the first few

portions of the image will only be represented by 1s. So we should begin reading the barcode part of the image only once we encounter the starting and ending character. % Start of readimage.m %Recognises barcode from image function [ans, new_bar, flag]= readimage(bar) bar = imread ('perfectI.jpg'); imshow (bar); %Convert to 1 dimension array size_bc = size(bar); for i=1:size_bc(2) bar1(i)=bar(round(size_bc(1)/2), i); end %find start and end of barcode bcn=not(bar1); indices_1 = find(bcn, 1, 'first'); indices_2 = find(bcn, 1, 'last'); bc=bcn(indices_1:indices_2); %crop image from bar code %new image store in new_bar bar0n=not(bar); center=round((find(bar0n(:,indices_1), 1, 'first')+find(bar0n(:,indices_1), 1, 'last'))/2); new_bar=imcrop(bar,[indices_1 center indices_2-indices_1 40]); %Convert array to 95bit length x=1; for (y = 1:length(bc)) if (mod(y,length(bc)/95)==0)

bc2(x)=bc(y); x=x+1; end end %Output ans=bc2; if bc2==1 flag=1; else flag=0; end figure();imshow (new_bar); % End of Readimage.m 3.8BARCODE CONVERSION This function predominantly focuses on converting the sequence of binary 1s and 0s into its respective numerals, after it has been passed through checksum.m. It initially analyses the first 6 digits, that is, bits number 1 to 42, inclusive. This starts at bit number one as the start bits have been removed once the barcode is determined to be UPC-A. Thus, looking at 7 bits at a time, we are able to convert into the numeric numbers. [Ref.8] i = 1:42 -> 42 bits for i=1:6 if bc4(1+7*(i-1):7+7*(i-1)) == [0 0 0 1 1 0 1] bc5(i)=0; elseif bc4(1+7*(i-1):7+7*(i-1)) == [0 0 1 1 0 0 1]; bc5(i)=1; elseif bc4(1+7*(i-1):7+7*(i-1)) == [0 0 1 0 0 1 1]; bc5(i)=2;

elseif bc4(1+7*(i-1):7+7*(i-1)) == [0 1 1 1 1 0 1]; bc5(i)=3; elseif bc4(1+7*(i-1):7+7*(i-1)) == [0 1 0 0 0 1 1]; bc5(i)=4; elseif bc4(1+7*(i-1):7+7*(i-1)) == [0 1 1 0 0 0 1]; bc5(i)=5; elseif bc4(1+7*(i-1):7+7*(i-1)) == [0 1 0 1 1 1 1]; bc5(i)=6; elseif bc4(1+7*(i-1):7+7*(i-1)) == [0 1 1 1 0 1 1]; bc5(i)=7; elseif bc4(1+7*(i-1):7+7*(i-1)) == [0 1 1 0 1 1 1]; bc5(i)=8; elseif bc4(1+7*(i-1):7+7*(i-1)) == [0 0 0 1 0 1 1]; bc5(i)=9; end end This way, by using the UPC-A standard definitions for barcodes representation, we are able to decode the Barcode segment. CHAPTER 4 : CONCLUSION This project aims at simulating a camera based barcode scanner. As already described above, the camera based scanner captures the entire image of a product and then uses advanced image processing techniques to decode it. Here,a Graphic User Interface(GUI) is created for the users convenience, from where the image to be decoded is chosen. After this, we process the image(if the user wishes) and perform image cleaning processes of noise removal on it. The deblurring algorithm is used for the purpose of image modification and image processing to make the image machine readable. The image reading algorithm performs image cropping and image resizing processes on the image to convert the machine readable image into a 95 bit array that makes it very simple to decode according the barcode decoding program.

Now, one may ask how this software differs from other softwares that are currently being used for various applications, like consumer markets and other similar applications. The difference is that most of these softwares require expensive hardware to accompany it. This software does take time to process the image and decode it, hence application in consumer stores is not a very feasible idea. But in smaller scale applications, like something as simple as issuing a book from a library, can be monitored using this software. One can use any simple scanner and scan the barcode segment of the image and then process it. The output decoded barcode can be then linked to any database management software, and in this way, the monitoring of issuance of books in a library can be obtained. Similarly, applications where the speed of scanning and the magnitude of images are not large, and where the products do not need to be scanned at an extremely rapid rate, can make use of this software for carrying out daily activities. The software can also be modified to scan images of other formats too. The UPC-A code was chosen only due to the convenience that it has only a standard length of 95 bits. The barcode recognition algorithm, as well as a few changes to readimage.m file can enable the user to use the same program to read barcodes of other formats.

Read more: http://www.ukessays.com/essays/information-systems/bar-codedata.php#ixzz2Mrr7hrCL

Reference: (http://www.ukessays.com/essays/information-systems/bar-code-data.php)

Another Reference for bar code(main): http://www.softwarepractice.org/wiki/Image_Processing_for_Barcode_Recognition#Algorithm_Dev elopment_in_Matlab_for_Barcode_Recognition

Anda mungkin juga menyukai