PLEASE READ: this tutorial assumes that the Dragonfly Java App has been already setup following the instructions available starting from this page.

A Raspberry Pi (RPI) is a cheap, flexible and power-efficient platform that can easily be used as a wireless remote camera for Dragonfly. It can easily stream a video over Ethernet, WiFi or LTE with the proper equipment.

1 – RPI Hardware

The required hardware to create a Raspberry Pi streaming kit is the following one. Everything is very easy to find and to buy online, some ready-to-go kits are also available but usually don’t include a camera.

  • Raspberry Pi motherboard: two different options are available.
    • Raspberry Pi 3 B+: this is the most recent and powerful version of the RPI. For streaming, its main advantage is to have an integrated 5 GHz WiFi controller, which provides a much better connection than the older 2.4 GHz WiFi controller of the other boards.
    • Raspberry Pi Zero W: this is the most compact and power efficient version of the RPI. It is also cheaper than the Raspberry Pi 3 B+, but it only comes with a weak 2.4 GHz WiFi controller.
  • Micro SD card: 16 GB are sufficient to run the OS smoothly. We recommend to purchase a class 10 card to avoid the RPI to be too slow.
  • Raspberry Pi fish eye camera: anyway any RPI wide angle camera with a frame-rate above 30 fps @ 640 x 480 can be used (with a preference for cameras with a FOV lower or equal to 160 degrees – because they are easier to calibrate). Our recommendation is this SainSmart Wide Angle Fish-Eye Camera.
  • (OPTIONAL) the following equipment can be useful in some cases.
    • USB power bank: any USB connector is sufficient to power the RPI. Having a USB power bank allows to have a very mobile streaming device. The power consumption of a RPI is very low and can run hours on the smallest available power bank. Feel free to choose among the most compact power banks capable of providing an output of at least 2 Ampere.
    • Case: there are a bunch a cases for the different RPI models. They are often already provided with ready-to-go kits.
    • HDMI cable, USB keyboard and USB mouse: useful if you want to use the user interface to configure the RPI the first time. It is also possible to configure the RPI in headless mode though, as explained below.

USB ASTAR stereo camera: can’t be used on Raspberry Pi because it seems that the USB 2.0 port of the RPi is not able to deliver enough power.

2 – RPI setup

2.1 – Camera physical connection

Those marked in BLUE are the slots to be used to connect the SainSmart Wide Angle Fish-Eye Camera to the RPI.

Raspberry Pi 3 B+ board

Raspberry Pi Zero W board

2.2 – Setup Raspbian Stretch

OPTION 1 – Using the RPI graphic interface

Install the operating system

  1. Download on your computer the latest version of Raspbian Stretch with desktop here.
  2. Download on your computer Etcher here.
  3. Insert your micro SD card in your computer, and use Etcher to flash it with the downloaded image of Raspbian Stretch with desktop.
  4. Insert the micro SD card in the Raspberry Pi.
  5. Plug your RPI to a monitor, plug a USB keyboard and mouse, and power the RPI.
  6. Follow the configuration wizard and connect your RPI to a Wi-Fi network.

Enable the SSH server and the Camera interface

You need to plug the camera to your RPI before following the instructions below.

  1. Open the LX Terminal on your RPI.
  2. Run the command:
  3. Select Interfacing Options > SSH and enable the SSH server.
  4. Select Interfacing Options > Camera and enable the Camera interface.
  5. Select Advanced Options > Expand filesystem.
  6. Go back to the main screen click on Finish and confirm the reboot.

OPTION 2 – Without the RPI graphic interface (headless mode)

Install the operating system

  1. Download on your computer the latest version of Raspbian Stretch Light here.
  2. Download on your computer Etcher here.
  3. Insert your micro SD card in your computer, and use Etcher to flash it with the downloaded image of Raspbian Stretch Light.
  4. Open a terminal window and cd to the micro SD card using the following command:
  5. In the boot drive, create a file called ssh. Just an empty file with exactly that name.
  6. In the boot drive, create a file called  wpa_supplicant.conf.
  7. Take an editor of your choice and add this to wpa_supplicant.conf and change YOUR_SSID and YOUR_PSK parts according to your environment:
  8. Insert the micro SD card in RPI and power it ON.

Connection problems: if you have problems connecting your RPI to the WiFi network it could be that the key_mgmt field does not contain the right value for the WiFi connection used. Please check this file for the values that can be assigned to the key_mgmt field.

Enable the Camera interface

You need to plug the camera to your RPI before following the instructions below.

  1. Open the terminal on your PC.
  2. Find the local IP assigned to your RPI (ip_of_the_pi) and run the command (password is raspberry):
  3. Run the command:
  4. Select Interfacing Options > Camera and enable the Camera interface.
  5. Select Advanced Options > Expand filesystem.
  6. Go back to the main screen click on Finish and confirm the reboot.

2.3 – Setup Gstreamer

We use Gstreamer to stream the video. To install it enter the following commands on your RPI:

2.4 – Make your RPI a RTSP server

To make the RPI video stream a RTSP stream accessible you have to enter the following commands on your RPI:

  1. Check the Gstreamer version with this command:
  2. On this site look for the URL of the Gstreamer RTSP server compatible with the Gstreamer version installed at section 2.3
  3. Install the Gstreamer RTSP server by using these commands:
  4. Install the raspivid wrapper with these commands:

3 – Calibration of the camera

3.1 – Enable the RTSP stream

  1. On the RPI launch this command:
  2. The command above should return this:
  3. Leave this terminal opened and DON’T STOP THIS COMMAND.

3.2 – Convert the RTSP stream into a MJPEG stream

Open a terminal on your PC and follow these steps:

  1. Install Node.js on your system following one of these tutorial. Example: if you are using Ubuntu you can install it using these 2 lines:
  2. Launch these commands to clone the Accuware proxy used to convert a RTSP stream into a MJPEG stream and install all the needed dependencies:
  3. Open the server.js file with your favorite editor:
  4. Comment all the URL lines except for one line that should be changed like this:
  5. Save the file.
  6. Launch this command to activate the proxy:

3.3 – Perform the calibration

  1. Open the browser on your PC and call the following URL from the browser:
  2. Follow the instructions available inside the Dragonfly Web Calibration Tool.
  3. At the end of the calibration process:
    1. click on the Download button and download the JSON calibration file generated by the calibration tool.
    2. place the JSON calibration file inside the config folder (cd dragonfly_linux/application/Dragonfly2Java_jar/config).

4 – Make use of the RTSP stream inside the Dragonfly Java App

4.1 – Enable the RTSP stream

  1. On the RPI launch this command:
  2. The command above should return this:
  3. Leave this terminal opened and DON’T STOP THIS COMMAND.

4.2 – Connect the Dragonfly Java App to the RTSP stream

  1. If not already done please setup the Dragonfly Java App following carefully the instructions available starting from this page.
  2. Launch the Dragonfly Java Web UI.
  3. Click on the Configuration tab and set:
    1. the CAM_SOURCE parameter to the following string (where ip_of_the_pi is the local IP address assigned to the RPI):

    2. the CAM_CALIBRATION_FILE parameter to the name of the JSON calibration file placed inside the config folder at the root of the Dragonfly Java App installation folder (cd dragonfly_linux/application/Dragonfly2Java_jar/config)
  4. Click on Save and Restart.

The Raspberry Pi can now be used as a remote camera for Dragonfly. All the information about the Dragonfly Java App can be found inside this page.