ТОП просматриваемых книг сайта:
Raspberry Pi For Dummies. Sean McManus
Читать онлайн.Название Raspberry Pi For Dummies
Год выпуска 0
isbn 9781119796879
Автор произведения Sean McManus
Жанр Компьютерное Железо
Издательство John Wiley & Sons Limited
ls
You can use lots of different options to take still photos, too. This example takes a shot with the pastel filter and flips the picture horizontally (-hf
) and vertically (-vf
):
raspistill -ifx pastel -hf -vf -o testshot2.jpg
All those hyphens and letter combinations might seem a bit random to you now, but after you read Chapter 5, they should make more sense. To see the documentation for raspistill
, type
raspistill | less
Use the down-arrow key to move through the information, and press Q to finish.
Your photos are stored in your pi
directory. See Chapter 4 for instructions on how to use File Manager to find your files and Image Viewer to see them.
To shoot video, you use raspivid
. Enter this command to shoot a 5-second film:
raspivid -o testvideo.h264 -t 5000
The video is saved with the filename testvideo.h264
and is 5000 milliseconds (5 seconds) long. You can view the video you made using
omxplayer testvideo.h264
The video footage is captured as a raw H264 video stream. For greater compatibility with media players, it's a good idea to convert it to an MP4 file. Start by installing MP4Box using this command:
sudo apt install gpac
Then you can convert your video file (called testvideo.h264
) into an MP4 file (called testvideo.mp4
) like this:
MP4Box -add testvideo.h264 testvideo.mp4
You can get help on using raspivid
with
raspivid | less
There is also a library called picamera that you can use in Python to access the camera from your own Python programs. By adding the Video Sensing extension in Scratch, you can use the camera to make onscreen characters react to movement in the video.
For more information on using the Raspberry Pi Camera Module, see the documentation at www.raspberrypi.org/documentation/usage/camera
.
Connecting Using SSH
If your Raspberry Pi has a network connection, you should be able to access it with another computer on the same network using Secure Shell (also known as SSH), which is a way to make a secure connection between computers. This can be helpful if you have set up your Pi to use it headerless (without a screen). Here's how to set it up:
1 Change your password.To prevent unauthorized access to your Raspberry Pi after a remote connection is enabled, start by changing your password. You can use the Raspberry Pi Configuration tool (see “Configuring Your Raspberry Pi in Raspberry Pi OS,” earlier in this chapter), or see Chapter 5 for instructions on changing the password in the command line.
2 Enable SSH on your Pi.Use the Raspberry Pi Configuration tool to enable SSH on the Interfaces tab. Alternatively, use this instruction to create an empty file in the boot directory called ssh and then reboot your Pi:sudo touch /boot/ssh
3 Get your Pi's IP address.Use ifconfig in the command line to get your Raspberry Pi’s IP address (shown as inet on wlan0 for a WiFi connection or on eth0 for an Ethernet connection).
4 Connect from your other device.In Windows 10, macOS, and Linux, the SSH software is already installed. You can use it from the command line by typing in ssh [email protected]. You replace the numbers with your Raspberry Pi's IP address. If you changed the username on your Raspberry Pi, change pi too. If you’re using a computer that doesn’t have SSH software, or you prefer to use a graphical interface, you can download an SSH client such as Putty. In Putty, you input the IP address of your Raspberry Pi and click the Open button. After you enter your Pi’s password, you can use the command line on the Raspberry Pi to manage and fix files, viewing it through your PC screen and using your PC keyboard. SSH apps are also available for the iPhone/iPad and Android. You can find fuller instructions for using SSH on your other machine at www.raspberrypi.org/documentation/remote-access/ssh
.
You can only use SSH to access the Raspberry Pi command line, not the desktop.
Connecting Using VNC
Using VNC, you can control your Raspberry Pi’s desktop environment from another computer. If you register for a RealVNC account, you can access your Raspberry Pi over the public Internet. Just follow these steps:
1 Change your password.To prevent unauthorized access to your Raspberry Pi after a remote connection is enabled, start by changing your password. You can use the Raspberry Pi Configuration tool (see “Configuring Your Raspberry Pi in Raspberry Pi OS,” earlier in this chapter), or see Chapter 5 for instructions on changing the password in the command line.
2 Enable VNC on your Pi.Use the Raspberry Pi Configuration tool to enable VNC on the Interfaces tab.
3 Get your Pi’s IP address.Click the VNC icon, which appears in the upper right of your desktop. The window that opens shows you the IP address you need to connect to your Pi.
4 Install VNC Viewer.You’ll need to install VNC Viewer on the device you want to connect from. You can download it at www.realvnc.com/en/connect/download/viewer
. Apps are available for Windows, macOS, and Linux. If you want to manage one Raspberry Pi from another, there’s a version of VNC Viewer for the Raspberry Pi, too. Apps for Android and iOS are available, but they’re quite hard to use without a physical mouse and keyboard.
5 Connect from your other device.Run VNC Viewer, and you’ll be prompted to enter a VNC server address. This is the IP address displayed by your Raspberry Pi. The first time you connect, VNC Viewer warns you that it hasn’t connected to this device before. Click Continue. When you enter your username and password, a window opens that shows your Raspberry Pi screen. You can now control your Raspberry Pi remotely.
Using VNC, you can share a keyboard and mouse between your PC and your Raspberry Pi. Connect them to your PC; then use VNC to control your Raspberry Pi from your PC.
Part 2
Getting Started with Linux
IN THIS PART …
Use the Raspberry Pi desktop to manage the files and start the programs on your Raspberry Pi.
Discover some of the games and applications provided in Raspberry Pi OS.
Surf the web and manage bookmarks for your favorite sites.
Watch