Tesseract quiet mode - tesseract

Under Ubuntu I use tesseract-ocr in version 3.02. Especially the wrapper pytesseract for python, but this question is also about the commandline-tool.
In the FAQ under
https://code.google.com/p/tesseract-ocr/wiki/FAQ#How_can_I_make_the_error_messages_go_to_tesseract.log_instead_of
is written that there is a option/config-file "quiet" supressing the info line of tesseract.
However, when I call tesseract command line with this option, it says
"read_params_file: Can't open quiet"
And it is right, in the corresponding config-folder there is no "quiet"-config-file.
Where can I get it or how can I create it?
The info-line which I want to supress is: "Tesseract Open Source OCR Engine v3.02 with Leptonica".

quiet is part of tesseract-ocr repository: https://github.com/tesseract-ocr/tesseract/blob/master/tessdata/configs/quiet

The quiet config file from the other answer contains one line: debug_file /dev/null
If the config can't be used this way for some reason, you can achieve the same effect by adding -c debug_file=/dev/null somewhere before the input/output params.

Related

How to have Dexy evaluate Perl scripts?

The dexy documentation states than any language may be used. The tutorial use the py filter to run Python file, but I didn't find any filter to run Perl file.
I try to execute a very simple Perl file
I've tried to use the bash or sh filter, but with no luck, and didn't find any execute-or-like filter.
Am I missing something obvious ?
Ok, here are the different solutions I found about this.
1. A perl filter now exist
Ok, Ana is the owner of this project and is very reactive. I asked her the question about dexy and perl on IRC, and tada ! Less than 1 hour later, there was a commit on the repository with perl support.
So, if you just get latest version and install it this way :
git clone https://github.com/dexy/dexy
cd dexy
sudo pip install -e .
You should have a perl filter.
If you want to pass arguments to a script, just use the scriptargs setting.
2. Use a bash script
Another very simple solution is to embed the launch of a perl script into a sh/bash script, and use the sh/shint/bash filter that already exist.
3. Use bash script without additional files
If you fear that the latest solution will makes you add a lot of tiny scripts in your directories, you may use the contents feature of dexy. That way, the required one-liners are defined in dexy.yaml only.
Something like :
- shell-myscript.sh|sh:
- contents: "perl ./perl/myscript.pl --any-parameter"
- perl/myscript.pl
is doing the job just fine for me.

Unrar script, error, in need of rar command for debian

I'm currently trying to get this script to work:
https://github.com/mj41/auto-unrar/blob/master/bin/unrar2.pl
The only problem is that I get the following error:
Entering directory 'Series'
Entering directory 'Series/SerieName'
Entering directory 'Series/SerieName/Season2'
Entering directory 'Series/SerieName/Season2/SerieNameS02E21.720p.HDTV.X264-DIMENSION'
Entering directory 'Series/SerieName/Season2/SerieNameS02E21.720p.HDTV.X264-DIMENSION/Sample'
Can't call method "List" on an undefined value at unrar2.pl line 973.
This line is rar_obj->List();
$rar_conf{'-verbose'} = $rar_ver if $rar_ver;
my $rar_obj = Archive::Rar->new( %rar_conf );
$rar_obj->List();
my #files_extracted = $rar_obj->GetBareList();
This is an old script, 3-4 years old and I changed a little like SHA1 to SHA and use Filesys::DfPortable; to Df
Does anyone know how I can fix this error :)?
EDIT:
I contacted the developer and he told me I needed to install a program that can handle rar commands. So how would I do that. I can't seem to be able to install unrar.
EDIT2:
What my problem is now, 2 of the 3 unrar packages aren't in my architecture, armhf.
To install the script yourself::::::::::::
https://github.com/jorricks/UNRAR
You need to pass the -archive parameter into the call to new() otherwise how will $rar_obj know which file it is supposed to be looking at?
I can't seem to be able to install unrar
That's not a particular good explanation of your problem. What did you try? What unexpected behaviour did you see?
From the tags on your question, it looks like you're running Debian. What do you see if you run sudo apt-get install unrar?
Update: My first comment was based on the code extract that you showed us. Looking at the full program code, I can see that %rar_conf has other values set in it (including the -archive option) before the section of code you gave us.
Looking at the source of the Archive::Rar module, it seems to assume that the program to use for dealing with the archives is called rar. So 7-Zip is not going to work.

