Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add cli -c parameter(s) to init vectors #4363

Merged
merged 1 commit into from
Nov 27, 2024
Merged

Conversation

zdenop
Copy link
Contributor

@zdenop zdenop commented Nov 27, 2024

see #4354

@amitdo amitdo merged commit 2e5a114 into tesseract-ocr:main Nov 27, 2024
6 checks passed
@zdenop zdenop deleted the cli branch November 27, 2024 12:36
@amitdo
Copy link
Collaborator

amitdo commented Nov 27, 2024

Thanks!

@stweil
Copy link
Contributor

stweil commented Nov 27, 2024

What happens now if I want to override parameters which are normally set by the model file?

old: model file parameters could be overridden by command line parameters
new: command line parameters are evaluated before the model file parameters are set?

@stweil
Copy link
Contributor

stweil commented Nov 27, 2024

Old error message for wrong usage:

Missing = in configvar assignment

New error message:

libc++abi: terminating due to uncaught exception of type std::invalid_argument: Missing '=' in configvar assignment
zsh: abort      tesseract x - -c x

Throwing an error changes the error message which is presented to users. It also changes the result code from 1 to 134 on macOS (maybe also on Linux and Windows). Why not simply print the old error message?

@amitdo
Copy link
Collaborator

amitdo commented Nov 28, 2024

Responding to your first comment:

It's not clear if you wonder if there is an issue here or you know there is an issue here.

Regarding your second comment, yes, we should change this to print a simple error message.

@amitdo
Copy link
Collaborator

amitdo commented Nov 28, 2024

@stweil,

See the code in:

int Tesseract::init_tesseract(const std::string &arg0, const std::string &textbase,

@zdenop
Copy link
Contributor Author

zdenop commented Nov 29, 2024

@stweil : Could it be like this?

diff --git a/src/tesseract.cpp b/src/tesseract.cpp
index 08a65e14..6025af5f 100644
--- a/src/tesseract.cpp
+++ b/src/tesseract.cpp
@@ -462,7 +462,8 @@ static bool ParseArgs(int argc, char **argv, const char **lang, const char **ima
       const std::string argument(argv[i + 1]);
       const auto equal_pos = argument.find('=');
       if (equal_pos == std::string::npos) {
-          throw std::invalid_argument("Missing '=' in configvar assignment");
+        fprintf(stderr, "Missing = in configvar assignment\n");
+        return false;
       }
       // Extract key and value
       const std::string key = argument.substr(0, equal_pos);

@zdenop
Copy link
Contributor Author

zdenop commented Dec 3, 2024

@stweil : Are you fine with proposal above or does 0a9df94 solve the problem?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants