Book Image

BeagleBone By Example

By : Pei JIA, Jayakarthigeyan Prabakar, Alexander Hiam
Book Image

BeagleBone By Example

By: Pei JIA, Jayakarthigeyan Prabakar, Alexander Hiam

Overview of this book

BeagleBone is a low cost, community-supported development platform to develop a variety of electronic projects. This book will introduce you to BeagleBone and get you building fun, cool, and innovative projects with it. Start with the specifications of BeagleBone Black and its operating systems, then get to grips with the GPIOs available in BeagleBone Black. Work through four types of exciting projects: building real-time physical computing systems, home automation, image processing for a security system, and building your own tele-controlled robot and learn the fundamentals of a variety of projects in a single book. By the end of this book, you will be able to write code for BeagleBone in order to operate hardware and impart decision-making capabilities with the help of efficient coding in Python.
Table of Contents (17 chapters)
BeagleBone By Example
Credits
About the Author
About the Reviewer
www.PacktPub.com
Preface
Index

Project: Image capture from a camera using Python and OpenCV


In this chapter we will be writing a code to capture an image from a camera and saving it in .jpg format using Python.

Let's first create a directory named ImageCapture inside which we can save the Python file in which we write the code, and where we can also save the image file that we capture:

  • mkdir ImageCapture

  • cd ImageCapture

It will look like the following screenshot:

  • sudo nano TakePhoto.py

    Refer to the following image:

Now we can go ahead and start writing the code to capture an image from the camera and save it on the BeagleBone Black:

The simplest code possible to do this is given in the following screenshot:

Save it and run it to capture an image from the camera and save it.

The output you will see when you run the code sudo python TakePhoto.py is as shown in the following screenshot:

If you don't get any errors and the program ends printing the Saving Image text, everything should have happened properly. To check this let...