Close

The soft side of things

A project log for Mockulus Thrift IR

Raspberry Pi, composite video 480P screen, IR LEDs, and a 3D printer. See in the dark.

joeJoe 01/12/2016 at 18:390 Comments

Today I have begun working on the software aspect of the project as I don't currently have access to the 3D modeling resources I was using yesterday, which involves two main parts. The first is the python script that opens the video file stream to be displayed on the screen using the picamera library. The code has mostly been copied, and the complete documentation can be found here.

import io
import picamera

stream = io.BytesIO()
with picamera.PiCamera() as camera:
    camera.resolution = (640, 480)
    camera.start_recording(stream, format='h264', quality=23)
    fullscreen = TRUE
    camera.wait_recording(15)
    camera.stop_recording()

The second main part is the launcher script, which was created with help from this tutorial on instructables. This script is necessary because as soon as the goggles are turned on, the pi boots and needs to start displaying the feed with no user input, as there will be no user input devices connected. The python file is called "NVG.py" and can be found in the NVG folder in the root directory. It also needs to be made executable, as illustrated in the tutorial.

#!/bin/sh
# launcher.sh
# navigate to home directory, then to this directory, then execute the script, then back home

cd /
cd home/pi/NVG
sudo python NVG.py
cd /

The crontab background process needs to be modified so that the file runs on startup, using the following lines:

sudo crontab -e
@reboot sh /home/pi/bbt/launcher.sh >/home/pi/logs/cronlog 2>&1

Now the NVG.py file should be launched on startup and the video stream should be displayed to the screen.

Discussions