News for hackers. Stuff that matters.
Re:Tesseract.js: Pure JavaScript OCR for 100 Languages by NewDimension on Friday December 20, 2019 @11:36AM (#21845359)
Somewhat offtopic, do you know of a library that would allow me to select an area of a PDF through a GUI and only read the text in those coordinates?
Re:Tesseract.js: Pure JavaScript OCR for 100 Languages by ncallaway on Friday December 20, 2019 @12:35PM (#21845828)
The tesseract-cli (and so I'm sure the library also) will give you HOCR output, which is an HTML format that gives you the text, with bounding boxes around paragraphs and individual characters.

https://github.com/tesseract-ocr/tesseract/wiki/Command-Line...

It's not quite what you want, but I think you could probably filter the output based on the selected region and pretty quickly get what you want.

Re:Tesseract.js: Pure JavaScript OCR for 100 Languages by narayanans on Saturday December 21, 2019 @10:41AM (#21851671)
Try tabula[0]

It is opensource and runs on Java.You can also extract the areas of interest in the pdf and run it via cmdline[1].You can get more details if required on my blog[2]

[0]https://tabula.technology/

[1]https://github.com/tabulapdf/tabula-java/wiki/Using-the-comm...

[2]https://narayanansiyer.com/Tabula/tabula/

Re:Tesseract.js: Pure JavaScript OCR for 100 Languages by sailfast on Friday December 20, 2019 @12:52PM (#21845957)
I think the Project Naptha extension by the folks that wrote this library will do that, no? https://projectnaptha.com/

Not sure if it only reads at those coordinates vs. OCRing the whole thing (for example if you were legally prohibited from OCRing content outside a certain coordinate space), but it is selectable.

Re:Tesseract.js: Pure JavaScript OCR for 100 Languages by severine on Friday December 20, 2019 @02:12PM (#21846627)
You could simply pipe an area screenshot to tesseract, discard the input image and get the tesseract output, am I wrong?
Re:Tesseract.js: Pure JavaScript OCR for 100 Languages by NewDimension on Friday December 20, 2019 @03:17PM (#21847054)
That sounds like a valid approach, any idea what tools I could use to get the define the area and get the screenshot?
Re:Tesseract.js: Pure JavaScript OCR for 100 Languages by severine on Friday December 20, 2019 @04:59PM (#21847746)
You possibly have one installed. Mine comes with my desktop (Xfce), and gives me a GUI and a CLI to take screenshots of the full desktop, any window, or a particular area defined by crosshairs.

There's a very popular and minimalist CLI called scrot that I think would be ideal... well scratch that, I made a search and our question has already been asked and answered:

https://askubuntu.com/questions/280475/how-can-instantaneous...

https://stackoverflow.com/questions/21497447/ocr-on-a-screen...

Re:Tesseract.js: Pure JavaScript OCR for 100 Languages by mkl on Friday December 20, 2019 @06:10PM (#21848201)
If I remember correctly, I did it with the ImageMagick "import" command. I found I had to add a wide white border, as Tesseract got confused near the edges of the image (this was over 10 years ago though).
Re:Tesseract.js: Pure JavaScript OCR for 100 Languages by mdtusz on Friday December 20, 2019 @06:01PM (#21848144)
I'm not sure if there's a non GUI interface for it, but zathura does this for pdfs.
Re:Tesseract.js: Pure JavaScript OCR for 100 Languages by jjohansson on Friday December 20, 2019 @12:18PM (#21845706)
Commercial or open source? PDFTron can do it, but they’re not an open source project.
Re:Tesseract.js: Pure JavaScript OCR for 100 Languages by NewDimension on Friday December 20, 2019 @01:44PM (#21846438)
I prefer something I can install locally (doesn't need to be open source). I'm trying to extract text from a PDF at a certain position, the PDF is indeed text not an image so OCR isn't strictly needed.

The goal is to draw a box using GUI, then use those coordinates to extract text from several homogeneous pages.

I also have a different goal of trying to interpret structure of a PDF that has visual structure (headers, sections and subsections all numbered). But that seems to lend itself to some sort of text parsing.

Re:Tesseract.js: Pure JavaScript OCR for 100 Languages by severine on Friday December 20, 2019 @05:06PM (#21847796)
I also have a different goal of trying to interpret structure of a PDF that has visual structure (headers, sections and subsections all numbered). But that seems to lend itself to some sort of text parsing.

Some reading here: https://stackoverflow.com/questions/53219016/detecting-secti...

Re:Tesseract.js: Pure JavaScript OCR for 100 Languages by jjohansson on Friday December 20, 2019 @06:10PM (#21848202)
PDFTron provides an SDK and isn't really meant as a plug-and-play end-user application. But it can accomplish what you're looking for.

Here's how to extract text from a PDF based on coordinates (this explains how to do it on web, but it's also possible using other platforms):

https://groups.google.com/d/msg/pdfnet-webviewer/h2W3VksbQUI...

Here's how to extract a PDF's logical structure:

https://www.pdftron.com/documentation/samples/#logicalstruct...

Re:Tesseract.js: Pure JavaScript OCR for 100 Languages by pierre on Friday December 20, 2019 @12:52PM (#21845962)
Pdf.js and filtering the output. Par.sr with the good input module configuration