Documentation

  • N/A
  • 2.6
  • 08/06/2021
  • Public Content

Industrial Text Line Recognition

In this tutorial, you'll run the Industrial Text Line Recognition reference implementation to verify that
Edge Insights for Industrial
was installed successfully and to start getting familiar with its modules and structure. By following this tutorial, you will learn:
  • How to add a new custom/user application to
    Edge Insights for Industrial
  • How to rebuild
    Edge Insights for Industrial
    with this new application
  • How to visualize the results of the custom application
This reference implementation provides an AI-enabled approach to recognize characters from print text line by using the deep learning method.
Industrial Text Line Recognition is a reference implementation that can be executed as part of the . If you have not installed that package yet, you can download it here and then follow the
Edge Insights for Industrial
installation instructions.
Target System Requirements
  • Ubuntu* 18.04 LTS
  • Intel® Core™ i5 processor or above with 16GB of RAM

How it Works

The application uses the inference engine included in the Intel® Distribution of OpenVINO™ toolkit. The reference implementation shows an example of how Industrial Text Line Recognition algorithm can be leveraged in industrial scenarios.
  • Print text line video: Sample video that is used to simulate a live camera stream. The video includes 300 print text images.
  • Inference Module: Ingest the frames from the camera stream and performs inference on each frame to recognize characters. The predicted result of each frame is also recorded and displayed on the output Visualizer window of the
    Edge Insights for Industrial
    software stack.
All communication between modules occurs over the
Edge Insights for Industrial
Message Bus. This reference implementation is a sample application that can be executed using the established pipeline.

Get Started

The Industrial Text Line Recognition reference implementation is a plug-and-play application developed for the
Edge Insights for Industrial
package.
This application is a reference implementation of how to deploy an OpenVINO™ optimized Industrial Text Line Recognition model using the
Edge Insights for Industrial
pipeline and not a production-ready custom commercially deployable Industrial Text Line Recognition tool.
Industrial Text Line Recognition is a reference implementation that can be executed as part of the . If you have not installed that package yet, you can download it here and then follow the
Edge Insights for Industrial
installation instructions.

Step 1: Add Industrial Text Line Recognition UDF Components

  1. Copy the Industrial Text Line Recognition UDF file to the
    Edge Insights for Industrial
    UDFs directory:
    # Set Edge Insights for Industrial home path as environment variable EII_HOME=<path_to_install_dir/IEdgeInsights/> # Copy Text Line Recognition UDF file to the UDFs directory cp -r text_line/ $EII_HOME/common/video/udfs/python/.
  2. Modify the VideoIngestion (VI) and VideoAnalytics (VA) configuration files to add Industrial Text Line Recognition to the IEdgeInsights pipeline:
    We recommend that you make copies of the original
    $EII_HOME/VideoIngestion/config.json
    and
    $EII_HOME/VideoAnalytics/config.json
    files before proceeding. These files needed to be rewritten to modify the pipeline to use the Industrial Text Line Recognition application files instead of the default PCB demo application.
    1. Make copies of the original VI and VA
      config.json
      files:
      mv $EII_HOME/VideoIngestion/config.json $EII_HOME/VideoIngestion/config.json_original mv $EII_HOME/VideoAnalytics/config.json $EII_HOME/VideoAnalytics/config.json_original
    2. Copy the new VI and VA
      config.json
      files to execute the Industrial Text Line Recognition application.
      Optionally, edit the
      va_config.json
      to use the inference hardware of choice [CPU/GPU/Myriad/HDDL]. Default is CPU.
      The deep learning model used in the reference implementation is a deep model, and hence would take a few minutes for the initial loading into an accelerator (Myriad/HDDL) memory.
      cp vi_config.json $EII_HOME/VideoIngestion/config.json cp va_config.json $EII_HOME/VideoAnalytics/config.json
    3. Copy the Industrial Text Line Recognition sample video to simulate camera stream input:
      cp text_line.avi $EII_HOME/VideoIngestion/test_videos/.
  3. Follow the
    Edge Insights for Industrial
    instructions to provision and launch the containers:
    # Configure the IEdgeInsights pipeline to use VideoIngestion, VideoAnalytics, Visualizer & Web Visualizer containers cd $EII_HOME/build/ sudo python3 builder.py -f video-streaming.yml # Provision cd $EII_HOME/build/provision/ sudo ./provision.sh ../docker-compose.yml # Build and run cd $EII_HOME/build/ docker-compose up --build -d # Enable visualizer display xhost +
    The output will look similiar to:

