Search icon CANCEL
Subscription
0
Cart icon
Cart
Close icon
You have no products in your basket yet
Save more on your purchases!
Savings automatically calculated. No voucher code required
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
The Computer Vision Workshop

You're reading from  The Computer Vision Workshop

Product type Book
Published in Jul 2020
Publisher Packt
ISBN-13 9781800201774
Pages 568 pages
Edition 1st Edition
Languages
Authors (3):
Hafsa Asad Hafsa Asad
Profile icon Hafsa Asad
Vishwesh Ravi Shrimali Vishwesh Ravi Shrimali
Profile icon Vishwesh Ravi Shrimali
Nikhil Singh Nikhil Singh
Profile icon Nikhil Singh
View More author details
Toc

4. Working with contours

Activity 4.01: Identifying a Character on a Mirrored Document

Solution:

  1. Open Jupyter Notebook. Go to File | New File. A new file will open. Save it as Activity4.01.ipynb.
  2. Import the OpenCV library:
    import cv2
  3. Read the image of the handwritten note as follows:
    image = cv2.imread('phrase_handwritten.png')
  4. Save a copy of this image. You will mark the bounding box on this copy at the end of the activity:
    imagecopy= image.copy()
  5. Convert the image to grayscale as follows:
    gray_image = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
  6. Now, convert the image into binary and display it as follows:
    ret,binary_im = cv2.threshold(gray_image,0,255,\
                                  cv2.THRESH_OTSU) 
    cv2.imshow('binary image', binary_im)
    cv2.waitKey(0) 
    cv2.destroyAllWindows()

    The preceding code...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime}