Reader small image

You're reading from  Computer Vision Projects with OpenCV and Python 3

Product typeBook
Published inDec 2018
Reading LevelIntermediate
PublisherPackt
ISBN-139781789954555
Edition1st Edition
Languages
Tools
Right arrow
Author (1)
Matthew Rever
Matthew Rever
author image
Matthew Rever

Matthew Rever received his PhD. in electrical engineering from the University of Michigan, Ann Arbor. His career revolves around image processing, computer vision, and machine learning for scientific research applications. He started programming in C++, a language he still uses today, over 20 years ago, and has also used Matlab and most heavily Python in the past few years, using OpenCV, SciPy, scikit-learn, TensorFlow, and PyTorch. He believes it is important to stay up to date on the latest tools to be as productive as possible. Dr. Rever is the author of Packt's Computer Vision Projects with Python 3 and Advanced Computer Vision Projects.
Read more about Matthew Rever

Right arrow

Plate utility functions

Let's jump to our code in Jupyter Notebook, in order to understand plate utility functions. We will first embed the imports with our utilities.

We will be importing the following libraries:

  • OpenCV (version 3.4)
  • NumPy
  • Pickle, which lets us save Python data and case functions

Import the libraries as follows:

import cv2
import numpy as np
import pickle
def gray_thresh_img(input_image):
h, w, _ = input_image.shape
grayimg = cv2.cvtColor(input_image, cv2.COLOR_BGR2HSV)[:,:,2]

kernel = cv2.getStructuringElement(cv2.MORPH_RECT, (3, 3))

tophat = cv2.morphologyEx(grayimg, cv2.MORPH_TOPHAT, kernel)
blackhat = cv2.morphologyEx(grayimg, cv2.MORPH_BLACKHAT, kernel)
graytop = cv2.add(grayimg, tophat)
contrastgray = cv2.subtract(graytop, blackhat)
blurred = cv2.GaussianBlur(contrastgray, (5,5), 0)
thesholded = cv2.adaptiveThreshold...
lock icon
The rest of the page is locked
Previous PageNext Page
You have been reading a chapter from
Computer Vision Projects with OpenCV and Python 3
Published in: Dec 2018Publisher: PacktISBN-13: 9781789954555

Author (1)

author image
Matthew Rever

Matthew Rever received his PhD. in electrical engineering from the University of Michigan, Ann Arbor. His career revolves around image processing, computer vision, and machine learning for scientific research applications. He started programming in C++, a language he still uses today, over 20 years ago, and has also used Matlab and most heavily Python in the past few years, using OpenCV, SciPy, scikit-learn, TensorFlow, and PyTorch. He believes it is important to stay up to date on the latest tools to be as productive as possible. Dr. Rever is the author of Packt's Computer Vision Projects with Python 3 and Advanced Computer Vision Projects.
Read more about Matthew Rever