%% Barcode Recognition Using Live Video Acquisition
%
% This example shows how to use the From Video Device block to recognize a barcode.
%
% Image Acquisition Toolbox(TM) provides a Simulink(R) block to acquire live
% image data from image acquisition devices into Simulink models.
%
% This example uses the From Video Device block to acquire live image data
% from the Point Grey Flea(R) 2 camera into Simulink. The example uses the 
% Computer Vision Toolbox(TM) to create an image processing 
% system which can recognize and interpret a GTIN-13 barcode. The GTIN-13 
% barcode, formally known as EAN-13, is an international barcode standard. 
% It is a superset of the widely used UPC standard. 
%
% This example requires Simulink, Computer Vision Toolbox and the
% Point Grey Flea(R) 2 camera to open and run the model. 

%%
%
% <https://www.mathworks.com/videos/barcode-recognition-using-live-video-acquisition-101414.html Watch
% barcode recognition on live video stream>. (11 seconds)
%
%

%%

% Copyright 2008-2012 The MathWorks, Inc.

%% Example Model
% The following figure shows the example model using the From Video Device
% block.
%
%
% <<../demoimaqsl_barcoderecognition_01.png>>

%% Live Video Input
% The input video is acquired live from a DCAM image acquisition device
% (Point Grey Flea(R) 2). In this example, the block acquires RGB frames 
% from the camera and outputs them into the Simulink model at every 
% simulation time step.

%% Algorithm
% The barcode recognition example performs a search on some selected rows of
% the input image, called scan lines. The scan lines are analyzed per pixel
% and marked by feature. Once all pixels are marked with a feature value, 
% the sequences of patterns are analyzed. The example identifies the guard 
% patterns and symbols by sequence and location. The symbols are up sampled 
% and compared with the codebook to determine a corresponding code.
%
% To compensate for various barcode orientations, the example analyzes from
% left to right and from right to left and chooses the better match. If the
% check sum is correct and a matching score against the codebook is higher
% than a set threshold, the code is considered valid and is displayed.
%
% You can change the number and location of the scan lines by changing the
% value of the "Row Positions Of Scan Lines" parameter.

%% Results
% The scan lines that have been used to detect barcodes are displayed in 
% red. When a GTIN-13 is correctly recognized and verified, the code is 
% displayed in yellow. 
%
% <<../demoimaqsl_barcoderecognition_outputs.png>>

%%
% Even though a Flea(R) 2 camera was used for this example, this model 
% can be easily updated to connect your models to other supported image 
% acquisition devices. This provides you the flexibility to use the same 
% Simulink model with different image acquisition hardware.