Step 2: Check the Reference Implementation

The
Edge Insights for Industrial
builds the VideoIngestion, VideoAnalytics, Visualizer and WebVisualizer containers. The VideoIngestion container streams the sample video to the VideoAnalytics container that performs Industrial Text Line Recognition on each frame to recognize the characters. Once the frame has been processed, the image is displayed on the Visualizer output window with the predicted result and inference time.
Execute the following command to ensure all the containers are running without errors:
sudo docker ps
Check for Success
If it was successful, the results will be similar to:
WebVisualizer Output
The sample video contains 300 printed text line images similar to the ones shown below:

(Optional) Stop the Vision Pipline

To stop the
Edge Insights for Industrial
software, execute the following command:
cd $EII_HOME/build/ docker-compose down
To revert to the default PCB Demo application, move the VI and VA
config.json
files to the original copies [Step 1.2.a] and rebuild using the instructions in Step 1.3.

(Optional) Standalone Testing

Testing the Industrial Text Line Recognition reference implementation outside of the
Edge Insights for Industrial
deployment environment requires OpenVINO™ to be installed on the development system. Please follow instructions on the OpenVINO™ website for installation steps for different inference hardware (CPU/Myriad/HDDL).
To execute the application on the host development system, follow the instructions below:
# Install dependencies pip install opencv-python==4.4.0.42 # Set OpenVINO env variables source /opt/intel/openvino/bin/setupvars.sh -pyver 3.6 # Run inference on single test image python3 text_line_recognizer.py\ --model <path/to/model/XML/file> \ --label <path/to/labels/txt/file> \ --image <path/to/input/test/image> Ex.: python3 text_line/text_line_recognizer.py \ --model text_line/ref/model.xml \ --label text_line/ref/labels.txt \ --image ./sample_data/2020081707:39:59E_217.jpg Expected output: Image : ./sample_data/2020081707:39:59E_217.jpg INFO:Textline_RECOGNITION:Prediction : 2020081707:39:59E INFO:Textline_RECOGNITION:Inference time : 0.08637118339538574 sec *********************************************************** # Run inference on directory of test images python3 text_line_recognizer.py \ --model <path/to/model/XML/file> \ --label <path/to/labels/txt/file> \ --dir <path/to/dir/of/test/images> Ex.: python3 text_line/text_line_recognizer.py \ --model text_line/ref/model.xml \ --label text_line/ref/labels.txt \ --dir ./sample_data/ Expected output: Image : ./sample_data/2019011413:26:44E_21.jpg INFO:Textline_RECOGNITION:Prediction : 2019011413:26:44E INFO:Textline_RECOGNITION:Inference time : 0.07046294212341309 sec *********************************************************** Image : ./sample_data/2020091921:05:31M_148.jpg INFO:Textline_RECOGNITION:Prediction : 2020091921:05:31M INFO:Textline_RECOGNITION:Inference time : 0.0416107177734375 sec ***********************************************************

Summary and Next Steps

In this tutorial, you successfully ran the Industrial Text Line Recognition application and displayed the result using the
Edge Insights for Industrial
Visualizer output.
To get access to the deep learning training algorithm that was used to generate the Industrial Text Line Recognition model, please contact your Intel account manager.
As a next step, see the Industrial Surface Defect Detection tutorial.

Product and Performance Information

1

Performance varies by use, configuration and other factors. Learn more at www.Intel.com/PerformanceIndex.