Replies: 3 comments 7 replies
-
|
If you build with OCR support, you should see in Settings → Options → OCR the option Enable OCR. If that is checked, OCR is enabled. The first time it's enabled, you will need to wait a bit to download the model, but once that's done it should just work. You can click the Eye icon on the bottom right of the OSC to go into OCR mode which will allow you to select an area to scan. You can also use Ctrl+D to enter OCR mode. Text will be searched in the search box on the side. I wouldn't say it's experimental, but it's not something I recommend most people use because linking C++ to Python is pretty sketchy in terms of reliability. It also uses a lot of RAM. I hardly ever use it, but sometimes I pair it with mpv-manga-reader and just OCR text, though I'm sure better options exist. |
Beta Was this translation helpful? Give feedback.
-
|
arf I had commented out the How can I tell memento where to find libmocr-populate ? I have it built with nix: memento wants to build libmocr but it's not possible to fetch arbitrary code in a nix sandbox. Is there a cmake flag to tell memento where to find it ? |
Beta Was this translation helpful? Give feedback.
-
|
For what you want to do, you'll need to modify the CMake to be something like this. diff --git a/CMakeLists.txt b/CMakeLists.txt
index 790e371..fc82d08 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -139,6 +139,9 @@ if(MECAB_SUPPORT)
find_package(MeCab REQUIRED)
endif()
find_package(mpv REQUIRED)
+if(OCR_SUPPORT)
+ find_package(mocr REQUIRED)
+endif()
find_package(SQLite3 REQUIRED)
if(UNIX AND NOT APPLE) # Linux and Unix
find_package(
diff --git a/cmake/Findmocr.cmake b/cmake/Findmocr.cmake
new file mode 100644
index 0000000..04a6800
--- /dev/null
+++ b/cmake/Findmocr.cmake
@@ -0,0 +1,40 @@
+include(FindPackageHandleStandardArgs)
+
+find_library(mocr_LIBRARY NAMES mocr)
+find_path(mocr_INCLUDE_DIR NAMES mocr.h)
+
+find_library(mocrxx_LIBRARY NAMES mocr++)
+find_path(mocrxx_INCLUDE_DIR NAMES mocr++.h)
+
+find_package_handle_standard_args(
+ mocr
+ REQUIRED_VARS
+ mocr_LIBRARY mocr_INCLUDE_DIR
+ mocrxx_LIBRARY mocrxx_INCLUDE_DIR
+)
+
+if(mocr_FOUND)
+ mark_as_advanced(mocr_LIBRARY)
+ mark_as_advanced(mocr_INCLUDE_DIR)
+ mark_as_advanced(mocrxx_LIBRARY)
+ mark_as_advanced(mocrxx_INCLUDE_DIR)
+endif()
+
+if(mocr_FOUND AND NOT TARGET mocr::mocr)
+ add_library(mocr::mocr UNKNOWN IMPORTED)
+ set_target_properties(
+ mocr::mocr PROPERTIES
+ IMPORTED_LOCATION "${mocr_LIBRARY}"
+ INTERFACE_INCLUDE_DIRECTORIES "${mocr_INCLUDE_DIR}"
+ )
+endif()
+
+if(mocr_FOUND AND NOT TARGET mocr::mocrxx)
+ add_library(mocr::mocrxx UNKNOWN IMPORTED)
+ set_target_properties(
+ mocr::mocrxx PROPERTIES
+ IMPORTED_LOCATION "${mocrxx_LIBRARY}"
+ INTERFACE_INCLUDE_DIRECTORIES "${mocrxx_INCLUDE_DIR}"
+ )
+ target_link_libraries(mocr::mocrxx INTERFACE mocr::mocr)
+endif()
diff --git a/extern/CMakeLists.txt b/extern/CMakeLists.txt
index 7e2db26..1a8391a 100644
--- a/extern/CMakeLists.txt
+++ b/extern/CMakeLists.txt
@@ -19,13 +19,3 @@ FetchContent_Declare(
PATCH_COMMAND ${MEMENTO_QCORO_PATCH_COMMAND}
)
FetchContent_MakeAvailable(qcoro)
-
-if(OCR_SUPPORT)
- set(BUILD_TESTING OFF CACHE BOOL "" FORCE)
- FetchContent_Declare(
- libmocr
- GIT_REPOSITORY https://github.com/ripose-jp/libmocr.git
- GIT_TAG 24ec081102208d0ff6954c3003df2fb691713bd5
- )
- FetchContent_MakeAvailable(libmocr)
-endif()
diff --git a/src/ocr/CMakeLists.txt b/src/ocr/CMakeLists.txt
index f942be1..3ffaf50 100644
--- a/src/ocr/CMakeLists.txt
+++ b/src/ocr/CMakeLists.txt
@@ -9,7 +9,7 @@ if(OCR_SUPPORT)
target_include_directories(ocrmodel PRIVATE ${MEMENTO_INCLUDE_DIRS})
target_link_libraries(
ocrmodel
- PRIVATE mocr++
+ PRIVATE mocr::mocrxx
PRIVATE Qt6::Concurrent
PRIVATE Qt6::Gui
PUBLIC Qt6::Core |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I feel bad for asking silly questions in the same vein as #301 but here I go.
So I think I've built with OCR successfully and I opened: https://www.youtube.com/watch?v=somEzKcCDVE which contains hardcoded subtitles at the top.
I dont know how to leverage the OCR though:
NB: I've used manga-ocr with success in the past
Beta Was this translation helpful? Give feedback.
All reactions