The directions below were explicitly written/documented for the purpose of being used with Neptune Systems Apex Fusion. The process can be adapted for use with just about anything(embedded in a webpage, directly opened in a browser, etc).
How-To Setup Raspberry Pi Camera Stream For Use With Apex Fusion
Start with this basic tutorial on how to setup ["MJPG-Streamer on the Raspberry Pi"](http://blog.miguelgrinberg.com/post/how-to-build-and-run-mjpg-streamer-on-the-raspberry-pi)". Stop at the end of step 6. If you follow that tutorial all the way through it's not the end of the world, but step 7 & 8 will need to be done every few minutes and each reboot to keep the stream alive. So I've documented a process to automatically start the stream on boot and restart it every minute to keep it alive below:
How-To Setup Raspberry Pi Camera Stream For Use With Apex Fusion
Start with this basic tutorial on how to setup ["MJPG-Streamer on the Raspberry Pi"](http://blog.miguelgrinberg.com/post/how-to-build-and-run-mjpg-streamer-on-the-raspberry-pi)". Stop at the end of step 6. If you follow that tutorial all the way through it's not the end of the world, but step 7 & 8 will need to be done every few minutes and each reboot to keep the stream alive. So I've documented a process to automatically start the stream on boot and restart it every minute to keep it alive below:
- Start with a RaspberryPi loaded with raspbian
- Login to your Raspbery Pi.
- sudo su
- vi /etc/init.d/raspi-stream
Code:
#!/bin/sh
/root/start-raspi-stream.sh`
- Hit esc, then :wq to write the file and quit vi
- vi /root/start-raspi-stream.sh
Code:
#!/bin/sh
# If you're having issues with the script you can uncomment the echo ... lines debugging purposes to see where it's getting hung up.`
# You can also remove the ">/dev/null 2>&1 &" from the end the lines to stop the redirection of stderr and stdout which was
# implemented to prevent filling up the disk with error messages.
# echo "start-raspi-stream.sh - scipt started at $(date)" >> /root/start-raspi-stream.log
ps -ef | grep raspistill | grep -v grep | awk '{print }' | xargs kill -9
# echo "kill existing raspistill processes ran at $(date)" >> /root/start-raspi-stream.log
mkdir -p /tmp/stream
# echo "mkdir -p /tmp/stream ran at $(date)" >> /root/start-raspi-stream.log
# Explanation of basic user adjustable camera parameters:
# -rot X = rotate image X degrees
# -w # = image width X pixels
# -h # = image height X pixels
# See [URL]https://www.raspberrypi.org/documentation/raspbian/applications/camera.md[/URL] for more information
nohup raspistill --nopreview -w 640 -h 480 -q 25 -o /tmp/stream/pic.jpg -tl 10 -t 9999999 -th 0:0:0 -rot 270 -hf >/dev/null 2>&1 &
# echo "start-raspi-stream.sh ran - start capture process at $(date)" >> /root/start-raspi-stream.log
LD_LIBRARY_PATH=/usr/local/lib /usr/local/bin/mjpg_streamer -i "input_file.so -f /tmp/stream -n pic.jpg" -o "output_http.so -w /usr/local/www" >/dev/null 2>&1 &
# echo "start-raspi-stream.sh ran - created LD_LIBRARY_PATH variables at $(date)" >> /root/start-raspi-stream.log
# echo "end of start-raspi-stream.sh" >> /root/start-raspi-stream.log
- Hit esc, then :wq to write the file and quit vi
- chmod ugo+x /etc/init.d/raspi-stream
- update-rc.d raspi-stream defaults
- crontab -e
- Add the following line to the end of your crontab file
Code:
* * * * * /root/start-raspi-stream.sh
- (Hit esc, then :wq to write the file and quit vi)
- Setup Fusion
- If you haven't already, add the webcam tile to your dashboard.
- Click on the gear for the webcam tile to get to settings.
- Click the plus sign to add the stream
- Name it something useful
- Change the level to view
- Change the type to Image/Motion JPEG
- Add your URL: http://yoururl.net:8080/?action=stream (In order for Apex Fusion to be able to display the stream you'll need to have setup port forwarding, if using the defaults in the tutorial above the port you'll need to forward is port 8080)


