Unfamiliar Python Libraries

Hello all 😀, This is Shyam… an AI / AR / IoT enthusiast👽.

Shyam
6 min readJul 14, 2021

🏃 Now let’s get into the blog….

“Unfamiliary Python Libraries” :

The most formal definition of Python Library is “A Python library is a reusable chunk of code that you may want to include in your programs/ projects “.But to say in short, 🥶🥶🥶Do you like to write the same code again and again on each program? Or 🤪to conclude with a single line code? The answer defines the usage of library.

Python for GAMES 🎲🎲🎲

  1. freegames 🎮 🎮 🎮 It is an Apache2 licensed collection of free Python games intended for education and fun. The games are written in simple Python code and designed for experimentation and changes.
!pip install freegames
python -m freegames list

#Then to start a particular game just type the name and pops up
python -m freegames.pacman

2.Chess ♟️ ♟️ ♟️ python-chess is a chess library for Python, with move generation, move validation, and support for common formats.

!pip install chess
import chess
board = chess.Board()
board #initializes the chess board

Now, if you like to move the white pawn to 2 steps, just initializing the respective grid value in push_san( ) will achieve the task.

Python for DESIGN 💫💥💫

Yeaahhhh You heard it Right, Python can also help to make cool designs 😎

1.ColabTurtle 🐢 🐢 🐢

!pip install ColabTurtlefrom ColabTurtle.Turtle import *
initializeTimTheTurtle()
---- intialize tutle
for num_sides in range(3,21,1):
print(num_sides)
drawShapes(num_sides)
bgcolor(“#efefef”) ---- background colour

Since we have made the loop with 21 iterations, the turtle will follow the path for 21 cycles and stops.

Language Processing with Python 🤓🤓🤓

1.FuzzyWuzzy 😺 Fuzzy string matching like a boss. It uses Levenshtein Distance to calculate the differences between sequences in a simple-to-use package.

!pip install fuzzywuzzyfrom fuzzywuzzy import fuzzfuzz.ratio(“Let’s do a simple test”, “Let us do a simple test”)

Output: 93 ,The two strings have 93% similarity.

2.EasyOCR 😺 Ready-to-use OCR with 80+ supported languages and all popular writing scripts including Latin, Chinese, Arabic, Devanagari, Cyrillic and etc.

!pip install easyocrimport easyocrreader = easyocr.Reader([‘en’,’ta’])results = reader.readtext(‘/content/test1.jpg’)from IPython.display import Imagedisplay(Image(‘/content/test1.jpg’))text = ‘ ‘for result in results:
text += result[1] + ‘ ‘
print(text)

Here our test image is..

The dominant texts will be detected from the image

FAKE GENERATOR WITH PYTHON 😈

1.Faker 🤡 Faker is a Python package that generates fake data for you. Whether you need to bootstrap your database, create good-looking XML documents, fill-in your persistence to stress test it, or anonymize data taken from a production service, Faker is for you.

!pip install Faker
from faker import Faker
fake = Faker()
# Generating fake email
print(fake.email())
# Generating fake country name
print(fake.country())
# Generating fake name
print(fake.name())

# Generating fake text
print(fake.text())
# Generating fake lat and lon
print(fake.latitude(), fake.longitude())
# Generating fake url
print(fake.url())
# Generating fake profile
print(fake.profile())
# Generating random number
print(fake.random_number())

Just with a one-line fake.email( ) ,it randomly generates an email address

HELP 🤖

  1. Wikipedia

Wikipedia is by far the world’s largest encyclopedia; it is the largest, most comprehensive, and most accessible compilation of knowledge to exist in the history of the human race. …

Wikipedia is a Python library that makes it easy to access and parse data from Wikipedia. Search Wikipedia, get article summaries, get data like links and images from a page, and more.

!pip install wikipediaimport wikipediaresult = wikipedia.page(“ShutterIsland”)print(result.summary)

Lets search for “SHUTTER ISLAND”

Output : Shutter island is a novel by ……………………………………………

2.GoogleTrans

Googletrans is a free and unlimited python library that implemented Google Translate API. This uses the Google Translate Ajax API to make calls to such methods as detect and translate.

Try 😂:“你好 你好 你好 你好 “

Try to Encode the above message using this library

!pip install googletrans==3.1.0a0from googletrans import Translatortranslater = Translator()out = translater.translate(“யாதும் ஊரே யாவரும் கேளிர்”,dest=”en”)print(out.text)

ARUCO MARKER 🥽 🥽 🥽

ArUco markers have a wide usage on precision landing. For drone delivering systems precision landing places a major role . An Aruco marker will be placed on the ground and once the marker was detected based on its position on the frame, the directions will be sent as a command to the flight controller, which in turn makes the required action.

But the usage was wide….😎 Augmented Reality features can also be integrated on the detected markers. Lets see an example

ARUCO 🧙🏽‍♂️ SWIG generated Python wrappers for ArUco library. Works with OpenCV Python module cv2 resp. numpy array data types.

An ArUco marker is a synthetic square marker composed by a wide black border and an inner binary matrix which determines its identifier (id). The black border facilitates its fast detection in the image and the binary codification allows its identification and the application of error detection and correction techniques. The marker size determines the size of the internal matrix. For instance a marker size of 4x4 is composed by 16 bits. Each ArUco marker has a unique Id, like the above marker represents 3.

👻👻👻👻👻👻👻👻👻Thus came to an end Kindly Follow and suggest for next blog.🍁

--

--

Shyam

Hello guys, This is Shyam, a college student who is interested in learning new things.