赞
踩
ChineseOcr Lite Ncnn,超轻量级中文OCR PC Demo,支持ncnn推理;
# 源码下载
git clone https://github.com/opencv/opencv.git
cd opencv
mkdir build && cd build
cmake ..
make -j4
root@kaixuan-PC:/home/kaixuan/Desktop/ocr/ncnn# git clone https://github.com/opencv/opencv.git 正克隆到 'opencv'... remote: Enumerating objects: 331436, done. remote: Counting objects: 100% (230/230), done. remote: Compressing objects: 100% (156/156), done. remote: Total 331436 (delta 103), reused 153 (delta 69), pack-reused 331206 接收对象中: 100% (331436/331436), 521.32 MiB | 2.14 MiB/s, 完成. 处理 delta 中: 100% (231146/231146), 完成. 正在检出文件: 100% (7452/7452), 完成. root@kaixuan-PC:/home/kaixuan/Desktop/ocr/ncnn# ls opencv root@kaixuan-PC:/home/kaixuan/Desktop/ocr/ncnn# cd opencv/ root@kaixuan-PC:/home/kaixuan/Desktop/ocr/ncnn/opencv# ls 3rdparty apps cmake CMakeLists.txt CONTRIBUTING.md COPYRIGHT data doc include LICENSE modules platforms README.md samples SECURITY.md root@kaixuan-PC:/home/kaixuan/Desktop/ocr/ncnn/opencv# mkdir build && cd build root@kaixuan-PC:/home/kaixuan/Desktop/ocr/ncnn/opencv/build# cmake .. -- 'Release' build type is used by default. Use CMAKE_BUILD_TYPE to specify build type (Release or Debug) -- The CXX compiler identification is GNU 8.3.0 -- The C compiler identification is GNU 8.3.0 -- Detecting CXX compiler ABI info -- Detecting CXX compiler ABI info - done -- Check for working CXX compiler: /usr/bin/c++ - skipped ... ... ... long-long -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections -msse -msse2 -msse3 -fvisibility=hidden -g -O0 -DDEBUG -D_DEBUG -- Linker flags (Release): -Wl,--exclude-libs,libippicv.a -Wl,--exclude-libs,libippiw.a -Wl,--gc-sections -Wl,--as-needed -Wl,--no-undefined -- Linker flags (Debug): -Wl,--exclude-libs,libippicv.a -Wl,--exclude-libs,libippiw.a -Wl,--gc-sections -Wl,--as-needed -Wl,--no-undefined -- ccache: NO -- Precompiled headers: NO -- Extra dependencies: dl m pthread rt -- 3rdparty dependencies: -- -- OpenCV modules: -- To be built: calib3d core dnn features2d flann gapi highgui imgcodecs imgproc ml objdetect photo stitching ts video videoio -- Disabled: world -- Disabled by dependency: - -- Unavailable: java python2 python3 -- Applications: tests perf_tests apps -- Documentation: NO -- Non-free algorithms: NO -- -- GUI: NONE -- GTK+: NO -- VTK support: NO -- -- Media I/O: -- ZLib: zlib (ver 1.3.1) -- JPEG: build-libjpeg-turbo (ver 2.1.3-62) -- SIMD Support Request: YES -- SIMD Support: NO -- WEBP: build (ver encoder: 0x020f) -- PNG: build (ver 1.6.37) -- TIFF: build (ver 42 - 4.6.0) -- JPEG 2000: build (ver 2.5.0) -- OpenEXR: build (ver 2.3.0) -- HDR: YES -- SUNRASTER: YES -- PXM: YES -- PFM: YES -- -- Video I/O: -- DC1394: NO -- FFMPEG: NO -- avcodec: NO -- avformat: NO -- avutil: NO -- swscale: NO -- avresample: NO -- GStreamer: NO -- v4l/v4l2: YES (linux/videodev2.h) -- -- Parallel framework: pthreads -- -- Trace: YES (with Intel ITT) -- -- Other third-party libraries: -- Intel IPP: 2021.11.0 [2021.11.0] -- at: /home/kaixuan/Desktop/ocr/ncnn/opencv/build/3rdparty/ippicv/ippicv_lnx/icv -- Intel IPP IW: sources (2021.11.0) -- at: /home/kaixuan/Desktop/ocr/ncnn/opencv/build/3rdparty/ippicv/ippicv_lnx/iw -- VA: NO -- Lapack: NO -- Eigen: NO -- Custom HAL: NO -- Protobuf: build (3.19.1) -- Flatbuffers: builtin/3rdparty (23.5.9) -- -- OpenCL: YES (no extra features) -- Include path: /home/kaixuan/Desktop/ocr/ncnn/opencv/3rdparty/include/opencl/1.2 -- Link libraries: Dynamic load -- -- Python (for build): /usr/bin/python3 -- -- Java: -- ant: NO -- Java: NO -- JNI: NO -- Java wrappers: NO -- Java tests: NO -- -- Install to: /usr/local -- ----------------------------------------------------------------- -- -- Configuring done -- Generating done -- Build files have been written to: /home/kaixuan/Desktop/ocr/ncnn/opencv/build
不同版本ncnn源码下载,ncnn文件存放路径;
OcrLiteNcnn/ncnn-static
├── NcnnWrapperConfig.cmake
├── linux
├── macos
├── windows-x64
└── windows-x86
- Source code (tar.gz):linux源码;
- Source code (zip):windows源码;
- *.7z:编译好的不同平台可执行程序,没有特殊要求可直接使用;
root@kaixuan-PC:/home/kaixuan/Desktop/ocr# cd OcrLiteNcnn-1.8.0/ root@kaixuan-PC:/home/kaixuan/Desktop/ocr/OcrLiteNcnn-1.8.0# ./build.sh ========请先参考README.md准备好编译环境======== ========编译选项======== 请输入编译选项并回车: 1)Release, 2)Debug 1 请选择要使用的ncnn库选项并回车: 1)ncnn(CPU),2)ncnn(vulkan) 1 请注意:如果选择2)JNI动态库时,必须安装配置Oracle JDK 请选择编译输出类型并回车: 1)BIN可执行文件,2)JNI动态库,3)C动态库 1 /home/kaixuan/Desktop/ocr/OcrLiteNcnn-1.8.0/Linux-BIN-CPU /home/kaixuan/Desktop/ocr/OcrLiteNcnn-1.8.0 cmake -DCMAKE_INSTALL_PREFIX=install -DCMAKE_BUILD_TYPE=Release -DOCR_OUTPUT=BIN -DOCR_VULKAN=CPU .. -- The C compiler identification is GNU 8.3.0 -- The CXX compiler identification is GNU 8.3.0 -- Detecting C compiler ABI info -- Detecting C compiler ABI info - done -- Check for working C compiler: /usr/bin/cc - skipped -- Detecting C compile features -- Detecting C compile features - done -- Detecting CXX compiler ABI info -- Detecting CXX compiler ABI info - done -- Check for working CXX compiler: /usr/bin/c++ - skipped -- Detecting CXX compile features -- Detecting CXX compile features - done 配置Linux ncnn 路径: /home/kaixuan/Desktop/ocr/OcrLiteNcnn-1.8.0/ncnn-static/linux/lib/cmake/ncnn -- Looking for pthread.h -- Looking for pthread.h - found -- Performing Test CMAKE_HAVE_LIBC_PTHREAD -- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Failed -- Check if compiler accepts -pthread -- Check if compiler accepts -pthread - yes -- Found Threads: TRUE -- ncnn Found! 配置Linux OpenCV 路径: /home/kaixuan/Desktop/ocr/OcrLiteNcnn-1.8.0/opencv-static/linux/lib/cmake/opencv4 -- Found OpenCV: /usr/local (found version "4.9.0") -- OpenCV_LIBS: opencv_calib3d;opencv_core;opencv_dnn;opencv_features2d;opencv_flann;opencv_gapi;opencv_highgui;opencv_imgcodecs;opencv_imgproc;opencv_ml;opencv_objdetect;opencv_photo;opencv_stitching;opencv_video;opencv_videoio -- OpenCV_INCLUDE_DIRS: /usr/local/include/opencv4 -- Configuring done -- Generating done -- Build files have been written to: /home/kaixuan/Desktop/ocr/OcrLiteNcnn-1.8.0/Linux-BIN-CPU Scanning dependencies of target benchmark Scanning dependencies of target OcrLiteNcnn [ 9%] Building CXX object CMakeFiles/benchmark.dir/benchmark/benchmark.cpp.o ... ... ... [100%] Built target OcrLiteNcnn Install the project... -- Install configuration: "Release" -- Installing: /home/kaixuan/Desktop/ocr/OcrLiteNcnn-1.8.0/Linux-BIN-CPU/install/bin/OcrLiteNcnn -- Set runtime path of "/home/kaixuan/Desktop/ocr/OcrLiteNcnn-1.8.0/Linux-BIN-CPU/install/bin/OcrLiteNcnn" to "" -- Installing: /home/kaixuan/Desktop/ocr/OcrLiteNcnn-1.8.0/Linux-BIN-CPU/install/bin/benchmark -- Set runtime path of "/home/kaixuan/Desktop/ocr/OcrLiteNcnn-1.8.0/Linux-BIN-CPU/install/bin/benchmark" to "" /home/kaixuan/Desktop/ocr/OcrLiteNcnn-1.8.0 kaixuan@kaixuan-PC:~/Desktop/ocr/OcrLiteNcnn-1.8.0$ cd Linux-BIN-CPU/ kaixuan@kaixuan-PC:~/Desktop/ocr/OcrLiteNcnn-1.8.0/Linux-BIN-CPU$ ls benchmark CMakeCache.txt CMakeFiles cmake_install.cmake install install_manifest.txt Makefile OcrLiteNcnn
./OcrLiteNcnn
-d /home/kaixuan/Desktop/ocr/models-1.8
-i /home/kaixuan/Desktop/ocr/1111.jpeg
-f /home/kaixuan/Desktop/ocr/1212.txt
OcrLiteNcnn:编译结果文件
-d:模型文件所在目录
-i:需要识别的图片
-f:识别结果输出文件
kaixuan@kaixuan-PC:~/Desktop/ocr/OcrLiteNcnn-1.8.0$ cd Linux-BIN-CPU/ kaixuan@kaixuan-PC:~/Desktop/ocr/OcrLiteNcnn-1.8.0/Linux-BIN-CPU$ ./OcrLiteNcnn -d /home/kaixuan/Desktop/ocr/models-1.8 -i /home/kaixuan/Desktop/ocr/1111.jpeg -f /home/kaixuan/Desktop/ocr/1212.txt 秘密10年 东海市文件 签发: 东文[2019129号 关于检测文件是否为模板的测试 第一条为了保护民事主体的合法权益,调整民事关 系,维护社会和经济秩序,适应中国特色社会主义发展要求, 弘扬社会主义核心价值观,根据宪法,制定本法。 第二条民法调整平等主体的自然人、法人和非法人组 织之间的人身关系和财产关系。 第三条 民事主体的人身权利、财产权利以及其他合法 权益受法律保护,任何组织或者个人不得侵犯。 第四条民事主体在民事活动中的法律地位一律平等。 第五条民事主体从事民事活动,应当遵循自愿原则 按照自己的意思设立、变更、终止民事法律关系 第六条 民事主体从事民事活动,应当遵循公平原则 合理确定各方的权利和义务。
小编使用识别模型(OcrLiteNcnn-models-1.8.rar)
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。