mirror of
https://github.com/HIllya51/LunaTranslator.git
synced 2024-12-26 23:24:13 +08:00
fix
This commit is contained in:
parent
15e5315e83
commit
cfd96256fc
33
.github/scripts/build_lunatranslator.py
vendored
33
.github/scripts/build_lunatranslator.py
vendored
@ -205,7 +205,7 @@ def buildPlugins(arch):
|
|||||||
f"cmake --build ../build/x86 --config Release --target ALL_BUILD -j 14"
|
f"cmake --build ../build/x86 --config Release --target ALL_BUILD -j 14"
|
||||||
)
|
)
|
||||||
# subprocess.run(f"python copytarget.py 1")
|
# subprocess.run(f"python copytarget.py 1")
|
||||||
elif arch=='x64':
|
elif arch == "x64":
|
||||||
subprocess.run(
|
subprocess.run(
|
||||||
f'cmake ../CMakeLists.txt -G "Visual Studio 17 2022" -A x64 -T host=x64 -B ../build/x64 -DCMAKE_SYSTEM_VERSION=10.0.26621.0'
|
f'cmake ../CMakeLists.txt -G "Visual Studio 17 2022" -A x64 -T host=x64 -B ../build/x64 -DCMAKE_SYSTEM_VERSION=10.0.26621.0'
|
||||||
)
|
)
|
||||||
@ -213,19 +213,21 @@ def buildPlugins(arch):
|
|||||||
f"cmake --build ../build/x64 --config Release --target ALL_BUILD -j 14"
|
f"cmake --build ../build/x64 --config Release --target ALL_BUILD -j 14"
|
||||||
)
|
)
|
||||||
# subprocess.run(f"python copytarget.py 0")
|
# subprocess.run(f"python copytarget.py 0")
|
||||||
elif arch=='xp':
|
elif arch == "xp":
|
||||||
url = "https://github.com/Chuyu-Team/YY-Thunks/releases/download/v1.0.7/YY-Thunks-1.0.7-Binary.zip"
|
url = "https://github.com/Chuyu-Team/YY-Thunks/releases/download/v1.0.7/YY-Thunks-1.0.7-Binary.zip"
|
||||||
os.system(rf"curl -SLo YY-Thunks-1.0.7-Binary.zip " + url)
|
os.system(rf"curl -SLo YY-Thunks-1.0.7-Binary.zip " + url)
|
||||||
os.system(rf"7z x -y YY-Thunks-1.0.7-Binary.zip -o../libs/YY-Thunks")
|
os.system(rf"7z x -y YY-Thunks-1.0.7-Binary.zip -o../libs/YY-Thunks")
|
||||||
with open("do.bat", "w") as ff:
|
with open("do.bat", "w") as ff:
|
||||||
ff.write(
|
ff.write(
|
||||||
rf"""
|
rf"""
|
||||||
|
|
||||||
cmake -DWINXP=ON ../CMakeLists.txt -G "Visual Studio 16 2019" -A win32 -T v141_xp -B ../build/x86_xp
|
cmake -DWINXP=ON ../CMakeLists.txt -G "Visual Studio 16 2019" -A win32 -T v141_xp -B ../build/x86_xp
|
||||||
cmake --build ../build/x86_xp --config Release --target ALL_BUILD -j 14
|
cmake --build ../build/x86_xp --config Release --target ALL_BUILD -j 14
|
||||||
"""
|
"""
|
||||||
)
|
)
|
||||||
os.system(f"cmd /c do.bat")
|
os.system(f"cmd /c do.bat")
|
||||||
|
|
||||||
|
|
||||||
def downloadsomething():
|
def downloadsomething():
|
||||||
pass
|
pass
|
||||||
# shutil.rmtree(rootDir + "\\files\\LunaTranslator_qss\\.git")
|
# shutil.rmtree(rootDir + "\\files\\LunaTranslator_qss\\.git")
|
||||||
@ -280,10 +282,31 @@ if __name__ == "__main__":
|
|||||||
downloadLocaleEmulator()
|
downloadLocaleEmulator()
|
||||||
downloadNtlea()
|
downloadNtlea()
|
||||||
downloadCurl()
|
downloadCurl()
|
||||||
downloadOCRModel()
|
if arch != "xp":
|
||||||
|
downloadOCRModel()
|
||||||
downloadcommon()
|
downloadcommon()
|
||||||
downloadbass()
|
downloadbass()
|
||||||
os.chdir(rootDir)
|
os.chdir(rootDir)
|
||||||
|
if arch == "xp":
|
||||||
|
shutil.copytree(
|
||||||
|
f"{rootDir}/../build/cpp_xp",
|
||||||
|
f"{rootDir}/../cpp/builds",
|
||||||
|
dirs_exist_ok=True,
|
||||||
|
)
|
||||||
|
shutil.copytree(
|
||||||
|
f"{rootDir}/../build/hook_xp",
|
||||||
|
f"{rootDir}/files/plugins/LunaHook",
|
||||||
|
dirs_exist_ok=True,
|
||||||
|
)
|
||||||
|
os.chdir(rootDir + "/../cpp/scripts")
|
||||||
|
os.makedirs("../../py/files/plugins/DLL32", exist_ok=True)
|
||||||
|
shutil.copy("../builds/_x86/shareddllproxy32.exe", "../../py/files/plugins")
|
||||||
|
shutil.copy(
|
||||||
|
"../builds/_x86/winsharedutils32.dll", "../../py/files/plugins/DLL32"
|
||||||
|
)
|
||||||
|
os.chdir(rootDir)
|
||||||
|
os.system(f"python {os.path.join(rootthisfiledir,'collectall_xp.py')}")
|
||||||
|
exit()
|
||||||
shutil.copytree(
|
shutil.copytree(
|
||||||
f"{rootDir}/../build/hook_64",
|
f"{rootDir}/../build/hook_64",
|
||||||
f"{rootDir}/files/plugins/LunaHook",
|
f"{rootDir}/files/plugins/LunaHook",
|
||||||
|
7
.github/scripts/collectall.py
vendored
7
.github/scripts/collectall.py
vendored
@ -3,13 +3,6 @@ import platform
|
|||||||
import sys
|
import sys
|
||||||
from importanalysis import importanalysis
|
from importanalysis import importanalysis
|
||||||
|
|
||||||
rootDir = os.path.dirname(__file__)
|
|
||||||
if not rootDir:
|
|
||||||
rootDir = os.path.abspath(".")
|
|
||||||
else:
|
|
||||||
rootDir = os.path.abspath(rootDir)
|
|
||||||
rootthisfiledir=rootDir
|
|
||||||
rootDir=os.path.abspath(os.path.join(rootDir,'../../py'))
|
|
||||||
x86 = platform.architecture()[0] == "32bit"
|
x86 = platform.architecture()[0] == "32bit"
|
||||||
if sys.argv[1] == "32":
|
if sys.argv[1] == "32":
|
||||||
targetdir = r"build\LunaTranslator_x86"
|
targetdir = r"build\LunaTranslator_x86"
|
||||||
|
44
.github/scripts/collectall_xp.py
vendored
Normal file
44
.github/scripts/collectall_xp.py
vendored
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
import shutil, os
|
||||||
|
import platform
|
||||||
|
import sys
|
||||||
|
|
||||||
|
os.system("git clone https://github.com/HIllya51/py3.4_pyqt5.5.1")
|
||||||
|
os.rename("py3.4_pyqt5.5.1", "runtime")
|
||||||
|
targetdir = r"build\LunaTranslator_x86_winxp"
|
||||||
|
launch = r"..\cpp\builds\_x86"
|
||||||
|
baddll = "DLL64"
|
||||||
|
|
||||||
|
|
||||||
|
def copycheck(src, tgt):
|
||||||
|
print(src, tgt, os.path.exists(src))
|
||||||
|
if not os.path.exists(src):
|
||||||
|
return
|
||||||
|
if src.lower().endswith("_ssl.pyd"):
|
||||||
|
return
|
||||||
|
if not os.path.exists(tgt):
|
||||||
|
os.makedirs(tgt, exist_ok=True)
|
||||||
|
if os.path.isdir(src):
|
||||||
|
tgt = os.path.join(tgt, os.path.basename(src))
|
||||||
|
if os.path.exists(tgt):
|
||||||
|
shutil.rmtree(tgt)
|
||||||
|
shutil.copytree(src, tgt)
|
||||||
|
return
|
||||||
|
shutil.copy(src, tgt)
|
||||||
|
|
||||||
|
|
||||||
|
copycheck(os.path.join(launch, "LunaTranslator.exe"), targetdir)
|
||||||
|
copycheck(os.path.join(launch, "LunaTranslator_debug.exe"), targetdir)
|
||||||
|
copycheck("./LunaTranslator", targetdir)
|
||||||
|
copycheck(r".\files", targetdir)
|
||||||
|
copycheck("runtime", targetdir + "/files")
|
||||||
|
try:
|
||||||
|
shutil.rmtree(rf"{targetdir}\files\plugins\{baddll}")
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
shutil.copy(r"..\LICENSE", targetdir)
|
||||||
|
|
||||||
|
target = os.path.basename(targetdir)
|
||||||
|
os.chdir(os.path.dirname(targetdir))
|
||||||
|
if os.path.exists(rf"{target}.zip"):
|
||||||
|
os.remove(rf"{target}.zip")
|
||||||
|
os.system(rf'"C:\Program Files\7-Zip\7z.exe" a -m0=Deflate -mx9 {target}.zip {target}')
|
17
.github/workflows/buildluna.yml
vendored
17
.github/workflows/buildluna.yml
vendored
@ -117,4 +117,19 @@ jobs:
|
|||||||
- uses: actions/upload-artifact@v4
|
- uses: actions/upload-artifact@v4
|
||||||
with:
|
with:
|
||||||
name: ${{ matrix.fname }}
|
name: ${{ matrix.fname }}
|
||||||
path: py/build/${{matrix.fname}}.zip
|
path: py/build/${{matrix.fname}}.zip
|
||||||
|
merge_xp:
|
||||||
|
runs-on: windows-latest
|
||||||
|
needs: [build_cpp_xp,hook_xp]
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
- run: git submodule init py/files/LunaTranslator_qss
|
||||||
|
- run: git submodule update py/files/LunaTranslator_qss
|
||||||
|
- uses: actions/download-artifact@v4
|
||||||
|
with:
|
||||||
|
path: build
|
||||||
|
- run: python .github/scripts/build_lunatranslator.py merge xp
|
||||||
|
- uses: actions/upload-artifact@v4
|
||||||
|
with:
|
||||||
|
name: LunaTranslator_x86_winxp
|
||||||
|
path: py/build/LunaTranslator_x86_winxp.zip
|
1
.gitignore
vendored
1
.gitignore
vendored
@ -48,3 +48,4 @@ cpp/libs/opencv-static/opencv-static.7z
|
|||||||
cpp/LunaHook/.vscode/settings.json
|
cpp/LunaHook/.vscode/settings.json
|
||||||
cpp/LunaHook/scripts/YY-Thunks-1.0.7-Binary.zip
|
cpp/LunaHook/scripts/YY-Thunks-1.0.7-Binary.zip
|
||||||
cpp/libs/YY-Thunks
|
cpp/libs/YY-Thunks
|
||||||
|
py/LunaTranslator/.vscode/settings.json
|
||||||
|
@ -34,10 +34,10 @@ target_precompile_headers(pch PUBLIC pch.h)
|
|||||||
|
|
||||||
add_subdirectory(exec)
|
add_subdirectory(exec)
|
||||||
add_subdirectory(winsharedutils)
|
add_subdirectory(winsharedutils)
|
||||||
add_subdirectory(hookmagpie)
|
|
||||||
add_subdirectory(shareddllproxy)
|
add_subdirectory(shareddllproxy)
|
||||||
|
if(NOT WINXP)
|
||||||
|
add_subdirectory(hookmagpie)
|
||||||
add_subdirectory(LunaOCR)
|
add_subdirectory(LunaOCR)
|
||||||
add_subdirectory(winrtutils)
|
add_subdirectory(winrtutils)
|
||||||
if(NOT WINXP)
|
|
||||||
add_subdirectory(wcocr)
|
add_subdirectory(wcocr)
|
||||||
endif()
|
endif()
|
@ -1,12 +1,3 @@
|
|||||||
|
|
||||||
enum class Directional
|
|
||||||
{
|
|
||||||
H,
|
|
||||||
V,
|
|
||||||
Auto
|
|
||||||
};
|
|
||||||
|
|
||||||
#ifndef WINXP
|
|
||||||
#include <onnxruntime/core/session/onnxruntime_cxx_api.h>
|
#include <onnxruntime/core/session/onnxruntime_cxx_api.h>
|
||||||
#include <opencv2/opencv.hpp>
|
#include <opencv2/opencv.hpp>
|
||||||
#include <opencv2/imgproc.hpp>
|
#include <opencv2/imgproc.hpp>
|
||||||
@ -15,6 +6,13 @@ enum class Directional
|
|||||||
typedef std::vector<cv::Point> TextBox;
|
typedef std::vector<cv::Point> TextBox;
|
||||||
typedef std::string TextLine;
|
typedef std::string TextLine;
|
||||||
typedef std::pair<TextBox, TextLine> TextBlock;
|
typedef std::pair<TextBox, TextLine> TextBlock;
|
||||||
|
enum class Directional
|
||||||
|
{
|
||||||
|
H,
|
||||||
|
V,
|
||||||
|
Auto
|
||||||
|
};
|
||||||
|
|
||||||
struct ScaleParam
|
struct ScaleParam
|
||||||
{
|
{
|
||||||
int srcWidth;
|
int srcWidth;
|
||||||
@ -705,16 +703,13 @@ std::vector<TextBlock> OcrLite::detect_internal(cv::Mat &src, cv::Rect &originRe
|
|||||||
|
|
||||||
return textBlocks;
|
return textBlocks;
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
struct OcrLite;
|
|
||||||
#endif
|
|
||||||
struct ocrpoints
|
struct ocrpoints
|
||||||
{
|
{
|
||||||
int x1, y1, x2, y2, x3, y3, x4, y4;
|
int x1, y1, x2, y2, x3, y3, x4, y4;
|
||||||
};
|
};
|
||||||
DECLARE_API OcrLite *OcrInit(const wchar_t *szDetModel, const wchar_t *szRecModel, const wchar_t *szKeyPath, int nThreads)
|
DECLARE_API OcrLite *OcrInit(const wchar_t *szDetModel, const wchar_t *szRecModel, const wchar_t *szKeyPath, int nThreads)
|
||||||
{
|
{
|
||||||
#ifndef WINXP
|
|
||||||
OcrLite *pOcrObj = nullptr;
|
OcrLite *pOcrObj = nullptr;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@ -731,14 +726,10 @@ DECLARE_API OcrLite *OcrInit(const wchar_t *szDetModel, const wchar_t *szRecMode
|
|||||||
{
|
{
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
return nullptr;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
DECLARE_API void OcrDetect(OcrLite *pOcrObj, const void *binptr, size_t size, Directional mode, void (*cb)(ocrpoints, const char *))
|
DECLARE_API void OcrDetect(OcrLite *pOcrObj, const void *binptr, size_t size, Directional mode, void (*cb)(ocrpoints, const char *))
|
||||||
{
|
{
|
||||||
#ifndef WINXP
|
|
||||||
if (!pOcrObj)
|
if (!pOcrObj)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -758,13 +749,10 @@ DECLARE_API void OcrDetect(OcrLite *pOcrObj, const void *binptr, size_t size, Di
|
|||||||
catch (...)
|
catch (...)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
DECLARE_API void OcrDestroy(OcrLite *pOcrObj)
|
DECLARE_API void OcrDestroy(OcrLite *pOcrObj)
|
||||||
{
|
{
|
||||||
#ifndef WINXP
|
|
||||||
if (pOcrObj)
|
if (pOcrObj)
|
||||||
delete pOcrObj;
|
delete pOcrObj;
|
||||||
#endif
|
|
||||||
}
|
}
|
@ -74,7 +74,7 @@ bool PyStand::CheckEnviron(const wchar_t *rtp)
|
|||||||
MessageBoxW(NULL, msg.c_str(), L"ERROR", MB_OK);
|
MessageBoxW(NULL, msg.c_str(), L"ERROR", MB_OK);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
#ifndef WINXP
|
||||||
// check python3.dll
|
// check python3.dll
|
||||||
if (!PathFileExistsW((_runtime + L"\\python3.dll").c_str()))
|
if (!PathFileExistsW((_runtime + L"\\python3.dll").c_str()))
|
||||||
{
|
{
|
||||||
@ -82,7 +82,14 @@ bool PyStand::CheckEnviron(const wchar_t *rtp)
|
|||||||
MessageBoxW(NULL, msg.c_str(), L"ERROR", MB_OK);
|
MessageBoxW(NULL, msg.c_str(), L"ERROR", MB_OK);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
if (!PathFileExistsW((_runtime + L"\\python34.dll").c_str()))
|
||||||
|
{
|
||||||
|
std::wstring msg = L"Missing python34.dll in:\r\n" + _runtime;
|
||||||
|
MessageBoxW(NULL, msg.c_str(), L"ERROR", MB_OK);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
// setup environment
|
// setup environment
|
||||||
SetEnvironmentVariableW(L"PYSTAND", _pystand.c_str());
|
SetEnvironmentVariableW(L"PYSTAND", _pystand.c_str());
|
||||||
SetEnvironmentVariableW(L"PYSTAND_HOME", _home.c_str());
|
SetEnvironmentVariableW(L"PYSTAND_HOME", _home.c_str());
|
||||||
@ -117,7 +124,11 @@ bool PyStand::LoadPython()
|
|||||||
// python dll must be load under "runtime"
|
// python dll must be load under "runtime"
|
||||||
SetCurrentDirectoryW(runtime.c_str());
|
SetCurrentDirectoryW(runtime.c_str());
|
||||||
// LoadLibrary
|
// LoadLibrary
|
||||||
|
#ifndef WINXP
|
||||||
_hDLL = (HINSTANCE)LoadLibraryA("python3.dll");
|
_hDLL = (HINSTANCE)LoadLibraryA("python3.dll");
|
||||||
|
#else
|
||||||
|
_hDLL = (HINSTANCE)LoadLibraryA("python34.dll");
|
||||||
|
#endif
|
||||||
if (_hDLL)
|
if (_hDLL)
|
||||||
{
|
{
|
||||||
_Py_Main = (t_Py_Main)GetProcAddress(_hDLL, "Py_Main");
|
_Py_Main = (t_Py_Main)GetProcAddress(_hDLL, "Py_Main");
|
||||||
|
@ -12,9 +12,7 @@ generate_product_version(
|
|||||||
|
|
||||||
add_library(winrtutils MODULE winrtsnapshot.cpp winrtocr.cpp livecaptions.cpp ${versioninfo})
|
add_library(winrtutils MODULE winrtsnapshot.cpp winrtocr.cpp livecaptions.cpp ${versioninfo})
|
||||||
target_precompile_headers(winrtutils REUSE_FROM pch)
|
target_precompile_headers(winrtutils REUSE_FROM pch)
|
||||||
if(NOT WINXP)
|
|
||||||
target_link_libraries(winrtutils wil)
|
target_link_libraries(winrtutils wil)
|
||||||
endif()
|
|
||||||
if(${CMAKE_SIZEOF_VOID_P} EQUAL 8)
|
if(${CMAKE_SIZEOF_VOID_P} EQUAL 8)
|
||||||
set_target_properties(winrtutils PROPERTIES OUTPUT_NAME "winrtutils64")
|
set_target_properties(winrtutils PROPERTIES OUTPUT_NAME "winrtutils64")
|
||||||
else()
|
else()
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
#ifndef WINXP
|
|
||||||
// https://github.com/corbamico/get-livecaptions-cpp/
|
// https://github.com/corbamico/get-livecaptions-cpp/
|
||||||
#include <sdkddkver.h>
|
#include <sdkddkver.h>
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
@ -61,10 +60,8 @@ public:
|
|||||||
return FindWindowW(L"LiveCaptionsDesktopWindow", nullptr) != NULL;
|
return FindWindowW(L"LiveCaptionsDesktopWindow", nullptr) != NULL;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
#endif
|
|
||||||
DECLARE_API HANDLE livecaption_start(void (*cb)(const wchar_t *))
|
DECLARE_API HANDLE livecaption_start(void (*cb)(const wchar_t *))
|
||||||
{
|
{
|
||||||
#ifndef WINXP
|
|
||||||
auto mutex = CreateSemaphoreW(NULL, 0, 1, NULL);
|
auto mutex = CreateSemaphoreW(NULL, 0, 1, NULL);
|
||||||
auto flag = new int{1};
|
auto flag = new int{1};
|
||||||
std::thread([=]()
|
std::thread([=]()
|
||||||
@ -93,21 +90,13 @@ DECLARE_API HANDLE livecaption_start(void (*cb)(const wchar_t *))
|
|||||||
delete flag; })
|
delete flag; })
|
||||||
.detach();
|
.detach();
|
||||||
return mutex;
|
return mutex;
|
||||||
#else
|
|
||||||
return NULL;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
DECLARE_API void livecaption_stop(HANDLE m)
|
DECLARE_API void livecaption_stop(HANDLE m)
|
||||||
{
|
{
|
||||||
#ifndef WINXP
|
|
||||||
ReleaseSemaphore(m, 1, NULL);
|
ReleaseSemaphore(m, 1, NULL);
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
DECLARE_API bool livecaption_isrunning()
|
DECLARE_API bool livecaption_isrunning()
|
||||||
{
|
{
|
||||||
#ifndef WINXP
|
|
||||||
return Engine::is_livecaption_running();
|
return Engine::is_livecaption_running();
|
||||||
#else
|
|
||||||
return false;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
@ -1,5 +1,3 @@
|
|||||||
|
|
||||||
#ifndef WINXP
|
|
||||||
#include <winrt/Windows.Foundation.h>
|
#include <winrt/Windows.Foundation.h>
|
||||||
#include <winrt/Windows.Storage.Pickers.h>
|
#include <winrt/Windows.Storage.Pickers.h>
|
||||||
#include <winrt/Windows.Storage.Streams.h>
|
#include <winrt/Windows.Storage.Streams.h>
|
||||||
@ -27,10 +25,8 @@ using namespace Windows::Media::Devices;
|
|||||||
using namespace Windows::Security::Cryptography;
|
using namespace Windows::Security::Cryptography;
|
||||||
using namespace Windows::Globalization;
|
using namespace Windows::Globalization;
|
||||||
using namespace Windows::Foundation::Collections;
|
using namespace Windows::Foundation::Collections;
|
||||||
#endif
|
|
||||||
DECLARE_API bool check_language_valid(wchar_t *language)
|
DECLARE_API bool check_language_valid(wchar_t *language)
|
||||||
{
|
{
|
||||||
#ifndef WINXP
|
|
||||||
OcrEngine ocrEngine = OcrEngine::TryCreateFromUserProfileLanguages();
|
OcrEngine ocrEngine = OcrEngine::TryCreateFromUserProfileLanguages();
|
||||||
std::wstring l = language;
|
std::wstring l = language;
|
||||||
try
|
try
|
||||||
@ -42,13 +38,9 @@ DECLARE_API bool check_language_valid(wchar_t *language)
|
|||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
return false;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
DECLARE_API void getlanguagelist(void (*cb)(LPCWSTR))
|
DECLARE_API void getlanguagelist(void (*cb)(LPCWSTR))
|
||||||
{
|
{
|
||||||
#ifndef WINXP
|
|
||||||
OcrEngine ocrEngine = OcrEngine::TryCreateFromUserProfileLanguages();
|
OcrEngine ocrEngine = OcrEngine::TryCreateFromUserProfileLanguages();
|
||||||
auto languages = ocrEngine.AvailableRecognizerLanguages();
|
auto languages = ocrEngine.AvailableRecognizerLanguages();
|
||||||
|
|
||||||
@ -57,11 +49,9 @@ DECLARE_API void getlanguagelist(void (*cb)(LPCWSTR))
|
|||||||
auto lang = language.LanguageTag();
|
auto lang = language.LanguageTag();
|
||||||
cb(lang.c_str());
|
cb(lang.c_str());
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
DECLARE_API void OCR(void *ptr, size_t size, wchar_t *lang, wchar_t *space, void (*cb)(int, int, int, int, LPCWSTR))
|
DECLARE_API void OCR(void *ptr, size_t size, wchar_t *lang, wchar_t *space, void (*cb)(int, int, int, int, LPCWSTR))
|
||||||
{
|
{
|
||||||
#ifndef WINXP
|
|
||||||
IBuffer buffer = CryptographicBuffer::CreateFromByteArray(
|
IBuffer buffer = CryptographicBuffer::CreateFromByteArray(
|
||||||
winrt::array_view<uint8_t>(static_cast<uint8_t *>(ptr), size));
|
winrt::array_view<uint8_t>(static_cast<uint8_t *>(ptr), size));
|
||||||
InMemoryRandomAccessStream memoryStream;
|
InMemoryRandomAccessStream memoryStream;
|
||||||
@ -94,5 +84,4 @@ DECLARE_API void OCR(void *ptr, size_t size, wchar_t *lang, wchar_t *space, void
|
|||||||
}
|
}
|
||||||
cb(x1, y1, x2, y2, xx.c_str());
|
cb(x1, y1, x2, y2, xx.c_str());
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,4 @@
|
|||||||
|
#include <dxgi.h>
|
||||||
#ifndef WINXP
|
|
||||||
#include <dxgi.h>
|
|
||||||
#include <inspectable.h>
|
#include <inspectable.h>
|
||||||
#include <dxgi1_2.h>
|
#include <dxgi1_2.h>
|
||||||
#include <d3d11.h>
|
#include <d3d11.h>
|
||||||
@ -205,10 +203,8 @@ void capture_window(HWND window_handle, void (*cb)(byte *, size_t))
|
|||||||
memcpy(ptr, p_buf.get(), l_bmp_info.bmiHeader.biSizeImage);
|
memcpy(ptr, p_buf.get(), l_bmp_info.bmiHeader.biSizeImage);
|
||||||
cb(p_buf2.get(), bmfh.bfSize);
|
cb(p_buf2.get(), bmfh.bfSize);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
DECLARE_API void winrt_capture_window(HWND hwnd, void (*cb)(byte *, size_t))
|
DECLARE_API void winrt_capture_window(HWND hwnd, void (*cb)(byte *, size_t))
|
||||||
{
|
{
|
||||||
#ifndef WINXP
|
|
||||||
// auto hwnd = GetForegroundWindow();// FindWindow(L"Window_Magpie_967EB565-6F73-4E94-AE53-00CC42592A22", 0);
|
// auto hwnd = GetForegroundWindow();// FindWindow(L"Window_Magpie_967EB565-6F73-4E94-AE53-00CC42592A22", 0);
|
||||||
auto style_ex = GetWindowLong(hwnd, GWL_EXSTYLE);
|
auto style_ex = GetWindowLong(hwnd, GWL_EXSTYLE);
|
||||||
auto style_ex_save = style_ex;
|
auto style_ex_save = style_ex;
|
||||||
@ -224,5 +220,4 @@ DECLARE_API void winrt_capture_window(HWND hwnd, void (*cb)(byte *, size_t))
|
|||||||
capture_window(hwnd, cb);
|
capture_window(hwnd, cb);
|
||||||
if (needset)
|
if (needset)
|
||||||
SetWindowLong(hwnd, GWL_EXSTYLE, style_ex_save);
|
SetWindowLong(hwnd, GWL_EXSTYLE, style_ex_save);
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user