Skip to content

Commit

Permalink
OcrLiteNcnn项目升级1.6.1
Browse files Browse the repository at this point in the history
  • Loading branch information
benjaminwan committed Oct 28, 2021
1 parent d3aa354 commit 1469b42
Show file tree
Hide file tree
Showing 7 changed files with 78 additions and 11 deletions.
13 changes: 7 additions & 6 deletions cpp_projects/OcrLiteNcnn/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -103,20 +103,21 @@ if (OCR_OUTPUT STREQUAL "JNI") # JNI
add_library(OcrLiteNcnn SHARED ${OCR_COMPILE_CODE})
target_compile_definitions(OcrLiteNcnn PRIVATE __JNI__)
target_link_libraries(OcrLiteNcnn ncnn ${OpenCV_LIBS} ${JNI_LIBS} ${OpenMP_CXX_LIB_NAMES})
elseif(OCR_OUTPUT STREQUAL "CLIB") # C LIB
elseif(OCR_OUTPUT STREQUAL "CLIB") # CLIB
add_library(OcrLiteNcnn SHARED ${OCR_COMPILE_CODE})
target_compile_definitions(OcrLiteNcnn PRIVATE __CLIB__)
target_link_libraries(OcrLiteNcnn ncnn ${OpenCV_LIBS} ${OpenMP_CXX_LIB_NAMES})
elseif(OCR_OUTPUT STREQUAL "BIN") # C LIB
elseif(OCR_OUTPUT STREQUAL "BIN") # BIN
add_executable(OcrLiteNcnn ${OCR_COMPILE_CODE})
target_compile_definitions(OcrLiteNcnn PRIVATE __EXEC__)
target_link_libraries(OcrLiteNcnn ncnn ${OpenCV_LIBS} ${OpenMP_CXX_LIB_NAMES})
endif ()

