Reader small image

You're reading from  Hands-On Vision and Behavior for Self-Driving Cars

Product typeBook
Published inOct 2020
PublisherPackt
ISBN-139781800203587
Edition1st Edition
Tools
Right arrow
Authors (2):
Luca Venturi
Luca Venturi
author image
Luca Venturi

Luca Venturi has extensive experience as a programmer with world-class companies, including Ferrari and Opera Software. He has also worked for some start-ups, including Activetainment (maker of the world's first smart bike), Futurehome (a provider of smart home solutions), and CompanyBook (whose offerings apply artificial intelligence to sales). He worked on the Data Platform team at Tapad (Telenor Group), making petabytes of data accessible to the rest of the company, and is now the lead engineer of Piano Software's analytical database.
Read more about Luca Venturi

Krishtof Korda
Krishtof Korda
author image
Krishtof Korda

Krishtof Korda grew up in a mountainside home over which the US Navy's Blue Angels flew during the Reno Air Races each year. A graduate from the University of Southern California and the USMC Officer Candidate School, he set the Marine Corps obstacle course record of 51 seconds. He took his love of aviation to the USAF, flying aboard the C-5M Super Galaxy as a flight test engineer for 5 years, and engineered installations of airborne experiments for the USAF Test Pilot School for 4 years. Later, he transitioned to designing sensor integrations for autonomous cars at Lyft Level 5. Now he works as an applications engineer for Ouster, integrating LIDAR sensors in the fields of robotics, AVs, drones, and mining, and loves racing Enduro mountain bikes.
Read more about Krishtof Korda

View More author details
Right arrow

Working with image files

OpenCV provides a very simple way to load images, using imread():

import cv2
image = cv2.imread('test.jpg')

To show the image, you can use imshow(), which accepts two parameters:

  • The name to write on the caption of the window that will show the image
  • The image to be shown

Unfortunately, its behavior is counterintuitive, as it will not show an image unless it is followed by a call to waitKey():

cv2.imshow("Image", image)cv2.waitKey(0)

The call to waitKey() after imshow() will have two effects:

  • It will actually allow OpenCV to show the image provided to imshow().
  • It will wait for the specified amount of milliseconds, or until a key is pressed if the amount of milliseconds passed is <=0. It will wait indefinitely.

An image can be saved on disk using the imwrite() method, which accepts three parameters:

  • The name of the file
  • The image
  • An optional format-dependent parameter:
  • ...
Previous PageNext Page
You have been reading a chapter from
Hands-On Vision and Behavior for Self-Driving Cars
Published in: Oct 2020Publisher: PacktISBN-13: 9781800203587
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.
undefined
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 €14.99/month. Cancel anytime

Authors (2)

author image
Luca Venturi

Luca Venturi has extensive experience as a programmer with world-class companies, including Ferrari and Opera Software. He has also worked for some start-ups, including Activetainment (maker of the world's first smart bike), Futurehome (a provider of smart home solutions), and CompanyBook (whose offerings apply artificial intelligence to sales). He worked on the Data Platform team at Tapad (Telenor Group), making petabytes of data accessible to the rest of the company, and is now the lead engineer of Piano Software's analytical database.
Read more about Luca Venturi

author image
Krishtof Korda

Krishtof Korda grew up in a mountainside home over which the US Navy's Blue Angels flew during the Reno Air Races each year. A graduate from the University of Southern California and the USMC Officer Candidate School, he set the Marine Corps obstacle course record of 51 seconds. He took his love of aviation to the USAF, flying aboard the C-5M Super Galaxy as a flight test engineer for 5 years, and engineered installations of airborne experiments for the USAF Test Pilot School for 4 years. Later, he transitioned to designing sensor integrations for autonomous cars at Lyft Level 5. Now he works as an applications engineer for Ouster, integrating LIDAR sensors in the fields of robotics, AVs, drones, and mining, and loves racing Enduro mountain bikes.
Read more about Krishtof Korda