User:Pedro Sá Couto/Prototyping 5th/Text Launderette Scripts: Difference between revisions

From XPUB & Lens-Based wiki
 
(11 intermediate revisions by the same user not shown)
Line 1: Line 1:
=Scripts=
=Scripts=
====From the git====
====From the git====
https://git.xpub.nl/pedrosaclout/Text_Launderette_Scripts
https://git.xpub.nl/pedrosaclout/DIY_Book_Scanner_Workflow
 
=DIY Book Scanner Workflow=
 
==Getting started==
 
This set of scripts was written for the Text Laundrette workshop. The workshop takes place in the Publication Station, WDkA building.<br> Rotterdam, 03-02-2020<br>It is a workflow to turn the pictures from the DIY Book Scanner into a final OCRed PDF.<br>
 
==Dependencies==
===Brew (MAC) or apt-get (LINUX)===
You’ll need the command-line tools for Xcode installed.
 
<source lang="shell">
xcode-select --install
</source>
 
After install Homebrew.
 
<source lang="shell">
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
</source>
 
Run the following command once you’re done to ensure Homebrew is installed and working properly:


==Merge PDF==
TEXT HERE
<source lang="shell">
<source lang="shell">
brew doctor
</source>
</source>


==Crop Bounding Box==
<source lang="shell">
TEXT HERE
sudo apt-get install python3 python3-pip imagemagick poppler pdfunite
<source lang="python">
</source>
</source>


==OCR==
<source lang="shell">
TEXT HERE
brew install python3 python3-pip imagemagick poppler pdfunite
<source lang="python">
</source>
</source>


==Rotate JPGS==
===PIP3===
TEXT HERE
<source lang="shell">
<source lang="python">
sudo pip3 install pdf2image Pillow time logging opencv-python pytesseract
</source>
</source>
<br>
==How to use==
Add your pictures from the book scanner to the folder "/scans"


==Burst PDF==
Make all the files executable.
TEXT HERE
 
<source lang="python">
<source lang="shell">
sudo chmod 777 merge_scans.sh workshop_stream.sh marge_files.sh
</source>
</source>
In case you want to skip any of the scripts just comment out in the shell code, <em>workshop_stream.sh</em>.
Run ./workshop_stream.sh
Wait :)
<br>
==Aditional information==
The workflow follows these scripts, by successive order:
===Create 5 directories===
<source lang="shell">
mkdir split
mkdir rotated
mkdir ocred
mkdir bounding_box
mkdir cropped
</source>
===Merge the files in the directory ''scans''===
All the scans will be appended to one pdf called out.pdf
<source lang="shell">
./merge_scans.sh
</source>
===Burst the pdf in ''scans''===
Burst this pdf, renaming all the files so they can be iterated later.
<source lang="shell">
python3 burstpdf.py
</source>
===Rotate the pdfs===
The book scanner takes pictures of the pdfs, this scrip iterates through the odd and even pages rotating them to their original position.
<source lang="shell">
python3 rotation.py
</source>
===Cropping the bounding boxes===
The pages are now in their original position, but they have a bounding box. This script iterates through them and crops the highest contrast area found.
<source lang="shell">
python3 bounding_box.py
</source>
===Cropping the mirror===
The pages are now cropped, but the mirror is still visible in the middle.
<source lang="shell">
python3 mirror_crop.py
</source>
===OCR===
In this part we OCR the jpg, turning these into PDFs.
<source lang="shell">
python3 tesseract_ocr.py
</source>
===Merge all the files and create the pdf===
The OCRed pages are now joined into their final PDF, your book is ready :)
<source lang="shell">
./merge_files.sh
</source>
==License==
The package is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).


=About Text Launderette=
=About Text Launderette=

Latest revision as of 12:40, 31 January 2020

Scripts

From the git

https://git.xpub.nl/pedrosaclout/DIY_Book_Scanner_Workflow

DIY Book Scanner Workflow

Getting started

This set of scripts was written for the Text Laundrette workshop. The workshop takes place in the Publication Station, WDkA building.
Rotterdam, 03-02-2020
It is a workflow to turn the pictures from the DIY Book Scanner into a final OCRed PDF.

Dependencies

Brew (MAC) or apt-get (LINUX)

You’ll need the command-line tools for Xcode installed.

xcode-select --install

After install Homebrew.

ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

Run the following command once you’re done to ensure Homebrew is installed and working properly:

brew doctor
sudo apt-get install python3 python3-pip imagemagick poppler pdfunite
brew install python3 python3-pip imagemagick poppler pdfunite

PIP3

sudo pip3 install pdf2image Pillow time logging opencv-python pytesseract


How to use

Add your pictures from the book scanner to the folder "/scans"

Make all the files executable.

sudo chmod 777 merge_scans.sh workshop_stream.sh marge_files.sh

In case you want to skip any of the scripts just comment out in the shell code, workshop_stream.sh.

Run ./workshop_stream.sh

Wait :)

Aditional information

The workflow follows these scripts, by successive order:

Create 5 directories

mkdir split
mkdir rotated
mkdir ocred
mkdir bounding_box
mkdir cropped

Merge the files in the directory scans

All the scans will be appended to one pdf called out.pdf

./merge_scans.sh

Burst the pdf in scans

Burst this pdf, renaming all the files so they can be iterated later.

python3 burstpdf.py

Rotate the pdfs

The book scanner takes pictures of the pdfs, this scrip iterates through the odd and even pages rotating them to their original position.

python3 rotation.py

Cropping the bounding boxes

The pages are now in their original position, but they have a bounding box. This script iterates through them and crops the highest contrast area found.

python3 bounding_box.py

Cropping the mirror

The pages are now cropped, but the mirror is still visible in the middle.

python3 mirror_crop.py

OCR

In this part we OCR the jpg, turning these into PDFs.

python3 tesseract_ocr.py

Merge all the files and create the pdf

The OCRed pages are now joined into their final PDF, your book is ready :)

./merge_files.sh

License

The package is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).

About Text Launderette

TITLE

XPUB workshops – Text Launderette

STATION

Publication Station

LOCATION

BL.00.4

TUTORS

Simon Browne & Pedro Sá Couto

DESCRIPTION

We will use a home-made, DIY book scanner, and open-source software to scan, process, and add digital features to printed texts brought by the participants to the workshop. Ultimately, we will include them in the “bootleg library”, a shadow library accessible over a local network.
Shadow libraries operate outside of legal copyright frameworks, in response to decreased open access to knowledge. This workshop aims to extend our research on libraries, their sociability, and methods by which we can add provenance to texts included in public or private, legal or extra-legal collections.
Participants should bring: a printed text, which they’d like to digitize and share.

PRACTICAL INFORMATION

Under the name of .py.rate.chnic sessions, the second-year students from the Experimental Publishing Master program invite you to participate in a series of hands-on workshops, related to the topics of their graduation projects. Each workshop offers the participants an opportunity to engage with the students’ research by partaking in their processes, experiments, and discussions.

MINIMAL ENROLMENT

5

MAXIMUM ENROLMENT

15

NR OF SESSIONS

1