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

The ability to restore variable #3260

Open
Shatur opened this issue Jan 24, 2021 · 2 comments
Open

The ability to restore variable #3260

Shatur opened this issue Jan 24, 2021 · 2 comments

Comments

@Shatur
Copy link
Contributor

Shatur commented Jan 24, 2021

Issue description

TessBaseAPI currently has SetVariable function for setting parameters. This is a useful thing and, for example, my application has the ability to set these parameters through the settings menu. But if the user first sets some parameter, and then removes it, then it is necessary to reset this value to the default. At the moment there is no such possibility without reinitializing the API itself. If you pass nullptr, then the application segfaults, if you pass an empty string, then PrintVariables return false indicating failure. Also, simply calling the Init function will not reset the variables unless End is called before it.

Suggestions

It would be nice to have a more convenient API to control such variables without full reinitialization. Something like ClearVariables would be enough.

Also it would also be convenient to reset the value to default when passing nullptr to SetVariable or have a separate function to reset a single variable.

@amitdo
Copy link
Collaborator

amitdo commented Feb 26, 2021

You can call GetVariableAsString() before you call SetVariable() and store the result so the user can undo / reset the variable to its previous value.

@Shatur
Copy link
Contributor Author

Shatur commented Feb 26, 2021

@amitdo, sure, but it would be nice to have a more convenient way :)

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

No branches or pull requests

2 participants