PHP/Bootstrap Web Interface for the Pi Camera


134 posts   Page 1 of 6   1, 2, 3, 4, 5, 6
by ronnyvdbr » Mon Feb 15, 2016 8:29 pm
Hi All, just wanted to share a little project of mine, I have built a PHP/Bootstrap web interface for the Raspberry Pi Camera module.
I was looking for a mobile friendly solution which I could easily deploy with a web gui, hence my little project.
If anyone is interested, I have built an image from a foundation Raspbian Jessie minimal image with the web gui and camera module enabled, you can find the image on my github page at the follow url: http://ronnyvdbr.github.io/RaspberryIPCamera/

Would love to hear from some test drivers how it works, and if there are any remaining problems which I should fix.
Obviously comments should be posted on the topic here on the Raspberry Pi forum.
Thanks to everyone willing to test-drive this software.
Posts: 65
Joined: Sun Mar 01, 2015 8:42 pm
by ronnyvdbr » Wed Feb 17, 2016 6:38 am
Posts: 65
Joined: Sun Mar 01, 2015 8:42 pm
by adstaggs » Thu Feb 18, 2016 4:14 am
I really want to test drive this but is there anyway to use a usb camera instead of a camera module?
Posts: 1
Joined: Thu Feb 18, 2016 4:10 am
by chris.brooke » Thu Feb 18, 2016 3:54 pm
What are the details to access the RTSP server bundled in?

I have a security program which connects to IP cameras over RTSP...
Posts: 2
Joined: Sun Jun 15, 2014 8:11 pm
by ronnyvdbr » Tue Feb 23, 2016 8:38 pm
adstaggs wrote:I really want to test drive this but is there anyway to use a usb camera instead of a camera module?


Well, the work is based on the uv4l framework of Linux projects.org.
They have a usb driver, so theoretically it should be possible.
Putting this into practice however will require additional code writing.
Will put it on my long todo list.
Posts: 65
Joined: Sun Mar 01, 2015 8:42 pm
by ronnyvdbr » Tue Feb 23, 2016 8:44 pm
chris.brooke wrote:What are the details to access the RTSP server bundled in?

I have a security program which connects to IP cameras over RTSP...


Currently only the mjpeg function is implemented, i'm still working on the h264 streaming because I struggle to display the stream on web page without delay.

The rtsp server is based on a work found on github which I have running on another pi without gui.
I'm currently connecting to the stream server on my pi's Ip port 80 on /
Posts: 65
Joined: Sun Mar 01, 2015 8:42 pm
by chris.brooke » Sun Feb 28, 2016 8:19 pm
Hi

Having an issue getting the latest beta to work; Can't seem to get connected to http://xxx.xxx.xxx.xxx:8080/stream/video.mjpeg

Port 8080 is not open on a portscan test.
Posts: 2
Joined: Sun Jun 15, 2014 8:11 pm
by ronnyvdbr » Wed Mar 02, 2016 10:07 pm
Hi, please note that I just uploaded beta 3 on direct download at: http://ronnyvdbr.github.io/RaspberryIPCamera/

The RTSP server functionality is now implemented, the mjpeg server is switched to another, and numerous other bugfixes/changes.
I tested the RTSP server with my Synology surveillance system, and this works sweet.
Pls, give it a try and let me know what u think.

P.s. Make sure to select beta 3 direct
Posts: 65
Joined: Sun Mar 01, 2015 8:42 pm
by willemprins » Sat Mar 05, 2016 1:46 pm
great work,
have used installation.sh. (full jessie) server seems ok but same here, port 8080 is not responding
(camera image gave server error)
willem
Posts: 3
Joined: Fri Mar 04, 2016 8:25 am
by ronnyvdbr » Sat Mar 05, 2016 4:28 pm
willemprins wrote:great work,
have used installation.sh. (full jessie) server seems ok but same here, port 8080 is not responding
(camera image gave server error)
willem


Strange, could u send me the output of below two commands to check it out?
Maybe debian jessie full already runs something else on that port ...

