Skip to content

transcend-information/RaspberryPi_OCR_Demo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Transcend ECM300 Raspberry Pi 5 OCR Demo Project

This project demonstrates real-time Optical Character Recognition (OCR) on the Raspberry Pi 5 platform, using the Transcend ECM300 embedded camera module. It is designed to capture live video, detect text regions, and recognize characters efficiently using the PaddleOCR framework.


Table of Contents


Hardware Requirements

  1. Supported Platforms

    • Raspberry Pi 5
  2. Supported Cameras

  3. Recommended SD Card

    • A microSD card with at least 128 GB capacity and UHS-1 speed class or higher.

Install Raspberry Pi 5 OS

Important: The ECM300 camera driver is only compatible with Raspberry Pi OS running Linux kernel version 6.12.25+rpt-rpi-2712. Using a different kernel version will result in driver incompatibility.

Installation Steps

  1. Download Raspberry Pi OS (64-bit, Debian Bookworm) dated 2025-05-13 from https://downloads.raspberrypi.org/raspios_arm64/images/raspios_arm64-2025-05-13/2025-05-13-raspios-bookworm-arm64.img.xz

    Note: This specific OS version includes the required kernel 6.12.25+rpt-rpi-2712.

  2. Write the image to the microSD card using Raspberry Pi Imager.

    • In the "Choose operating system" step, select "Use custom" at the bottom of the list, then choose the downloaded image file.
  3. Insert the microSD card into the Raspberry Pi 5 and complete the initial setup (language, username, WiFi, etc.).

  4. Important: During the OS installation process, when prompted with "Update Software" dialog:

    • Click "Skip" to continue without checking for updates

    • DO NOT click "Next" as this will update the system and may upgrade the kernel to an incompatible version

  5. After first boot, verify the kernel version:

    uname -r

    Expected output:

    6.12.25+rpt-rpi-2712
    

    Warning: If the kernel version does not match exactly, do NOT proceed with driver installation. The camera driver will not work with other kernel versions.

  6. Do NOT run system updates after installation, as this may upgrade the kernel to an incompatible version:

    # DO NOT RUN THIS
    # sudo apt update && sudo apt upgrade

    The installation script will automatically lock the kernel version to prevent accidental updates.


Connect the ECM300 Camera to Raspberry Pi 5

  1. Power off the Raspberry Pi 5 completely:

    sudo shutdown -h now
  2. Insert the camera module as follows:

    • ECM300: Insert into the CAM/DISP 1 port (the port closer to the USB-C power connector)
  3. Power on the Raspberry Pi 5.


Install IMX675 Camera Driver

1. Prepare Driver Package

Copy the Driver_Install folder to the desktop:

cd ~/Desktop/RaspberryPi_OCR_Demo/Driver_Install

2. Installation

Note: Please make sure the device is connected to the Internet before running the following commands.

Option A: Automatic Installation (Recommended)

Execute the installation script:

chmod +x install_imx675.sh
./install_imx675.sh

The installation will:

  • Install build dependencies (meson, ninja, kernel headers, etc.)
  • Clone and compile libcamera with IMX675 support
  • Install kernel module and device tree overlay
  • Configure system settings
  • Lock kernel version to prevent incompatible updates

Installation time: Approximately 15-25 minutes depending on your SD card speed and internet connection.

Option B: Manual Installation

Refer to the manual located in:

Driver_Install/CameraDriver_Package_v1.0/docs/

Follow the step-by-step instructions in the manual for manual installation.

3. Reboot

After installation completes successfully, reboot the system:

sudo reboot

4. Verify Installation

After reboot, verify the camera driver is working:

# List available cameras
libcamera-hello --list

# Test camera preview for 5 seconds
libcamera-vid -t 5000

Expected output:

Available cameras
-----------------
0 : imx675 [2592x1944 10-bit RGGB] (/base/axi/pcie@120000/rp1/i2c@80000/imx675@1a)

Note: The camera will only appear in the list after you physically connect it in the next section.


Quickly Run OCR

1. Run the Script

On first run, the script will automatically create a virtual environment (.venv) and install required packages. This may take a few minutes.

cd ~/Desktop/RaspberryPi_OCR_Demo
chmod +x run_ocr_raspi.sh
./run_ocr_raspi.sh

During Live View, you can enter the following commands in the terminal:

  • Capture — Save a snapshot of the current frame:

    capture pic.jpg
  • View Detect — Detect text regions in the live feed, draw red bounding boxes, and export coordinates to an XML file:

    view_detect output.xml

    Note: Live View pauses during detection. Enter the view command to resume.

  • View Recognize — Perform OCR on captured images and display recognized text on both the terminal and the live view:

    view_recognize
  • quit — Close the live view and exit the application:

    quit

Run OCR Manual

1. Set Up Virtual Environment

Navigate to the project directory and activate the virtual environment:

cd ~/Desktop/RaspberryPi_OCR_Demo
source .venv/bin/activate

Note: If the virtual environment doesn't exist (or you see bash: .venv/bin/activate: No such file or directory),

Run the following commands to create it and install the required packages:

python3 -m venv .venv --system-site-packages
source .venv/bin/activate
pip install -r requirements.txt

Command Usage

Note: Please make sure the device is connected to the Internet before running the following commands.

1. Show Live View

Display live video from the ECM300 / ECM100 camera. Option -o controls image rotation: 0 = no rotation, 1 = 90°, 2 = 180°, 3 = 270°.

python ocr_raspberrypi.py view -o 0

2. Detect Text in an Image and Export XML

Detect text from a static image, draw bounding boxes, and export the coordinates to an XML file.

python ocr_raspberrypi.py image_detect -i pic.jpg -x output.xml

3. Perform OCR and Display Results

Recognize text from a static image and print the results in the terminal.

python ocr_raspberrypi.py image_recognize -i pic.jpg

4. Deactivate Virtual Environment

To deactivate the virtual environment:

deactivate

Third-Party Licenses

This project uses PaddleOCR, which is licensed under the Apache License 2.0. You may freely use PaddleOCR for research, personal, and commercial purposes, provided that you retain the original license and copyright notice. No modifications were made to the original PaddleOCR source code.

About

A OCR demo application using Transcend ECM300 Camera in Raspberry Pi.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors