Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Python Game Programming By Example

You're reading from   Python Game Programming By Example A pragmatic guide for developing your own games with Python

Arrow left icon
Product type Paperback
Published in Sep 2015
Publisher
ISBN-13 9781785281532
Length 230 pages
Edition 1st Edition
Languages
Tools
Arrow right icon
Toc

Configuring cameras


OpenCV provides a class, called cv2.VideoCapture, that represents a stream of images from either a video file or a camera. This class has methods such as read(image) for exposing the stream's next image as a NumPy array. It also has the get(propId) and set(propId, value) methods for accessing properties such as the width and height (in pixels), color format, and frame rate. The valid properties and values may depend on the system's video codecs or camera drivers.

Across cameras, the default property values may differ dramatically. For example, one camera might default to an image size of 640 x 480, while another may default to 1920 x 1080. For greater predictability, we should try to set crucial parameters rather than rely on the defaults. Let's create a module called ResizeUtils containing a utility function to configure the image size.

The ResizeUtils module begins by importing the CVBackwardCompat instance of cv2, which may contain aliases (depending on the OpenCV version...

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 $19.99/month. Cancel anytime