`GLIBCXX_3.4.11' not found, run system call from MATLAB that links to glibc different than what's in matlab bin path

I'm trying to circumvent using MEX to link to MATLAB and just call a binary using "!" as in:
>> !template_image_rigid -args ....
template_image_rigid: /opt/MatlabR2010a/sys/os/glnxa64/libstdc++.so.6: version `GLIBCXX_3.4.11' not found (required by /usr/lib/libboost_program_options.so.1.40.0)
template_image_rigid: /opt/MatlabR2010a/sys/os/glnxa64/libstdc++.so.6: version `GLIBCXX_3.4.11' not found (required by /usr/lib/libdirac_encoder.so.0)
Is there a way to easily fix this dynamic link issue from within MATLAB? I know I can recompile the source with MATLAB and use a MEX call, but since it takes a while to run the solver I just want to run it as shell command and import text data later into MATLAB.
If it helps, the source & CMakeLists.txt can be found here: https://github.com/pkarasev3/nlmagick/tree/master/samples
Grr, community = fail.
Diagnoising: do !gnome-terminal from within matlab and look at "env":
env | grep Matlab
which gives
XKEYSYMDB=/opt/MatlabR2010a/X11/app-defaults/XKeysymDB
MATLABPATH=/opt/MatlabR2010a/toolbox/local
XAPPLRESDIR=/opt/MatlabR2010a/X11/app-defaults
LD_LIBRARY_PATH=/opt/MatlabR2010a/sys/os/glnxa64:/opt/MatlabR2010a/bin/glnxa64:/opt/MatlabR2010a/extern/lib/glnxa64:/opt/MatlabR2010a/runtime/glnxa64:/opt/MatlabR2010a/sys/java/jre/glnxa64/jre/lib/amd64/native_threads:/opt/MatlabR2010a/sys/java/jre/glnxa64/jre/lib/a md64/server:/opt/MatlabR2010a/sys/java/jre/glnxa64/jre/lib/amd64
OSG_LD_LIBRARY_PATH=/opt/MatlabR2010a/sys/openscenegraph/lib/glnxa64
TOOLBOX=/opt/MatlabR2010a/toolbox
XFILESEARCHPATH=/opt/MatlabR2010a/sys/java/jre/glnxa64/jre/lib/locale/%L/%T/%N%S::/usr/dt/app-defaults/%L/Dt
MATLAB=/opt/MatlabR2010a
Ok so the LD_LIBRARY_PATH is bad.
Trick: write a poltergeist script and run it from gnome-terminal, Launch it from Matlab with:
!./hack.sh RunStuffThatLinksElsewhere
where hack.sh is a script with something like:
#!/bin/bash
source ~/.bashrc
export LD_LIBRARY_PATH=''
gnome-terminal --command="${1}"
so an easy test is to try it with "eog", this hack gets around the link issue and lets you run it from within matlab...
Simpler:
setenv('foo',num2str(some_value) )
!LD_LIBRARY_PATH="" && ./my_binary -f $foo
disp('done with external program!')
I solved this problem by replacing the version of libstdc++.so.6 with a newer version from my system (I use ubuntu 12.04).
First find the system version of libstdc++.so.6.
From the command line type:
locate libstdc++.so.6
My system version of libstdc was
/usr/lib/i386-linux-gnu/libstdc++.so.6
Then replace the matlab libstdc version with a link to the system libstdc.
From the command line type (replace [....] with you settings):
cd [matlab_dir]/sys/os/glnx86
mv libstdc++.so.6 libstdc++.so.6-OLD
ln -s [your_system_version_of_libstdc] libstdc++.so.6
I recently ran into the same problem. My solution also uses a poltergeist script like other answers. The script is as follows (poltergeist.sh):
#!/bin/bash
export LD_LIBRARY_PATH=''
eval "$#"
It basically resets the library path and subsequently evaluates the call given by the arguments to the script. From within matlab I then call in this manner:
system([pwd,'/poltergeist.sh echo hello world!']);
The advantage to this approach is that you can dynamically modify the call command within matlab. As far as I know this is not possible using the bang syntax in the currently provided answers.

Auto-complete command line arguments

In bash, executables such as mplayer and imagemagick's "convert" have a cool auto-complete functionality on their command line arguments. For instance, if I type
mplayer <tab><tab>
in one of my video folders, then mplayer will list all media files located in that folder, and only the media files.
Similarly, if I type
convert -<tab><tab>
then I will see all the possible options of the convert script, which is great.
My question is how to achieve a similar functionality, using bash, ruby or python scripts?
This is an example of BASH's smart completion. A basic description is here, a guide to writing your own extensions is here and another (Debian-based) guide is here. And here's a fuller featured introduction to the complete command (the command that facilitates this behaviour).
The link to writing your own extension in the accepted answer has gone dead. Quoting here from http://web.archive.org/web/20090409201619/http://ifacethoughts.net/2009/04/06/extending-bash-auto-completion/
Bash provides you a way of specifying your keywords, and using them to
auto complete command line arguments for your application. I use vim
as a wiki, task managemer and contacts. The vim helptags system lets
me index the content instead of searching through it, and the speed
shows it. One feature I wanted to add to this was to access these tags
from outside vim.
This can be done in a straight forward way:
$ vim -t tagname
This takes me directly to specific content marked using this tag. However, this will be more productive if I can provide
auto-completion for the tags.
I first defined a Bash function for the vim commandline. I added the
following code to my .bashrc file:
function get {
vim -t $1
} Now I can use get tagname command to get to the content.
Bash programmable completion is done by sourcing the
/etc/bash-completion script. The script lets us add our
auto-completion script /etc/bash-completion.d/ directory and executes
it whenever it is called. So I added a script file called get with the
following code in that directory.
_get()
{
local cur
COMPREPLY=()
#Variable to hold the current word
cur="${COMP_WORDS[COMP_CWORD]}"
#Build a list of our keywords for auto-completion using
#the tags file
local tags=$(for t in `cat /home/anadgouda/wiki/tags | \
awk '{print $1}'`; do echo ${t}; done)
#Generate possible matches and store them in the
#array variable COMPREPLY
COMPREPLY=($(compgen -W "${tags}" $cur))
}
#Assign the auto-completion function _get for our command get.
complete -F _get get Once the /etc/bash-completion is sourced, you will get auto-completion for the tags when you use the get command.
Along with my wiki I use it for all the documentation work and at
times the code too. I also use the tags file created from my code. The
indexing system lets me remember the context instead of the filenames
and directories.
You can tweak this system for any of the tools you use. All you need
to do is get a list of the keywords for your command and give it to
the Bash programmable completion system.
This functionality in bash is provided by bash-completion and similar functionality is included in zsh. If you want to add support for some program not currently supported by one of these tools, you need to write your own extensions for them.
How do I enable bash completion on Ubuntu?
sudo apt-get install bash-completion
source /etc/profile.d/bash_completion.sh
sudo apt i[TAB]

XP command prompt : redirect a file to STDOUT

I want to do the opposite of everybody ( laugh )
I start open-erp with a command line like :
C:\OpenERPAllInOne\Server>openerp-server.exe --log-file=outputfile
but the problem is that with Windows it only does output to a file.
Is there any way to redirect a file to the STDOUT.
For example (it doesn't work but this is the way I see it working) :
C:\OpenERPAllInOne\Server>openerp-server.exe --log-file=STDOUT
and then see directly the output to the command line.
I can't make it work ! Any idea ?
Thanks,
Olivier
I'm not sure if it still works, try CON (hope it was that) as filename
That would be a function of the openerp-server.exe program.
If it's default output is to a file, then there isn't anything you can do about that.
I'm assuming that OpenERP uses getopt_long and confirms to GNU standards. If it does, then the following should work:
openerp-server --log-file=-
(a dash is usually used to represent STDOUT in GNU, Linux and UNIX programs.)
If you can't get the server to output to the standard output you could monitor the log file with [tail][1].
If you run:
tail -f c:\path\to\logfile.txt
in another window then you can see the contents of the file as they are written.
tail doesn't come with Windows as standard but you can download a free port of tail for Windows here.
for windows there is a configuration file for OpenERP Server,
like openerp-server.conf in the directory where you have installed the Open ERP
like c:\Program Files\OpenERP Server\openerp-server.conf OR
C:\documents and settings\USER\OpenERP Server\oepenrp-server.conf
you need to edit that file and set the --log-file paramter to None or False, and probably you might also try out something like this
C:\OpenERPAllInOne\Server>openerp-server.exe --log-file=False
that should work, but not sure whether it will work or not.!!