netstat -tulpn | grep :8080
sudo systemctl status uv4l-raspicam.service
Posts: 65
Joined: Sun Mar 01, 2015 8:42 pm
by willemprins » Sun Mar 06, 2016 11:27 am
your installation.sh is WORKING
The dir /etc/uv4l/
was not made
thanks

why the image is not working ?? I will try it later
Posts: 3
Joined: Fri Mar 04, 2016 8:25 am
by ronnyvdbr » Mon Mar 07, 2016 8:51 pm
Hi, please note that I just uploaded beta 4 on direct download at: http://ronnyvdbr.github.io/RaspberryIPCamera/

Another few bugs are now fixed, and the download is now presented as a net-installer which is small in download size. (only 32 mb)
Using the net-installer, it will take around 15 mins to build the raspberry camera, the process is completely unattended.
Just download the net installer, unzip and write to SD card with win32diskimager, after that, boot your pi and wait.
On completion, the web interface is available on port 80 of your pi, http://my-pi-ip-address
username admin
password raspberry
Posts: 65
Joined: Sun Mar 01, 2015 8:42 pm
by willemprins » Tue Mar 08, 2016 12:58 pm
thanks
Great, works in 1 time
< 10 min
Posts: 3
Joined: Fri Mar 04, 2016 8:25 am
by ronnyvdbr » Thu Mar 10, 2016 8:06 pm
Hi all, version 1.6 is now ready for download at http://ronnyvdbr.github.io/RaspberryIPCamera/
The whole setup is now changed, making the Raspbian Jessie Minimal OS read only, to contribute to stability, and prevent wearing off the sd card.    Making changes is possible if you remount the root read-write.
The system had a security update, closing some unprotected parts of the uv4l server which shouldn't be accessible.
Some restyling has been done on the web interface, making it a bit more friendly to look at.
As always, reports about bugs or any other feedback is welcome
Posts: 65
Joined: Sun Mar 01, 2015 8:42 pm
by ronnyvdbr » Fri Mar 18, 2016 7:39 am
chris.brooke wrote:What are the details to access the RTSP server bundled in?

I have a security program which connects to IP cameras over RTSP...


Hi, you can check out version 1.6, this includes an RTSP server from http://www.live555.com/ controlled by a wrapper written by Michel Promoneth.
I have this currently set up to work with synology surveillance station, works like a charm.
Posts: 65
Joined: Sun Mar 01, 2015 8:42 pm
by ctrlrst » Thu Mar 31, 2016 5:02 pm
Hi i can stream with this to vlc, but cant seem to get it set up with my syn.logy nas? Please can you tell me how you do this thanks,
Posts: 3
Joined: Thu Mar 31, 2016 4:58 pm
by ronnyvdbr » Thu Mar 31, 2016 6:15 pm
Hi, I have written an article on how to configure the IP Camera on a Synology Surveillance station.
You can find the article on my blog site: http://random-notes-of-a-sysadmin.blogspot.be/2016/03/howto-set-up-raspberry-ip-camera-on.html

