A walkthrough on how we can capture images/videos in the wild non-invasively.
An Operating System (OS) is an interface between a computer user and computer hardware. Your Raspberry Pi needs an operating system to work. It uses Linux, and in particular Raspbian.
To install an operating system, you'll need two things: an image file, and a program that will write it to your SD card.
Raspberry Pi OS can be installed using the Raspberry Pi Imager.
Raspberry Pi Imager
Follow the steps below to install Raspberry Pi OS on your Raspberry Pi:
A Raspberry Pi is considered headless when you have no monitor or keyboard connected to it. A headless Raspberry Pi can be useful for any situation where you don't want or need access to a monitor and keyboard.
You can use the following to make a headless connection to your Raspberry Pi:
PuTTY is a software terminal emulator for Windows and Linux. It provides a text user interface to remote computers running any of its supported protocols, including SSH and Telnet.
VNC Viewer is a graphical desktop sharing system that allows a user to remotely control the desktop of a remote computer (running VNC Server) from your device, and it transmits the keyboard and mouse or touch events to VNC Server, so that once you are connected, you have control over the computer you've accessed.
At this point, we should all have connected to our Raspberry Pi headless.
Python is a programming language that lets you work quickly and integrate systems more effectively. It is a powerful tool for prototyping and developing production-ready code.
Type the following commands in the terminal to get started with Python:
python3
print("Hello World")
Use the following command to get the IP address of your Raspberry Pi:
hostname -I
Now we will use a series of commands and learn how to make a directory, change directories, list directories. We will also learn how to create, edit, save and run a Python file.
Create a directory called DSAIL:
mkdir DSAIL
Change the directory to DSAIL:
cd DSAIL
List the files in the directory:
ls
Create and edit a file called hello.py:
nano hello.py
print("Hello World")
# Press Ctrl + S to save
# Press Ctrl + X to exit
Run the Python file:
python3 hello.py
Now that we have a basic understanding of Python, we can now capture images/videos using the Raspberry Pi camera.
We will use the libcamera command. This command is used to capture images using the Raspberry Pi camera.
Use the following command on the terminal to capture an image and save it on the desktop:
libcamera-jpeg -o Desktop/test.jpg
Use the following command on the terminal to capture a video and save it on the desktop:
libcamera-vid -t 10000 -o Desktop/test.h264
For more examples, use this guide.
Alternatively, you can use a USB camera to capture the images. Use the following command on the terminal to capture an image and save it on the desktop:
fswebcam -r 1280x720 --no-banner Desktop/image1.jpg
For more examples, use this guide.
While out in the field, we cannot do this every time we need an image or video captured. So we use Python scripts to capture images/videos at a specified time interval.
These Scripts are available in the cloned repository: ieee-africon-2023, in the
camera-trap folder.
Scripting is a way by which one can alleviate this necessity by automating these command sequences in order to make one's life at the shell easier and more productive.
Scripts can be used for a variety of purposes, such as to test how well the operating system performs certain tasks, to automate the steps in a software application's installation process, and to add functions to a Web page.
Bash scripts are used by Systems Administrators, Programmers, Network Engineers, Scientists and just about anyone else who uses a Linux/Unix system regularly.
To automate the process of capturing multiple images or videos, you can use Python, Bash scripts, and crontab. For example, you can write a Python script that captures an image every 5 minutes and saves it with a timestamped filename. Then, you can use a Bash script to run this Python script at regular intervals using crontab.
Here's an example Bash script that runs the above Python script every 5 minutes to capture an image using a Pi Camera:
#!/bin/bash
# Change to the directory where the Python script is located
cd /home/pi/camera_trap
# Run the Python script to capture an image
python3 capture_image.py
The crontab is a list of commands that you want to run on a regular schedule, and also the name of the command used to manage that list.
The crontab command opens the crontab for editing, and lets you add, remove, or modify scheduled tasks.
Make sure to make this script executable by running chmod +x /path/to/script.sh.
Then, you can use crontab to run this script at regular intervals. For example, to run the
script at reboot, you can add the following line to your crontab:
@reboot /path/to/script.sh
The power management software enables the Raspberry Pi to control the DSAIL Power Management Board. The figure below shows the flowchart of the power management software.
Power Control Software Flowchart