From f2b461bde62acafc47b3c769bd25b49d0ec5d101 Mon Sep 17 00:00:00 2001 From: Hao Guan <10684225+hguandl@users.noreply.github.com> Date: Fri, 7 Oct 2022 04:53:50 +1000 Subject: [PATCH] feat: use VisionOCR for apple platform --- .gitmodules | 3 +++ 3rdparty/VisionOCR | 1 + CMakeLists.txt | 12 +++++++++++- src/Python/asst.py | 4 ++++ 4 files changed, 19 insertions(+), 1 deletion(-) create mode 160000 3rdparty/VisionOCR diff --git a/.gitmodules b/.gitmodules index 880d4118f7..358c602a99 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,6 @@ [submodule "test"] path = test url = https://github.com/MaaAssistantArknights/MaaTestSet.git +[submodule "3rdparty/VisionOCR"] + path = 3rdparty/VisionOCR + url = https://github.com/hguandl/VisionOCR.git diff --git a/3rdparty/VisionOCR b/3rdparty/VisionOCR new file mode 160000 index 0000000000..cd18ce5e00 --- /dev/null +++ b/3rdparty/VisionOCR @@ -0,0 +1 @@ +Subproject commit cd18ce5e00e40436b5b207beab4ff0cdb8e7b74e diff --git a/CMakeLists.txt b/CMakeLists.txt index b3f751bab2..992d9b3883 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -55,7 +55,17 @@ else () target_link_libraries(MeoAssistant range-v3::range-v3) endif () - target_link_libraries(MeoAssistant ppocr paddle_inference protobuf cryptopp gflags glog utf8proc xxhash iomp5 mkldnn mklml_intel) + if (APPLE) + add_subdirectory(3rdparty/VisionOCR) + target_link_libraries(MeoAssistant + vnocr + "-framework CoreFoundation" + "-framework CoreGraphics" + "-framework Vision" + ) + else () + target_link_libraries(MeoAssistant ppocr paddle_inference protobuf cryptopp gflags glog utf8proc xxhash iomp5 mkldnn mklml_intel) + endif (APPLE) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -idirafter ${PROJECT_SOURCE_DIR}/3rdparty/include") endif () diff --git a/src/Python/asst.py b/src/Python/asst.py index 8468acf737..95abd3b3ea 100644 --- a/src/Python/asst.py +++ b/src/Python/asst.py @@ -34,6 +34,10 @@ class Asst: Asst.__libpath = pathlib.Path(path) / 'MeoAssistant.dll' os.environ["PATH"] += os.pathsep + str(path) Asst.__lib = ctypes.WinDLL(str(Asst.__libpath)) + if platform.system().lower() == 'darwin': + Asst.__libpath = pathlib.Path(path) / 'libMeoAssistant.dylib' + os.environ['DYLD_LIBRARY_PATH'] += os.pathsep + str(path) + Asst.__lib = ctypes.CDLL(str(Asst.__libpath)) else: Asst.__libpath = pathlib.Path(path) / 'libMeoAssistant.so' os.environ['LD_LIBRARY_PATH'] += os.pathsep + str(path)