bar code data

Upload: shayani-batabyal

Post on 03-Apr-2018

221 views

Category:

Documents


0 download

TRANSCRIPT

  • 7/29/2019 Bar Code Data

    1/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 alsocome in patterns of dots, concentric circles, and text codes hidden within images. Barcodescan be read by optical scanners called barcode readers or scanned from an image by specialsoftware. Barcodes are widely used to implement Auto ID Data Capture (AIDC) systems thatimprove 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 isconstantly improving. Some modern applications of barcodes include:

    Practically every item purchased from a grocery store, department store, and massmerchandiser has a barcode on it. This greatly helps in keeping track of the largenumber of items in a store and also reduces instances of shoplifting (since shoplifterscould no longer easily switch price tags from a lower-cost item to a higher-pricedone). Since the adoption of barcodes, both consumers and retailers have benefitedfrom the savings generated.

    Document Management tools often allow for bar coded sheets to facilitate theseparation and indexing of documents that have been imaged in batch scanningapplications.

    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 theinsects' 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 asymbology includes the encoding of the single digits/characters of the message as well as thestart and stop markers into bars and space, the size of the quiet zone required to be before andafter 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 onecharacter ending with a space and the next beginning with a bar, or vice versa.

  • 7/29/2019 Bar Code Data

    2/19

  • 7/29/2019 Bar Code Data

    3/19

    PDF417 PDF417 is a little more complex and it is difficult to say exactly what itscapacity is because it depends greatly on the type of data that you encodein a PDF417 symbol as well as the amount of error correction capacitythat you choose to use in a PDF417 symbol.

    For general binary data with no error correction enabled, a singlePDF417 symbol can hold up to 1108 bytes. If the data consists of allnumeric 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, thecapacity will be somewhere between 1108 and 1850 bytes and willdepend on the content of the data.

    All of our bar code software products use an extremely efficientencoding algorithm that will squeeze the maximum number of bytes

    possible into a PDF417 symbol however it still must work within thelimits of the symbology specification.

    1.4Benefits of using barcodes

    In point-of-sale management, the use of barcodes can provide very detailed up-to-dateinformation on key aspects of the business, enabling decisions to be made much more quicklyand 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, allowingfast-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 inshipping/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 aboutthe box; such as order number, items packed , qty packed, final destination, etc

    The information can be transmitted through a communication system such asElectronic Data Interchange (EDI) so the retailer has the information about a shipment

    before it arrives.

  • 7/29/2019 Bar Code Data

    4/19

    Tracking results when shipments are sent to a Distribution Center (DC) before beingforwarded to the final destination.

    When the shipment gets to the final destination, the UID gets scanned, and the storeknows 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 costand 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 slightlydifferent 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 barsin 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 barsand spaces in the bar code. Dark bars in the bar code absorb light and white spaces reflectlight 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 sameway as pen type readers except that they use a laser beam as the light source and typicallyemploy either a reciprocating mirror or a rotating prism to scan the laser beam back and forthacross the bar code. Just the same as with the pen type reader, a photo diode is used tomeasure the intensity of the light reflected back from the bar code. In both pen readers andlaser scanners, the light emitted by the reader is tuned to a specific frequency and the photodiode 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 upin 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 inthe CCD reader is extremely small and because there are hundreds of sensors lined up in arow, a voltage pattern identical to the pattern in a bar code is generated in the reader bysequentially 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 emittedambient 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 usessophisticated digital image processing techniques to decode the bar code. Video cameras use

  • 7/29/2019 Bar Code Data

    5/19

    the same CCD technology as in a CCD bar code reader except that instead of having a singlerow of sensors, a video camera has hundreds of rows of sensors arranged in a twodimensional 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 iscomposed of a combination of bars and spaces to denote particular alpha -numericidentification 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 anyhuman-readable characters (or numbers) into specific combination of bars and spaces. Thereare 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 thatan 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 andwhite 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 isevident, 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

  • 7/29/2019 Bar Code Data

    6/19

    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 onescomplements 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: 10000104: 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 recognitionwithin 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 0to 1, corresponding to the bars and spaces, etc. To convert the image to a graph as such wouldthen allow us to manipulate MATLAB to read the graph and determine the numbersinvolved. [Ref.5]

  • 7/29/2019 Bar Code Data

    7/19

    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 12digits 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 printedto the left of the barcode, and the check digit to the right. The manufacturer and productcodes are printed just below the barcode, separated by the guard bar.

    NS Description

    0 Regular UPC code

    1 Reserved

    2 Weight Items

    3 Drug/Health Items

    4 In-store use on non-food items

    5 Coupons

    6 Reserved

    7 Regular UPC code

    8 Reserved

    9 Reserved

    Number System. The number system is the first digit in the UPC number to identify the typeof 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

  • 7/29/2019 Bar Code Data

    8/19

    manufacturer code, visit http://www.uc-council.org/. Note that UCC has started to assignmanufacturer 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 5-digit 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 scannedcorrectly. The check digit is calculated based on the rest of the barcode digits. Read thefollowing 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 astandard 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 simulationin, but the length of a code 39 Barcode varies greatly depending on the product for which it ismade. 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 imagecontaining 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)

  • 7/29/2019 Bar Code Data

    9/19

    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 asmany 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 kindof pre-processing image that he wants, and then can process that desired image to be decodedto 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 startingclear 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);

  • 7/29/2019 Bar Code Data

    10/19

    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 downmenu in the GUI. The user can select the desired image, a preview of which is available onGUI 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 theoptions 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 interfacewherein 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');

  • 7/29/2019 Bar Code Data

    11/19

    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 edgesof 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 thencreates 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

  • 7/29/2019 Bar Code Data

    12/19

    This algorithm is used for deblurring an image. The image scanned may be blurred if movedwhile scanning, or even if the scanning device used may have imperfections. In this case, weuse 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 imagesynthesis. 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. Thedescription 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');

  • 7/29/2019 Bar Code Data

    13/19

    [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);

  • 7/29/2019 Bar Code Data

    14/19

    [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 aretypically 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 functionsevident within our processing process use 2 dimensional matrices, rather than the 3dimensions 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 astandard 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 theedges of the bars within the barcode. Within the program, we use an edge function of typecanny. By inputting the determined global threshold value, the program is able to detectstrong and weak edges within the barcode. We chose the canny filter as it is much moreadequate and powerful in comparison to the other filters available as it uses two differentthresholds. 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 thata structuring element of radius 2 is identified.

  • 7/29/2019 Bar Code Data

    15/19

    Imdilate - After the strel function, we pass the edged image and the structuring elementthough an imdilate morphological function. This expands the image to be processed. Themodified image array is then processed by adding 0s close to the border of the image where itis then further deconvolved using the blind convolution algorithm.

    Deconvblind - This is used as no information about the blurring and noise of the image isknown. This is usually the case with a new image. Since we do not know the blurring andnosies level of the image we employed deconvblind function,alone with the fspecial functionof the Gaussian type

    3.7 Readimage.m

    Barcode Image Recognition is an important step within our program as it aims to determinethe 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 itscans the image, both vertically and horizontally, determining the end values associated withthe edge of the barcode. Once these edges are established, the imcrop function within theimage 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. Wehave designed it such that the 1s correspond to the bars, and the 0s correspond to the spacesof the barcode.

    1) After loading the image, the first thing to be done is to convert the image into a black andwhite 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 areread as 1s and the black bars in the barcode are read as 0s. We can see that the first few

  • 7/29/2019 Bar Code Data

    16/19

    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)

  • 7/29/2019 Bar Code Data

    17/19

    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 itsrespective numerals, after it has been passed through checksum.m. It initially analyses thefirst 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 bitsat 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;

  • 7/29/2019 Bar Code Data

    18/19

    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 ableto 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 advancedimage processing techniques to decode it.

    Here,a Graphic User Interface(GUI) is created for the users convenience, from where theimage 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 usedfor the purpose of image modification and image processing to make the image machinereadable. 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 makesit very simple to decode according the barcode decoding program.

  • 7/29/2019 Bar Code Data

    19/19

    Now, one may ask how this software differs from other softwares that are currently beingused for various applications, like consumer markets and other similar applications. Thedifference is that most of these softwares require expensive hardware to accompany it. Thissoftware 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 anysimple scanner and scan the barcode segment of the image and then process it. The outputdecoded 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, applicationswhere 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 softwarefor carrying out daily activities.

    The software can also be modified to scan images of other formats too. The UPC-A code waschosen only due to the convenience that it has only a standard length of 95 bits. The barcoderecognition algorithm, as well as a few changes to readimage.m file can enable the user to usethe same program to read barcodes of other formats.

    Read more: http://www.ukessays.com/essays/information-systems/bar-code-data.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_Development_in_Matlab_for_Barcode_Recognition

    http://www.ukessays.com/essays/information-systems/bar-code-data.php#ixzz2Mrr7hrCLhttp://www.ukessays.com/essays/information-systems/bar-code-data.php#ixzz2Mrr7hrCLhttp://www.ukessays.com/essays/information-systems/bar-code-data.php#ixzz2Mrr7hrCLhttp://www.ukessays.com/essays/information-systems/bar-code-data.php#ixzz2Mrr7hrCLhttp://www.ukessays.com/essays/information-systems/bar-code-data.phphttp://www.ukessays.com/essays/information-systems/bar-code-data.phphttp://www.ukessays.com/essays/information-systems/bar-code-data.phphttp://www.softwarepractice.org/wiki/Image_Processing_for_Barcode_Recognition#Algorithm_Development_in_Matlab_for_Barcode_Recognitionhttp://www.softwarepractice.org/wiki/Image_Processing_for_Barcode_Recognition#Algorithm_Development_in_Matlab_for_Barcode_Recognitionhttp://www.softwarepractice.org/wiki/Image_Processing_for_Barcode_Recognition#Algorithm_Development_in_Matlab_for_Barcode_Recognitionhttp://www.softwarepractice.org/wiki/Image_Processing_for_Barcode_Recognition#Algorithm_Development_in_Matlab_for_Barcode_Recognitionhttp://www.softwarepractice.org/wiki/Image_Processing_for_Barcode_Recognition#Algorithm_Development_in_Matlab_for_Barcode_Recognitionhttp://www.ukessays.com/essays/information-systems/bar-code-data.phphttp://www.ukessays.com/essays/information-systems/bar-code-data.php#ixzz2Mrr7hrCLhttp://www.ukessays.com/essays/information-systems/bar-code-data.php#ixzz2Mrr7hrCL