-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ad233ef
commit 5055193
Showing
35 changed files
with
14,798 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,144 @@ | ||
# Prerequisites | ||
*.d | ||
# Created by .ignore support plugin (hsz.mobi) | ||
### Python template | ||
# Byte-compiled / optimized / DLL files | ||
__pycache__/ | ||
*.py[cod] | ||
*$py.class | ||
|
||
# Compiled Object files | ||
*.slo | ||
*.lo | ||
*.o | ||
*.obj | ||
# C extensions | ||
*.so | ||
|
||
# Precompiled Headers | ||
*.gch | ||
*.pch | ||
# Distribution / packaging | ||
.Python | ||
build/ | ||
develop-eggs/ | ||
dist/ | ||
downloads/ | ||
eggs/ | ||
.eggs/ | ||
lib/ | ||
lib64/ | ||
parts/ | ||
sdist/ | ||
var/ | ||
wheels/ | ||
pip-wheel-metadata/ | ||
share/python-wheels/ | ||
*.egg-info/ | ||
.installed.cfg | ||
*.egg | ||
MANIFEST | ||
|
||
# Compiled Dynamic libraries | ||
*.so | ||
*.dylib | ||
*.dll | ||
|
||
# Fortran module files | ||
*.mod | ||
*.smod | ||
|
||
# Compiled Static libraries | ||
*.lai | ||
*.la | ||
*.a | ||
*.lib | ||
|
||
# Executables | ||
*.exe | ||
*.out | ||
*.app | ||
# PyInstaller | ||
# Usually these files are written by a python script from a template | ||
# before PyInstaller builds the exe, so as to inject date/other infos into it. | ||
*.manifest | ||
*.spec | ||
|
||
# Installer logs | ||
pip-log.txt | ||
pip-delete-this-directory.txt | ||
|
||
# Unit test / coverage reports | ||
htmlcov/ | ||
.tox/ | ||
.nox/ | ||
.coverage | ||
.coverage.* | ||
.cache | ||
nosetests.xml | ||
coverage.xml | ||
*.cover | ||
*.py,cover | ||
.hypothesis/ | ||
.pytest_cache/ | ||
|
||
# Translations | ||
*.mo | ||
*.pot | ||
|
||
# Django stuff: | ||
*.log | ||
local_settings.py | ||
db.sqlite3 | ||
db.sqlite3-journal | ||
|
||
# Flask stuff: | ||
instance/ | ||
.webassets-cache | ||
|
||
# Scrapy stuff: | ||
.scrapy | ||
|
||
# Sphinx documentation | ||
docs/_build/ | ||
|
||
# PyBuilder | ||
target/ | ||
|
||
# Jupyter Notebook | ||
.ipynb_checkpoints | ||
|
||
# IPython | ||
profile_default/ | ||
ipython_config.py | ||
|
||
# pyenv | ||
.python-version | ||
|
||
# pipenv | ||
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. | ||
# However, in case of collaboration, if having platform-specific dependencies or dependencies | ||
# having no cross-platform support, pipenv may install dependencies that don't work, or not | ||
# install all needed dependencies. | ||
#Pipfile.lock | ||
|
||
# PEP 582; used by e.g. github.com/David-OConnor/pyflow | ||
__pypackages__/ | ||
|
||
# Celery stuff | ||
celerybeat-schedule | ||
celerybeat.pid | ||
|
||
# SageMath parsed files | ||
*.sage.py | ||
|
||
# Environments | ||
.env | ||
.venv | ||
env/ | ||
venv/ | ||
ENV/ | ||
env.bak/ | ||
venv.bak/ | ||
|
||
# Spyder project settings | ||
.spyderproject | ||
.spyproject | ||
|
||
# Rope project settings | ||
.ropeproject | ||
|
||
# mkdocs documentation | ||
/site | ||
|
||
# mypy | ||
.mypy_cache/ | ||
.dmypy.json | ||
dmypy.json | ||
|
||
# Pyre type checker | ||
.pyre/ | ||
|
||
#idea | ||
.idea | ||
cmake-build-debug/ | ||
build/ | ||
build-lib/ | ||
images/ | ||
models/*.param | ||
models/*.bin | ||
/ncnn-static | ||
/ncnn-vulkan-static | ||
/opencv-static | ||
/opencv-shared |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,142 @@ | ||
cmake_minimum_required(VERSION 3.1) | ||
project(RapidOCRNcnn) | ||
|
||
option(OCR_LIB "OcrLite Jni Support" OFF) | ||
option(OCR_STATIC "Use Static Librarys For Build" ON) | ||
option(OCR_OPENMP "OcrLite Enable OpenMP" ON) | ||
option(OCR_BENCHMARK "build benchmark" ON) | ||
option(OCR_VULKAN "OcrLite Enable Vulkan" OFF) | ||
#set(OCR_LIB ON) | ||
#set(OCR_STATIC OFF) | ||
#set(OCR_OPENMP OFF) | ||
set(OCR_BENCHMARK ON) | ||
#set(OCR_VULKAN OFF) | ||
|
||
set(CMAKE_CXX_STANDARD 11) | ||
add_definitions(-DUNICODE -D_UNICODE) | ||
if (CMAKE_BUILD_TYPE STREQUAL "Debug") | ||
add_definitions("-Wall -g -O0") | ||
else () | ||
add_definitions("-Wall") | ||
endif () | ||
|
||
# OpenMP flags for MACOS | ||
if (APPLE) | ||
if (CMAKE_C_COMPILER_ID MATCHES "Clang") | ||
set(OpenMP_C "${CMAKE_C_COMPILER}") | ||
set(OpenMP_C_FLAGS "-Xpreprocessor -fopenmp -I/usr/local/opt/libomp/include") | ||
set(OpenMP_C_LIB_NAMES "omp") | ||
set(OpenMP_omp_LIBRARY ${OpenMP_C_LIB_NAMES}) | ||
endif () | ||
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang") | ||
set(OpenMP_CXX "${CMAKE_CXX_COMPILER}") | ||
set(OpenMP_CXX_FLAGS "-Xpreprocessor -fopenmp -I/usr/local/opt/libomp/include") | ||
set(OpenMP_CXX_LIB_NAMES "omp") | ||
set(OpenMP_omp_LIBRARY ${OpenMP_C_LIB_NAMES}) | ||
endif () | ||
link_directories("/usr/local/opt/libomp/lib") | ||
endif () | ||
|
||
# OpenMP | ||
find_package(OpenMP REQUIRED) | ||
if (OPENMP_FOUND) | ||
message("OPENMP FOUND") | ||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}") | ||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}") | ||
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${OpenMP_EXE_LINKER_FLAGS}") | ||
else () | ||
message(FATAL_ERROR "OpenMP Not Found!") | ||
endif () | ||
|
||
# NCNN | ||
if (OCR_VULKAN) | ||
include(${CMAKE_CURRENT_SOURCE_DIR}/ncnn-vulkan-static/NcnnWrapperConfig.cmake) | ||
else () | ||
include(${CMAKE_CURRENT_SOURCE_DIR}/ncnn-static/NcnnWrapperConfig.cmake) | ||
endif () | ||
find_package(ncnn REQUIRED) | ||
if (ncnn_FOUND) | ||
message(STATUS "ncnn Found!") | ||
else () | ||
message(FATAL_ERROR "ncnn Not Found!") | ||
endif (ncnn_FOUND) | ||
|
||
# OpenCV | ||
if (OCR_STATIC) | ||
include(${CMAKE_CURRENT_SOURCE_DIR}/opencv-static/OpenCVWrapperConfig.cmake) | ||
else () | ||
include(${CMAKE_CURRENT_SOURCE_DIR}/opencv-shared/OpenCVWrapperConfig.cmake) | ||
endif () | ||
find_package(OpenCV REQUIRED) | ||
if (OpenCV_FOUND) | ||
message(STATUS "OpenCV_LIBS: ${OpenCV_LIBS}") | ||
message(STATUS "OpenCV_INCLUDE_DIRS: ${OpenCV_INCLUDE_DIRS}") | ||
else () | ||
message(FATAL_ERROR "opencv Not Found!") | ||
endif (OpenCV_FOUND) | ||
|
||
# JNI | ||
if (OCR_LIB) | ||
find_package(JNI REQUIRED) | ||
if (JNI_FOUND) | ||
message("JNI FOUND") | ||
message(STATUS "JNI_LIBS: ${JNI_LIBS}") | ||
message(STATUS "JNI_INCLUDE_DIRS: ${JNI_INCLUDE_DIRS}") | ||
include_directories(${JNI_INCLUDE_DIRS}) | ||
else () | ||
message(FATAL_ERROR "JNI Not Found!") | ||
endif () | ||
endif () | ||
|
||
# project include | ||
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include) | ||
|
||
# source | ||
file(GLOB OCR_SRC ${CMAKE_CURRENT_SOURCE_DIR}/src/*.cpp) | ||
set(OCR_COMPILE_CODE ${OCR_SRC}) | ||
|
||
# static libgcc libstdc++ | ||
if (OCR_STATIC) | ||
if (APPLE) | ||
set(CMAKE_EXE_LINKER_FLAGS "-static-libstdc++") | ||
else () | ||
set(CMAKE_EXE_LINKER_FLAGS "-static-libgcc -static-libstdc++") | ||
endif () | ||
endif () | ||
|
||
if (OCR_LIB) | ||
add_library(RapidOCRNcnn SHARED ${OCR_COMPILE_CODE}) | ||
target_compile_definitions(RapidOCRNcnn PRIVATE __JNI__) | ||
target_link_libraries(RapidOCRNcnn ncnn ${OpenCV_LIBS} ${JNI_LIBS} ${OpenMP_CXX_LIB_NAMES}) | ||
else () | ||
add_executable(RapidOCRNcnn ${OCR_COMPILE_CODE}) | ||
target_link_libraries(RapidOCRNcnn ncnn ${OpenCV_LIBS} ${OpenMP_CXX_LIB_NAMES}) | ||
endif () | ||
|
||
if (OCR_OPENMP) | ||
target_compile_definitions(RapidOCRNcnn PRIVATE __OPENMP__) | ||
endif () | ||
|
||
if (OCR_VULKAN) | ||
target_compile_definitions(RapidOCRNcnn PRIVATE __VULKAN__) | ||
endif () | ||
|
||
# benchmark | ||
if (OCR_BENCHMARK AND NOT OCR_LIB) | ||
add_executable(benchmark benchmark/benchmark.cpp | ||
src/AngleNet.cpp | ||
src/clipper.cpp | ||
src/CrnnNet.cpp | ||
src/DbNet.cpp | ||
src/getopt.cpp | ||
src/OcrLite.cpp | ||
src/OcrUtils.cpp) | ||
target_link_libraries(benchmark ncnn ${OpenCV_LIBS} ${OpenMP_CXX_LIB_NAMES}) | ||
if (OCR_OPENMP) | ||
target_compile_definitions(benchmark PRIVATE __OPENMP__) | ||
endif () | ||
|
||
if (OCR_VULKAN) | ||
target_compile_definitions(benchmark PRIVATE __VULKAN__) | ||
endif () | ||
endif () |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,12 @@ | ||
# RapidOCRNcnn | ||
# RapidOCRNcnnCpp | ||
|
||
ncnn 推理 WIP | ||
|
||
因模型转换没有完全支持的关系,关闭了cls模型来使用 | ||
|
||
转换成功的模型:mobile_det,server_det,server_rec | ||
|
||
转换失败的模型:mobile_cls,mobile_rec | ||
|
||
### [模型转换说明](./models/README.md) | ||
|
Oops, something went wrong.