How to Install the Libraries (OCR in Python Tutorials 01.02)

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
[Music] before getting started with this video i just wanted to say thank you to my first patreon for supporting this channel if you want to support this channel and you enjoy the content please do consider contributing just a little bit from a lot of different people really goes a long way to helping me make these videos and keeping everything completely free for everyone hello and welcome back to the series on ocr and python now in the last video i introduced you to the concept of ocr optical character recognition and how to go about generally solving it in a common workflow in python in this video i'm going to work on how to install the essential libraries what they are and why you're going to use them so we're going to start with the easiest library first and that's pillow pillow is a fork of the pil or python imaging library it's a fork that was started by alex clark and other contributors and it is the standard way to work with images in python if you're not familiar with pillow i highly encourage you to get familiar with it the syntax is relatively uh simple and it's easy to get used to with a little bit of practice what it does is it allows for you to open up images which are just a series of numerical arrays that represent pixels so numbers correspond to different pixels and it's a way of loading images into memory as numbers and working with them in python and then if you're using jupyter notebooks or some kind of way of displaying images you can also display the images through python as well if you're using an ide like i will be using for part of the series you can pass commands that will open up the images in a separate window so the way in which you're going to install this is you're going to just undo pip install pillow and if you do that you'll see that i have already got this already satisfied i'll zoom in a little bit so you can see that in fact i'm going to open up a brand new command prompt that's fresh so what you will do is like i said you will just do pip install pillow and you'll be able to install pillow on your um as a library that's going to be the easiest one here to actually install and that's why i started with it here this is again me working on windows um but there's if you follow the documentation that i'll link in the description down below it'll take you through all the different ways to install it on different systems from mac os to linux the next library that we're going to be working with and this one's a little trickier to install if you don't know how to do it is opencv opencv is a python library that allows for you to work with images in a much more dynamic way you can all through them you can think of it like a python version of photoshop that you execute in code it allows you to binarize images so take them and adjust them into black and white images it allows you to control threshold things like that it allows you to manipulate images now the reason why i say it's a little confusing if you're not used to the syntax is because of how you install it and how you import it so the way we're going to install it isn't like you would typically think we're going to do pip install open cv dash python and then you'll run this and you'll find you'll see that i already have it satisfied because i've downloaded it and one of the dependencies is going to be numpy i've spoken about numpy and installing a windows you might have to do some manual installation sometimes there's a problem installing numpy because of the math kernel library that is a requirement on windows but that's going to be how you work with opencv now the way in which we're going to import opencv in python isn't with import opencv python instead you're going to do import cv2 cv2 that's going to be how you import um opencv and while we're here you're not going to import the pillow library like you might expect you're going to import pil that's going to allow you to work with with pillow data and python more times than not however you're going to be doing it from a pil import image with a capital i that's going to be largely what we do throughout this series this is going to allow us to open up images using the pillow library fork and manipulate them in opencv and now i've saved kind of the more challenging of these three libraries for last and that library that we're going to be working with is a library called pi tesseract which is a wrapper for the python for the tesseract models that come out of google there's a couple different ways to use tester act in python and the pi testdirect module the library is by far the simplest i think and it's the easiest to get used to it is however limiting and what you can actually do to it later and do with it sorry later in the series i'm going to introduce you to another tesseract library that allows for you to do more custom things and engage with tesseract and the config system on a deeper level for the first part of the series though we're interested in acquiring the basic skills now installing pi tesseract isn't enough you also have to install tesseract and if you're working on windows like i am that means downloading as uh let me find it over here downloading the tesseract file from uh the mannheim university libraries now if you go down on the ub manheim github page you'll find it looks like this and i'll have a link in the description down below and you can download version 5.00 what we're working on in this series is version 4.0 because 5.0 is still an alpha so when you get to this page that i'll link in the description down below you're going to click on older versions available and you'll get to a page that looks like this and what you're going to want to do is you're going to want to scroll down and find the correct version for your system so i'm working with a 64-bit operating system so the version that i want is this one right here and i'm going to have a link that describes which file this is you can find it more easily by just doing control f and what this is going to allow for you to do is to download a an exe file instead of having to go through and cloning everything if however you are working with a mac or a linux system you're going to do things a little bit differently and what i'm going to provide for you also is a link to this the illinois library and what this does for you is it has a very nice installation process steps for if you're working on a mac or something other than windows so what you're going to do is you're going to download that tesseract file from here if you're working on a windows we have to do a few extra steps we scroll in so you can kind of get a better look here when you download it you're going to have an exe file and you're going to run that exe file at this stage you're going to hit yes you're going to run it it's going to open up and it's going to allow you to actually install tesseract onto your computer system so for me i'm working with english so i'm going to click yes and you're going to go through and actually follow all of the steps now i'm going to go ahead and just hit yes here and go ahead and reinstall everything and you're going to make sure that your that your installation area is program files backslash test rack dash ocr that should be default go through the steps here and you'll find that you can install not only the the 100 or so languages that are represented in tesseract each of which is going to be a model that's about 30 megabytes you'll also be able to install the the different scripts for different languages so you can install um the greek script the latin script is going to be default you can install the arabic script the hebrew script etc on down the list once you have tesseract installed now comes the part that i think is a little more challenging for those who aren't used to working with paths and windows and to find the path in window you're going to hit your windows key which is going to pop this up and you're just going to type in the word environment and you're going to hit enter this is what you want to go to it's in the control panel this is just an easier way to get to it once this is loaded you're going to click on environment variables and once you have that opened up you're going to go down to path and under path you're going to hit edit and when you edit this you're going to make sure to hit new and you're going to add in that c colon program files tesseract ocr and what that's going to allow for you to do is it's going to allow you to add tesseract into your path and once that is complete you'll be able to open up your command prompt and execute the following command tesseract dash dash space dash dash version and when you do that you should get something that looks like this if you see this this means that you have installed tesseract correctly and it is in fact in your path if however you're getting an error it means that something has gone wrong wrong in the process either it wasn't installed correctly or more than likely it wasn't added to the path correctly so go through and take your time doing all that once you have python or once you have tesseract installed in the path the next thing to do is going to be to pip install pi tesseract so you'll just do pip install pi tesseract i'm going to have a link in the description down below for a whole bunch of different guides for this installation process so you can follow along in text while you watch this video and i'll also have guides for macs and linux's linux systems once you do install pi tesseract now you should be able to import pi test direct and if everything works good here then it means that you've installed all these libraries correctly and it means that you're ready to move forward if however you're getting error messages i encourage you to re-watch this video make sure you take each of these steps slow up bit by bit this is the hardest part i have found in the past with working with these three libraries and doing ocr and python it's just getting the environment set up correctly once you have your environment set up correctly it's going to be things are going to be much more natural and feel a little bit better the only thing that's going to give you a little bit of pause is working with opencv in python because the syntax is a little confusing i'm still confused by some of the syntax and opencv but you'll get eventually just get used to it i promise so if you've got everything installed correctly then i've done my job well if you're getting errors let me know in the comments down below and i'll try to help you out in the comments but also check out the guides that i'm going to link in the description down below if you've got everything installed then you're ready to move on to the next video in which we start working actually it's gonna be part two of this series when we start working with the basics of all of these libraries so how to actually start doing tasks like opening images and pillow how to start editing uh images with opencv and how to start working with the basics of pi tesseract that's gonna be it for this video though thank you for listening if you've enjoyed it please like and subscribe down below and if you're finding this series useful please do consider supporting this channel on patreon linked in the description down below
Info
Channel: Python Tutorials for Digital Humanities
Views: 31,680
Rating: undefined out of 5
Keywords: python, digital humanities, python for DH, dh, python tutorial, tutorial, python and the humanities, python for the digital humanities, digital history, Python and libraries, python tutorials, python tutorials for digital humanities, how to install tesseract on windows, installing tesseract, python and tesseract, tutorial for tesseract and ocr in python
Id: 89m89vVh4wg
Channel Id: undefined
Length: 11min 13sec (673 seconds)
Published: Fri Apr 02 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.