Enjoy!
Posts: 65
Joined: Sun Mar 01, 2015 8:42 pm
by ctrlrst » Thu Mar 31, 2016 8:39 pm
Thanks for your quick reply and help I've tried those exact steps but I'm using an old ds209++ I'm guessing the driver pack isnt as up to date as what your running , maybe it's time for an upgrade :( , thanks for the help though.
Posts: 3
Joined: Thu Mar 31, 2016 4:58 pm
by ronnyvdbr » Thu Mar 31, 2016 8:49 pm
Hi, the camera as such was installed on my synology ds2015xs where this works out of the box on dsm 6.x

For an older model, see below forum post at step 4 for modifying config files.

Remove unicast from the url for my camera design though.


https://forum.synology.com/enu/viewtopic.php?t=98870
Posts: 65
Joined: Sun Mar 01, 2015 8:42 pm
by ctrlrst » Thu Mar 31, 2016 9:22 pm
OK I will try this and see if it works I wanted a new disk station anyway so if I can't get it working I suppose I will have a good excuse :) , thanks again.
Posts: 3
Joined: Thu Mar 31, 2016 4:58 pm
by Orvis » Tue Apr 19, 2016 8:39 am
Hello,
I'm facing an issue. I've got a standard Pi3 with a camera module rev1.3. But wether I use your distrib or the full raspbian with your installation.sh, I've got the same result :
- I can login to the webadmin but the camera view is empty
- when I try to connect to the :8080/stream/video.mjpeg, I've got a "connection reinitialised" but the connection to :8080 is OK
Posts: 6
Joined: Tue Apr 19, 2016 8:32 am
by ronnyvdbr » Tue Apr 19, 2016 7:17 pm
you should check if your uv4l_raspicam.service is running.

This command should show the status from your camera service:
sudo systemctl status uv4l_raspicam.service

Can u send me the output of that command?
Posts: 65
Joined: Sun Mar 01, 2015 8:42 pm
by Orvis » Mon Apr 25, 2016 5:59 pm
It seems that your PM box is full because I can't send you a PM.
Posts: 6
Joined: Tue Apr 19, 2016 8:32 am
by ronnyvdbr » Mon Apr 25, 2016 7:40 pm
Hello Orvis, lets continue our discussion via the board instead of PM where it could be of some use to other members of the forum as well.

Can u send me the output of the config files:

cat /etc/uv4l/uv4l-raspicam.conf
cat /etc/uv4l/uv4l-server.conf
cat /home/pi/RaspberryIPCamera/www/RaspberryIPCameraSettings.ini

ps -elf | grep uv4l

netstat -tulpn

This info would greatly help me diagnose your situation.
Posts: 65
Joined: Sun Mar 01, 2015 8:42 pm
by ronnyvdbr » Mon Apr 25, 2016 8:18 pm
Hi Orvis, let me try to answer a few of the question that you have.
So u do not want to do the 'hardening' of the system.
No real 'security' style hardening was done on the Raspbian, the design was only made read-only to allow for a longer endurance of the SD card. It's a know problem that SD cards used in Raspberry Pi's wear out after a certain amount of time if you don't do this.
SD cards are not created for heavy IO traffic, hence that change. Like I said, it's a thing to contribute to the stability of the IP camera.

Here are the lines I do not implement. Please confirm if they are absolutely necessary

# Make your partition a bit larger so it will fit this install
sudo parted /dev/mmcblk0 resizepart 2 1600
sudo resize2fs /dev/mmcblk0p2
I think that the second one generates an error. Anyway, I've got a 32gb microSD card, I guess it is large enough.


Well, if I recall correctly, the default partition size on the foundations Raspbian Lite image wasn't large enough to hold al the software I needed for the design, above commands just resizes your partitions to a larger size.
You can instead use raspi-config to expand your SD card to max. size, that will work too.

# Enable the Raspberry Pi Camera Module
sudo mount -o remount rw /boot
echo "start_x=1" | sudo tee -a /boot/config.txt
echo "gpu_mem=256" | sudo tee -a /boot/config.txt
echo "disable_camera_led=1" | sudo tee -a /boot/config.txt
I've manually enabled the cam and the 256M just after installation with raspi-config


If you enable the Camera via raspi-config you can indeed cancel all the other steps.

# First get rid of some unnecessary pagkages.
sudo apt-get -y remove --purge logrotate triggerhappy dphys-swapfile fake-hwclock samba-common
sudo apt-get -y autoremove --purge
# remove rsyslog and install a memory resident variant
sudo apt-get -y remove --purge rsyslog
sudo apt-get -y install busybox-syslogd
I skip this hardening block


Yes you can skip this, all this was done in an effort to make the image 'smaller' for redistribution on the internet.

# now remap some folders to temp space
sudo rm -rf /var/lib/dhcp/ /var/spool /var/lock
sudo rm /etc/resolv.conf
sudo ln -s /tmp /var/lib/dhcp
sudo ln -s /tmp /var/spool
sudo ln -s /tmp /var/lock
sudo ln -s /tmp/resolv.conf /etc/resolv.conf
sudo rm -rf /var/lib/php5/sessions
sudo ln -s /tmp/phpsessions /var/lib/php5/sessions
I skip this hardening block.
Some commands are very weird...


Well, this is done to make the system read only, it's just remapping some folders with writeable content to a memory resident location.

# configure the boot options to be read-only on next boot
sudo mount -o remount rw /boot
echo "dwc_otg.lpm_enable=0 console=ttyAMA0,115200 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait fastboot noswap ro" | sudo tee /boot/cmdline.txt
I skip this hardening block


In the /boot/cmdline.txt we make some modification which will mount the root partition read-only on next boot.
That way, nothing can be written on the SD card, makes it last longer ...

# Datei /etc/fstab
proc /proc proc defaults 0 0
/dev/mmcblk0p1 /boot vfat ro,defaults 0 2
/dev/mmcblk0p2 / ext4 ro,defaults,noatime 0 1
tmpfs /var/log tmpfs nodev,nosuid 0 0
tmpfs /var/tmp tmpfs nodev,nosuid 0 0
tmpfs /tmp tmpfs nodev,nosuid 0 0
I guess this block is a mistake ?


Not really, on boot the fstab file will tell the system what to mount where and how.
Since we remapped some folders, we need to make sure these are remounted and accessible somehow, this time not on the sd card but in temp (memory) space.

OK, if I stop here and give it a try, I can connect to the webadmin, but there is no camera view and the stream is not accessible through the URL http://192.168.2.35:8080/stream/video.mjpeg (connection reinitialised)

The output of sudo systemctl status uv4l_raspicam.service :
● uv4l_raspicam.service - LSB: Userspace Camera Driver
Loaded: loaded (/etc/init.d/uv4l_raspicam)
Active: active (running) since mer. 2016-04-20 11:29:01 CEST; 7min ago
Process: 113 ExecStart=/etc/init.d/uv4l_raspicam start (code=exited, status=0/SUCCESS)
CGroup: /system.slice/uv4l_raspicam.service
└─209 /usr/bin/uv4l -k --sched-fifo --mem-lock --config-file=/etc/uv4l/uv4l-raspicam.conf --driver raspicam --driver-config-file=/etc/uv4l/uv4l-raspicam.conf --server-option=--server-config-file=/etc/uv4l/uv4l-server.conf

avril 20 11:29:00 raspberrypi uv4l_raspicam[113]: <warning> [core] Driver 'raspicam' not found
avril 20 11:29:00 raspberrypi uv4l_raspicam[113]: <notice> [core] Trying driver 'raspicam' from external plug-in's...
avril 20 11:29:01 raspberrypi uv4l_raspicam[113]: <notice> [driver] Dual Raspicam Video4Linux2 Driver v1.9.36 built Apr 8 2016
avril 20 11:29:01 raspberrypi uv4l_raspicam[113]: <notice> [driver] Selected format: 1280x720, encoding: mjpeg, JPEG Video Capture
avril 20 11:29:01 raspberrypi uv4l_raspicam[113]: <notice> [driver] Framerate max. 15 fps
avril 20 11:29:01 raspberrypi uv4l_raspicam[113]: <notice> [driver] ROI: 0, 0, 1, 1
avril 20 11:29:01 raspberrypi uv4l_raspicam[113]: <info> [driver] RAW data will be included in the JPEG captures
avril 20 11:29:01 raspberrypi uv4l_raspicam[113]: <notice> [core] Device detected!
avril 20 11:29:01 raspberrypi uv4l_raspicam[113]: <notice> [core] Registering device node /dev/video0
avril 20 11:29:01 raspberrypi systemd[1]: Started LSB: Userspace Camera Driver.

So it seems correct.


Hrmm, at first sight it seems correct indeed.

If I go further through the installation.sh (126 -> 132) and I skip the cleaning block (135->143), and then I reboot, then I can not reach the webadmin anymore (connexion fails, as if there is no website available). I must :
sudo nginx
and the website is available again, but with the same issue (no camera view and no stream)


If you start nginx that way, it will only be running under your user session I believe.
In Raspbian Jessie, systemd is used as the service manager, and is responsible for stopping and starting stuff at boot or shutdown time.
If your nginx doesn't start during boot, it might not be enabled.
You can verify that by executing:
sudo systemctl status nginx.service
you should see a line:
Loaded: loaded (/lib/systemd/system/nginx.service; enabled)
The enabled at the end means it will try to start at boot.
Posts: 65
Joined: Sun Mar 01, 2015 8:42 pm