Making pictures and videos with the Spirit rover

The more technical aspects of Spirit, and carry-over discussion from Kickstarter updates.
User avatar
Marcel-Jan
Posts: 4
Joined: Thu Sep 21, 2017 8:00 pm

Making pictures and videos with the Spirit rover

Postby Marcel-Jan » Sat Sep 23, 2017 10:15 pm

I'm having fun making the first steps using Python 3 on a Raspberry Pi. My first program was to make a picture with the picamera. It's really easy. I have used the steps from the Raspberry Pi website (https://www.raspberrypi.org/learning/getting-started-with-picamera/worksheet/)

Python 3 is already installed. So you don't have to do that.
0. First make sure you have an internet connection. Probably that would be Wifi, because the Ethernet port is blocked by Spirit rover's frame.
1. You do have to install the picamera library (to my best memory). Python's pip/pip3 is like an app store for Python libraries. You can use it from a terminal:
On the start menu go to Accesoires --> Terminal
Type:
sudo pip3 install picamera

2. You need to activate the camera. From the Start Menu go to Preferences --> Raspberry Pi Configuration.
Go to the tab Interfaces. Here enable the Camera. In my case I had to reboot now.

3. Start the Python 3 shell. From the Start Menu go to Programming --> Python 3 (IDLE).
Make a new file (File --> New File)

4. Type the following code:
(I've put the camera.rotation in this code, because in the first attempt the photo was upside down)

Code: Select all

from picamera import PiCamera
from time import sleep

camera = PiCamera()
camera.rotation = 180

camera.start_preview()
camera.capture('/home/pi/Desktop/picam_test01.jpg')
sleep(10)
camera.stop_preview()


Save this file. Now you can run the code right away by pressing F5. Don't forget to smile if you aim the camera at yourself :D

5. Look in /home/pi/Desktop. There should be a file called picam_test01.jpg.

User avatar
Marcel-Jan
Posts: 4
Joined: Thu Sep 21, 2017 8:00 pm

Re: Making pictures and videos with the Spirit rover

Postby Marcel-Jan » Sat Sep 23, 2017 10:27 pm

Forgot to add how to make a video.

Change your code to this:

Code: Select all

from picamera import PiCamera
from time import sleep

camera = PiCamera()
camera.rotation = 180

camera.start_preview()
camera.start_recording('/home/pi/Desktop/picam_video_01.h264')
sleep(10)
camera.stop_recording()
camera.stop_preview()


It will record 10 seconds of video. But how to watch it?
From the terminal run this:

Code: Select all

omxplayer /home/pi/Desktop/picam_video_01.h264

stardusts
Posts: 5
Joined: Wed Nov 01, 2017 10:40 am

Re: Making pictures and videos with the Spirit rover

Postby stardusts » Thu Nov 09, 2017 12:48 pm

I tried it and it works fine! However the pic and videos seems a lot under exposure ( very dim) did u face the same issue ?


Who is online

Users browsing this forum: No registered users and 2 guests