Raspberry Pi_Eng_23.0 Chapter 23 Writing Program

Chapter 23 Writing Program

Chapter’s Main Topics

This chapter describes the way and procedures to create various programs in Raspberry Pi system. It shows you how to do various tasks in the system with simple operation without writing a program yourself. It also shows how to use the full-fledged program development language like Python, C, and Java.

It includes descriptions on the following topics:
■ Overview of program basics
■ Mathematica or Wolfram language
■ Sonic Pi
■ Scratch language
■ Python language
■ C language
■ Java language

Raspberry Pi_Eng_22.2.2 MUTT Program – Mail Transmitting Auxiliary Tool

22.2.2 Program – Mail Transmitting Auxiliary Tool

As described in the previous section, ff you have only mail transport agent, you can send mail, but there are many inconveniences. When sending mail from the Shell, we have to enter a sender, a recipient, a body of the mail, etc. in the mail contents at once, and we can not transmit an attachment file.

Raspberry Pi_Eng_22.2.1 SSMTP Program – Mail Transfer Agent

22.2 Using E-mail

22.2.1 Program – Mail Transfer Agent

We can send E-mails to others via our own E-mail server, such as gmail.com or hanmail.net usually with outlook or other tools.

We can send E-mail via E-mail server that we use through Raspberry Pi also. To do this, we need a MTA(Mail Transfer Agent) program that sends E-mail by connecting to E-mail server.

Raspberry Pi_Eng_22.1.8 Motion Detecting Web Camera – Motion Program

22.1.8 Motion Detecting Web Camera – Program

22.1.8.1 Framework to Access Camera via Web

program is a program that monitors video signals coming from a camera. It has the ability to detect if there is a significant change in the image, that is, motion. This program not only has a function to view the contents on the web in real time by transmitting a video taken by a camera to the Internet, but also has a function of storing the motion as an image or video when a motion is detected on the screen.

Raspberry Pi_Eng_22.1.6 Viewing Video on an External Computer

22.1.6 Viewing Video on an External Computer

Here we talk about how to view video taken in Raspberry Pi on an external computer through a network.

There are a number of ways to view video over the network, but here we explain the way to use program.

22.1.6.1 Basic framework to Transmit/Receive Video Data

Here, we want to use the following framework for video transmission and reception.

Raspberry Pi_Eng_22.1.5 Converting Video Format Using FFMPEG Program

22.1.5 Converting Video Format Using Program

Video taken by Raspberry Pi camera use “H.264” format, which is a format that is not widely used by ordinary users. You can use program to convert it to a popular video format.

● Installing program

To use program, you need to install it as follows:

Raspberry Pi_Eng_22.1.4 Playing Video Contents

22.1.4 Playing Video Contents

Here, we’ll look at the tools that can be used to play videos on the Raspberry Pi system.

22.1.4.1 Playing Video Using Program

OMXPlayer is a program installed in Raspberry Pi system by default. It can play not only video files recorded with Raspberry Pi camera but also general videos in Raspberry Pi system.

Raspberry Pi_Eng_22.1.3 Taking Picture and Video Using Pi Camera

22.1.3 Taking Picture and Video Using Pi Camera

22.1.3.1 Overview of Shooting Command for Pi Camera

With Raspberry Pi’s dedicated camera, you can run the following commands. They have functions that can shoot a still image or take a movie according to a command.

■ “raspistill” command

. This command captures still images. The captured image is saved as “jpg” file.

Raspberry Pi_Eng_22.1.2 Processing API for Raspberry Pi Camera

22.1.2 Processing API for Raspberry Pi Camera

In the Raspberry Pi system, MMAL method and V4L2 method can be used as processing API for the Raspberry Pi camera function.

22.1.2.1 MMAL (Multi-Media Abstraction Layer)

The Raspberry Pi A+/B+ system uses a BCM2835 system board made by the Broadcom, where the graphics processing GPU is VideoCore Ⅳ.