Skip to content

Commit

Permalink
Text recognition crnn (#176)
Browse files Browse the repository at this point in the history
* rcnn only for EN

* review 1

* add readme.md

* rename file

* review 2

* review 3

* option v

* review 4
  • Loading branch information
LaurentBerger committed Aug 8, 2023
1 parent 0d61961 commit 9aa1562
Show file tree
Hide file tree
Showing 4 changed files with 4,440 additions and 2 deletions.
29 changes: 29 additions & 0 deletions models/text_recognition_crnn/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
cmake_minimum_required(VERSION 3.24)
set(project_name "opencv_zoo_text_recognition_crnn")

PROJECT (${project_name})

set(OPENCV_VERSION "4.7.0")
set(OPENCV_INSTALLATION_PATH "" CACHE PATH "Where to look for OpenCV installation")
find_package(OpenCV ${OPENCV_VERSION} REQUIRED HINTS ${OPENCV_INSTALLATION_PATH})
# Find OpenCV, you may need to set OpenCV_DIR variable
# to the absolute path to the directory containing OpenCVConfig.cmake file
# via the command line or GUI

file(GLOB SourceFile
"demo.cpp")
# If the package has been found, several variables will
# be set, you can find the full list with descriptions
# in the OpenCVConfig.cmake file.
# Print some message showing some of them
message(STATUS "OpenCV library status:")
message(STATUS " config: ${OpenCV_DIR}")
message(STATUS " version: ${OpenCV_VERSION}")
message(STATUS " libraries: ${OpenCV_LIBS}")
message(STATUS " include path: ${OpenCV_INCLUDE_DIRS}")

# Declare the executable target built from your sources
add_executable(${project_name} ${SourceFile})

# Link your application with OpenCV libraries
target_link_libraries(${project_name} PRIVATE ${OpenCV_LIBS})
31 changes: 29 additions & 2 deletions models/text_recognition_crnn/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ Note:
- Try `text_recognition_CRNN_CH_2021sep.onnx` with `charset_94_CH.txt`
- Try `text_recognition_CRNN_CN_2021sep.onnx` with `charset_3944_CN.txt`.

### Python

Run the demo detecting English:

```shell
Expand All @@ -52,13 +54,38 @@ Run the demo detecting Chinese:

```shell
# detect on camera input
python demo.py --model text_recognition_CRNN_CN_2021nov.onnx --charset charset_3944_CN.txt
python demo.py --model text_recognition_CRNN_CN_2021nov.onnx
# detect on an image
python demo.py --input /path/to/image --model text_recognition_CRNN_CN_2021nov.onnx --charset charset_3944_CN.txt
python demo.py --input /path/to/image --model text_recognition_CRNN_CN_2021nov.onnx

# get help regarding various parameters
python demo.py --help
```
### C++

Install latest OpenCV and CMake >= 3.24.0 to get started with:

```shell
# detect on camera input
./build/opencv_zoo_text_recognition_crnn
# detect on an image
./build/opencv_zoo_text_recognition_crnn --input /path/to/image -v

# get help regarding various parameters
./build/opencv_zoo_text_recognition_crnn --help
```

Run the demo detecting Chinese:

```shell
# detect on camera input
./build/opencv_zoo_text_recognition_crnn --model=text_recognition_CRNN_CN_2021nov.onnx --charset=charset_3944_CN.txt
# detect on an image
./build/opencv_zoo_text_recognition_crnn --input=/path/to/image --model=text_recognition_CRNN_CN_2021nov.onnx --charset=charset_3944_CN.txt

# get help regarding various parameters
./build/opencv_zoo_text_recognition_crnn --help


### Examples

Expand Down
Loading

0 comments on commit 9aa1562

Please sign in to comment.