install(TARGETS OcrLiteNcnn EXPORT OcrLiteNcnn
ARCHIVE DESTINATION staticlib
LIBRARY DESTINATION sharedlib
RUNTIME DESTINATION bin)
install(TARGETS OcrLiteNcnn EXPORT OcrLiteNcnn)
if (OCR_OUTPUT STREQUAL "CLIB") # CLIB
file(GLOB OCR_INCLUDE ${CMAKE_CURRENT_SOURCE_DIR}/include/*.h)
install(FILES ${OCR_INCLUDE} DESTINATION include)
endif ()

if (OCR_VULKAN STREQUAL "GPU")
target_compile_definitions(OcrLiteNcnn PRIVATE __VULKAN__)
Expand Down
9 changes: 8 additions & 1 deletion cpp_projects/OcrLiteNcnn/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

### 联系方式

QQ①群:994929053 QQ②群:820132154
* QQ①群:994929053
* QQ②群:820132154
* QQ③群:904091319

### Project下载

Expand Down Expand Up @@ -33,6 +35,11 @@ ChineseOcr Lite Ncnn,超轻量级中文OCR PC Demo,支持ncnn推理

### 更新说明

#### 2021-10-25 update

* fix:win编译打包C动态库缺少lib文件
* 编译c动态库添加打包include

#### 2021-10-13 update

* opencv 4.5.4
Expand Down
1 change: 0 additions & 1 deletion cpp_projects/OcrLiteNcnn/build.bat
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ echo.

echo "请注意:如果选择2)JNI动态库时,必须安装配置Oracle JDK"
echo "请选择编译输出类型并回车: 1)BIN可执行文件,2)JNI动态库,3)C动态库"
set BUILD_OUTPUT="EXE"
set /p flag=
if %flag% == 1 (set BUILD_OUTPUT="BIN")^
else if %flag% == 2 (set BUILD_OUTPUT="JNI")^
Expand Down
5 changes: 2 additions & 3 deletions cpp_projects/OcrLiteNcnn/generate-vs-project.bat
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,8 @@ else if %flag% == 2 (set BUILD_NCNN_VULKAN="GPU")^
else (echo "输入错误!Input Error!")
echo.

echo "请注意:如果选择2)编译为JNI动态库时,必须安装配置Oracle JDK"
echo "请选择编译输出类型并回车: 1)编译成可执行文件,2)编译成JNI动态库,3)编译成C动态库"
set BUILD_OUTPUT="EXE"
echo "请注意:如果选择2)JNI动态库时,必须安装配置Oracle JDK"
echo "请选择编译输出类型并回车: 1)BIN可执行文件,2)JNI动态库,3)C动态库"
set /p flag=
if %flag% == 1 (set BUILD_OUTPUT="BIN")^
else if %flag% == 2 (set BUILD_OUTPUT="JNI")^
Expand Down
23 changes: 23 additions & 0 deletions cpp_projects/OcrLiteNcnn/ncnn-static/NcnnWrapperConfig.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
if (APPLE)
set(NCNN_INCLUDE_DIRS "${CMAKE_CURRENT_LIST_DIR}/macos/include")
include_directories(${NCNN_INCLUDE_DIRS})
message("配置macOS ncnn 路径: ${CMAKE_CURRENT_LIST_DIR}/macos/lib/cmake/ncnn")
set(ncnn_DIR "${CMAKE_CURRENT_LIST_DIR}/macos/lib/cmake/ncnn")
elseif (WIN32)
if (CMAKE_CL_64)
message("配置WINDOWS ncnn x64 路径: ${CMAKE_CURRENT_LIST_DIR}/windows-x64/lib/cmake/ncnn")
set(ncnn_DIR "${CMAKE_CURRENT_LIST_DIR}/windows-x64/lib/cmake/ncnn")
set(NCNN_INCLUDE_DIRS "${CMAKE_CURRENT_LIST_DIR}/windows-x64/include")
else ()
message("配置WINDOWS ncnn x86 路径: ${CMAKE_CURRENT_LIST_DIR}/windows-x86/lib/cmake/ncnn")
set(ncnn_DIR "${CMAKE_CURRENT_LIST_DIR}/windows-x86/lib/cmake/ncnn")
set(NCNN_INCLUDE_DIRS "${CMAKE_CURRENT_LIST_DIR}/windows-x86/include")
endif ()
include_directories(${NCNN_INCLUDE_DIRS})
elseif (UNIX)
set(NCNN_INCLUDE_DIRS "${CMAKE_CURRENT_LIST_DIR}/linux/include")
include_directories(${NCNN_INCLUDE_DIRS})
message("配置Linux ncnn 路径: ${CMAKE_CURRENT_LIST_DIR}/linux/lib/cmake/ncnn")
set(ncnn_DIR "${CMAKE_CURRENT_LIST_DIR}/linux/lib/cmake/ncnn")
endif ()

Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
if (APPLE)
set(NCNN_INCLUDE_DIRS "${CMAKE_CURRENT_LIST_DIR}/macos/include")
include_directories(${NCNN_INCLUDE_DIRS})
message("配置macOS ncnn 路径: ${CMAKE_CURRENT_LIST_DIR}/macos/lib/cmake/ncnn")
set(ncnn_DIR "${CMAKE_CURRENT_LIST_DIR}/macos/lib/cmake/ncnn")
elseif (WIN32)
if (CMAKE_CL_64)
message("配置WINDOWS ncnn x64 路径: ${CMAKE_CURRENT_LIST_DIR}/windows-x64/lib/cmake/ncnn")
set(ncnn_DIR "${CMAKE_CURRENT_LIST_DIR}/windows-x64/lib/cmake/ncnn")
set(NCNN_INCLUDE_DIRS "${CMAKE_CURRENT_LIST_DIR}/windows-x64/include")
else ()
message("配置WINDOWS ncnn x86 路径: ${CMAKE_CURRENT_LIST_DIR}/windows-x86/lib/cmake/ncnn")
set(ncnn_DIR "${CMAKE_CURRENT_LIST_DIR}/windows-x86/lib/cmake/ncnn")
set(NCNN_INCLUDE_DIRS "${CMAKE_CURRENT_LIST_DIR}/windows-x86/include")
endif ()
include_directories(${NCNN_INCLUDE_DIRS})
elseif (UNIX)
set(NCNN_INCLUDE_DIRS "${CMAKE_CURRENT_LIST_DIR}/linux/include")
include_directories(${NCNN_INCLUDE_DIRS})
message("配置Linux ncnn 路径: ${CMAKE_CURRENT_LIST_DIR}/linux/lib/cmake/ncnn")
set(ncnn_DIR "${CMAKE_CURRENT_LIST_DIR}/linux/lib/cmake/ncnn")
endif ()

15 changes: 15 additions & 0 deletions cpp_projects/OcrLiteNcnn/opencv-static/OpenCVWrapperConfig.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
if (WIN32)
if (CMAKE_CL_64)
message("配置WINDOWS OpenCV x64 路径: ${CMAKE_CURRENT_LIST_DIR}/windows-x64")
set(OpenCV_DIR "${CMAKE_CURRENT_LIST_DIR}/windows-x64")
else ()
message("配置WINDOWS OpenCV x86 路径: ${CMAKE_CURRENT_LIST_DIR}/windows-x86")
set(OpenCV_DIR "${CMAKE_CURRENT_LIST_DIR}/windows-x86")
endif ()
elseif (APPLE)
message("配置macOS OpenCV 路径: ${CMAKE_CURRENT_LIST_DIR}/macos/lib/cmake/opencv4")
set(OpenCV_DIR "${CMAKE_CURRENT_LIST_DIR}/macos/lib/cmake/opencv4")
elseif (UNIX)
message("配置Linux OpenCV 路径: ${CMAKE_CURRENT_LIST_DIR}/linux/lib/cmake/opencv4")
set(OpenCV_DIR "${CMAKE_CURRENT_LIST_DIR}/linux/lib/cmake/opencv4")
endif ()

0 comments on commit 1469b42

Please sign in to comment.