Streams real-time video from a Raspberry Pi to a Google Cardboard VR Display (Android)
- Raspberry Pi 2
- 8GB MicroSD Card loaded with NOOBS
- Micro USB power supply
- Raspberry Pi Camera Module
- Mini Pan-Tilt Kit
- 16-Channel PWM HAT for Raspberry Pi
- Power supply for 16-Channel PWM HAT
- A good Android phone (I'm using a Moto X Pure)
- A Google Cardboard kit. I highly recommend Mattel's plastic headset.
When I built this (January 2016), it cost about $150 in total, not including the phone.
- Installing packages
- uv4l to stream video from the RPi Camera
$ sudo apt-get update $ sudo apt-get install uv4l uv4l-raspicam uv4l-server uv4l-webrtc
- Pip and Flask for the web server
$ sudo apt-get install python-pip $ sudo pip install flask
- packages to enable i2c
$ sudo apt-get install python-smbus $ sudo apt-get install i2c-tools
- Follow these instructions to set up the servos and pan-tilt kit.
- Attach the tilt servo to channel 0 and the pan servo to channel 3 (the channel choices can be configured in server.py.
- Clone this repo on your RPi and a computer that can run Android Studio.
$ git clone https://github.com/nichhk/cardboardstream.git
- Begin streaming the video on the RPi.
$ uv4l --driver raspicam --auto-video_nr --server-option '--port=5000' --encoding mjpeg --server-option '--enable-webrtc' --width 256 --height 288 --framerate 24 --vflip --hflip
This command will open up an MJPEG stream of the video on port 5000. You can specify the width, height, and framerate for the stream. I flipped the stream vertically and horizontally because of how my camera is attached to the pan-tilt module.
- Run the webserver on the RPi.
$ cd /path/to/server
$ sudo python server.py
- Run the app on your Android device.
- Enter the RPi's IP address. You can find it using
ifconfig
. - The RPi and Android device must be on the same local network.
- Enjoy!