poing
Posts: 1131
Joined: Thu Mar 08, 2012 3:32 pm

*Tutorial* - Control the PiCam with a browser through Ajax

Sat Sep 21, 2013 4:28 pm

This is a simple tutorial which aims to show how to control the Pi camera with a browser using any device (Smartphone, Tablet, Laptop, PC or even an E-reader) through HTML, PHP and Ajax. The idea is to shoot stills which are immediately displayed on the browser page. When satisfied with the image you can leave it at that or start a timelapse sequence or a video capture using the displayed framing. I use it on-the-go to control a battery powered Pi with my smartphone.

The tutorial may look a bit intimidating at first, but all you basically have to do is create five files and copy content to them from this tutorial (if you already have a web server running).

Disclaimer: I'm not your typical Linux wizard so improvements are possible and any comments are highly appreciated.

Prerequisites
You need to install the Apache web server (or the like), PHP (and a Wifi dongle configured as access point if you want to use a mobile device; see http://elinux.org/RPI-Wireless-Hotspot). Plus a working PiCamera of course.

Make sure to be able to access '/var/www' and '/dev/vchiq'
To start off showing my ignorance about Linux, I always have a problem with the permissions. As long as you do not open your Pi to others, like me, the easy (but basically unsafe!) way is to make the web directory '/var/www' (created during the install of the webserver, owned by the group 'www-data') and the file '/dev/vchiq' (owned by the group 'video') accessible to anyone with the commands:

Code: Select all

sudo chmod 777 /var/www
sudo chmod 777 /dev/vchiq
'var/www' is the directory that holds the files used by the web server while 'dev/vchiq' is used by raspistill and raspivid. PHP needs access to this file, otherwise it can't launch the camera and gives the * failed to open vchiq instance error.

Create the '/var/www/img' directory
Shot images and videos will be saved in '/var/www/img' so create this directory with:

Code: Select all

sudo mkdir /var/www/img
Create the HTML and CSS files
In the directory '/var/www' create the file 'shootpi.html' (watch upper- and lower case!) and copy the contents of the next code block to it:

Code: Select all

<!DOCTYPE html>
<html>
<head>
	<meta charset="UTF-8"/>
	<meta name="viewport" content="width=device-width, initial-scale=1.0">
	<title>ShootPi</title>
	<link rel="stylesheet" href="shootpi.css" type="text/css" />
<script>
	var hold='';

	function loadXMLDoc(){
		var xmlhttp;
		if (window.XMLHttpRequest){
			// code for IE7+, Firefox, Chrome, Opera, Safari
			xmlhttp=new XMLHttpRequest();
		}else{
			// code for IE6, IE5
			xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
		}
		//Put the most recent image name in the variable 'hold'
		xmlhttp.onreadystatechange=function(){
			if (xmlhttp.readyState==4 && xmlhttp.status==200){
				hold=xmlhttp.responseText;
			}
		}
		//Get the latest info from 'ajax_info.txt'
		xmlhttp.open("GET","ajax_info.txt",true);
		xmlhttp.send();
		//Refresh the image only if it has a new name
		if(document.getElementById("myDiv").innerHTML!=hold){
			document.getElementById("myDiv2").innerHTML="<img src="+hold+">";
			document.getElementById("myDiv").innerHTML=hold;
		}
	}

	function shootStill(){
		var xmlhttp;
		if (window.XMLHttpRequest){
			// code for IE7+, Firefox, Chrome, Opera, Safari
			xmlhttp=new XMLHttpRequest();
		}else{
			// code for IE6, IE5
			xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
		}
		xmlhttp.onreadystatechange=function(){
			if (xmlhttp.readyState==4 && xmlhttp.status==200){
				//Do something
			}
		}
		//Take a still image
		xmlhttp.open("GET","shootStill.php",true);
		xmlhttp.setRequestHeader("Content-type","application/x-www-form-urlencoded");
		xmlhttp.send();
	}

	function shootTimelapse(){
		var xmlhttp;
		if (window.XMLHttpRequest){
			// code for IE7+, Firefox, Chrome, Opera, Safari
			xmlhttp=new XMLHttpRequest();
		}else{
			// code for IE6, IE5
			xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
		}
		xmlhttp.onreadystatechange=function(){
			if (xmlhttp.readyState==4 && xmlhttp.status==200){
				//Do something
			}
		}
		//Take a timelapse sequence
		xmlhttp.open("GET","shootTimelapse.php",true);
		xmlhttp.setRequestHeader("Content-type","application/x-www-form-urlencoded");
		xmlhttp.send();
	}

	function shootVideo(){
		var xmlhttp;
		if (window.XMLHttpRequest){
			// code for IE7+, Firefox, Chrome, Opera, Safari
			xmlhttp=new XMLHttpRequest();
		}else{
			// code for IE6, IE5
			xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
		}
		xmlhttp.onreadystatechange=function(){
			if (xmlhttp.readyState==4 && xmlhttp.status==200){
				//Do something
			}
		}
		//Take a video
		xmlhttp.open("GET","shootVideo.php",true);
		xmlhttp.setRequestHeader("Content-type","application/x-www-form-urlencoded");
		xmlhttp.send();
	}

	function timedRefresh(timeoutPeriod) {
		loadXMLDoc();
		setTimeout("timedRefresh(1000);",timeoutPeriod);
	}
</script>
</head>
<!-- Set the refresh interval in miliseconds, default=1000 (1 second) -->
<body onload="JavaScript:timedRefresh(1000);">
	<div id="myDiv2"></div>
	<div id="myDiv"></div>
	<input type="button" value="Shoot Still" onClick='shootStill();'><br><br>
	<input type="button" value="Shoot Timelapse" onClick='shootTimelapse();'><br><br>
	<input type="button" value="Shoot Video" onClick='shootVideo();'><br><br>
</body>
</html>

In the above file are 4 functions using Ajax. The first, loadXMLDoc(), is responsible for refreshing the div container holding the image when a new image is detected. The others launch PHP files that will make the camera shoot a still, timelapse or video. See the comments for details.

Next create the file 'shootpi.css' (watch upper- and lower case!) in '/var/www' and copy the next content to it:

Code: Select all

body
{
/* background-image:
url('bigg.gif');
*/
	background-color: #000000;
	background-repeat: no-repeat;
	background-attachment: fixed;

	font-family: "Verdana";
	font-size: 8pt;
	color: #dddddd;
}

img {
    max-width: 100%;
    max-height: 97%;
/*height: auto;*/
    width: auto\9; /* ie8 */
}
This CSS file makes the background black and re sizes the image inside the boundaries of the browser window.

Create the PHP files for still, timelapse and video capture
In '/var/www' create the files (watch upper- and lower case!):
shootStill.php

Code: Select all

<?
//get the last used number for naming file
$lastImgNum = file_get_contents('/var/www/lastImgNum.txt');
echo "lastImgNum read for this use is ".$lastImgNum."<br>";

//up the number by one
$lastImgNum+=1;
//write the new last used number
file_put_contents('/var/www/lastImgNum.txt', $lastImgNum);
echo "lastImgNum written for next use is ".$lastImgNum."<br>";

//construct file name with leading zeros
$imgName=str_pad($lastImgNum,6,"0",STR_PAD_LEFT);
echo "imgName for this use is ".$imgName."<br>";

//take still image with PiCamera and store it in '/var/www/img' directory
//edit the raspistill command here to taste but make sure not to remove the double quotes!
shell_exec("raspistill -t 1000 -o /var/www/img/".$imgName.".jpg");
echo "Shot image ".$imgName.".jpg<br>";

//write the filename to 'ajax_info.txt' so it will be shown in the browser using Ajax
$imgName="/img/".$imgName;
file_put_contents('/var/www/ajax_info.txt', $imgName);
echo "Saved ".imgName." to /var/www/ajax_info.txt <br>";

?>
shootTimelapse.php

Code: Select all

<?
//get the last used number for naming file
$lastImgNum = file_get_contents('/var/www/lastImgNum.txt');
echo "lastImgNum read for this use is ".$lastImgNum."<br>";

//up the number by one
$lastImgNum+=1;
//write the new last used number
file_put_contents('/var/www/lastImgNum.txt', $lastImgNum);
echo "lastImgNum written for next use is ".$lastImgNum."<br>";

//construct file name with leading zeros
$imgName=str_pad($lastImgNum,6,"0",STR_PAD_LEFT);
echo "imgName for this use is ".$imgName."<br>";

//take timelapse images with PiCamera and store it in '/var/www/img' directory
//edit the raspistill command here to taste but make sure not to remove the double quotes!
shell_exec("raspistill -t 20000 -tl 2000 -o /var/www/img/".$imgName."_%d.jpg");
echo "Shot timelapse ".$imgName."<br>";

/* DISABLED SHOWING IMAGE THROUGH AJAX!!!
//write the filename to 'ajax_info.txt' so it will be shown in the browser using Ajax
$imgName="/img/".$imgName;
file_put_contents('/var/www/ajax_info.txt', $imgName);
echo "Saved ".imgName." to /var/www/ajax_info.txt <br>";
*/

?>
shootVideo.php

Code: Select all

<?
//get the last used number for naming file
$lastImgNum = file_get_contents('/var/www/lastImgNum.txt');
echo "lastImgNum read for this use is ".$lastImgNum."<br>";

//up the number by one
$lastImgNum+=1;
//write the new last used number
file_put_contents('/var/www/lastImgNum.txt', $lastImgNum);
echo "lastImgNum written for next use is ".$lastImgNum."<br>";

//construct file name with leading zeros
$imgName=str_pad($lastImgNum,6,"0",STR_PAD_LEFT);
echo "imgName for this use is ".$imgName."<br>";

//take video with PiCamera and store it in '/var/www/img' directory
//edit the raspivid command here to taste but make sure not to remove the double quotes!
shell_exec("raspivid -t 10000 -o /var/www/img/".$imgName.".264");
echo "Shot video ".$imgName.".264<br>";

/* DISABLED SHOWING IMAGE THROUGH AJAX!!!
//write the filename to 'ajax_info.txt' so it will be shown in the browser using Ajax
$imgName="/img/".$imgName;
file_put_contents('/var/www/ajax_info.txt', $imgName);
echo "Saved ".imgName." to /var/www/ajax_info.txt <br>";
*/

?>
Done!
So what happens?

Browse to 'Pi_IP_address/shootpi.html' (in my case, using a wired connection, that is 'http://192.168.1.123/shootpi.html'). You'll see a black page with three buttons. Click the 'Shoot Still' button.

The page will launch the 'shootStill()' function that uses Ajax to launch 'shootStill.php' in turn. If all goes well this program gets the last used number from '/var/www/lastImgNum.txt', ups this number by one to create an unused image name, saves the new number for future use (aka the next image), takes an image using raspistill and finally saves the name of the shot image to '/var/www/ajax_info.txt'. This file is read by the 'loadXMLDoc()' function every second and if there's a new image name in the file it changes the image in the 'myDiv2' container to the new one.

The Timelapse and Video functions do not show images or video in the browser window; My use at this moment is to get a good image using still images and then use the other buttons to record timelapse or video.

To change the raspistill and raspivid parameters look in the .php files.

Troubleshooting (edited as problems arise in the thread)
- You can launch the three .php files by themselves in the browser (i.e. 'http://192.168.1.123/shootStill.php') to see error output and check if an image or video is saved.
- Doesn't seem to work with Internet Explorer 10 on Windows 7 64-bit with the present code (but it does work in Chrome and on my Android Nexus S phone).

Good luck, hope this is useful.
Last edited by poing on Sat Sep 21, 2013 9:07 pm, edited 2 times in total.

thegnnu
Posts: 157
Joined: Thu Oct 18, 2012 7:07 pm
Location: Bristol

Re: *Tutorial* - Control the PiCam with a browser through Aj

Sat Sep 21, 2013 8:15 pm

Hi Spotted your article and thought what a great idea thinking ahead to a bird table pi/camera
So I have made all the files and I can get the web page come up with the 3 buttons. Pressing any of the buttons nothing seems to happen. Run the file "shootStill.php" from putty and get the following error report
./shootStill.php: line 1: ?: No such file or directory
./shootStill.php: line 2: //get: No such file or directory
./shootStill.php: line 3: syntax error near unexpected token `('
./shootStill.php: line 3: `$lastImgNum = file_get_contents('/var/www/lastImgNum.txt');'

I then made a file called "llastImgNum.txt" and put a 1 in it. Stil have the error report
I did not know what I had to do about Java and ajax
could you please advise
Terry

poing
Posts: 1131
Joined: Thu Mar 08, 2012 3:32 pm

Re: *Tutorial* - Control the PiCam with a browser through Aj

Sat Sep 21, 2013 8:27 pm

The .txt files are created automatically so no worries there.

The .php files should be run from the browser; they're basically HTML files, only with .php as extension so the server knows there's PHP code inside that needs to be executed. Could you try the file 'shootStill.php' in the browser (using the Pi's IP adress of course) and post the output?

BTW, if you create a file called '/var/www/test.php' and put the following code inside:

Code: Select all

<? phpinfo(); ?>
then run that in the browser (as in 'http://Pi_IP_address/test.php') you see the configuration of PHP. If it doesn't run you probably do not have PHP installed.

thegnnu
Posts: 157
Joined: Thu Oct 18, 2012 7:07 pm
Location: Bristol

Re: *Tutorial* - Control the PiCam with a browser through Aj

Sat Sep 21, 2013 9:10 pm

Thanks I had only installed Apache2 so found a page about PHP
and installed these
apt-get install libapache2-mod-php5 php5 php-pear php5-xcache
Your Test page then gave me a page of details.
Will continue tomorrow when I can get the camera into daylight.

thanks for quick reply
Terry

thegnnu
Posts: 157
Joined: Thu Oct 18, 2012 7:07 pm
Location: Bristol

Re: *Tutorial* - Control the PiCam with a browser through Aj

Sun Sep 22, 2013 4:05 pm

Hi I still have a problem with the picture not being saved in /var/www/img the I have run a test and the results show the picture name is being incremented.
putting this into promt give me a picture being stored in the correct place so camera is working
raspistill -t 1000 -o /var/www/img/test.jpg
so I then run your program in browser
http://192.168.0.6/shootStill.php
and get the following report
lastImgNum read for this use is 11
lastImgNum written for next use is 12
imgName for this use is 000012
Shot image 000012.jpg
Saved imgName to /var/www/ajax_info.txt
As you can see it seems to stop at making the name and not going on to the shell_exec line
Terry

poing
Posts: 1131
Joined: Thu Mar 08, 2012 3:32 pm

Re: *Tutorial* - Control the PiCam with a browser through Aj

Sun Sep 22, 2013 4:59 pm

The (somewhhat cryptic) output text is correct and 'shell_exec' is just before the output of 'Shot image...' so that seems OK. Not sure what's wrong. Some things...
- if you run 'shootpi.html' do you see '/img/000012' in white just above the 'Shoot Still' button?
- did you do:

Code: Select all

sudo chmod 777 /var/www
sudo chmod 777 /dev/vchiq
This is basically unsafe if others can get at your Pi but otherwise it didn't work for me.

- if you create a test file named 'testShoot.php' with the contents:

Code: Select all

<?
shell_exec("raspistill -t 1000 -o /var/www/test.jpg");
?>
and run that in the browser does that save a file called 'test.jpg' in '/var/www'? That works for me.

thegnnu
Posts: 157
Joined: Thu Oct 18, 2012 7:07 pm
Location: Bristol

Re: *Tutorial* - Control the PiCam with a browser through Aj

Sun Sep 22, 2013 5:34 pm

I have the file number appear above the buttons and increments on each button press
I ran the testShoot.php and get a white empty screen and no file saved
noth dir are set to 777
Do I have anything missing I installed the apache2 and libapache2-mod-php5 php5 php-pear php5-xcache on top of a clean Raspbian install,

thegnnu
Posts: 157
Joined: Thu Oct 18, 2012 7:07 pm
Location: Bristol

Re: *Tutorial* - Control the PiCam with a browser through Aj

Sun Sep 22, 2013 6:45 pm

poing
Sorry do not under stand the code
found php.ini in \etc\php5\apache
it had
; short_open_tag
; Default Value: On
so changed to Off even restarted the PI and results for the test is still no image is saved
Terry

poing
Posts: 1131
Joined: Thu Mar 08, 2012 3:32 pm

Re: *Tutorial* - Control the PiCam with a browser through Aj

Sun Sep 22, 2013 8:31 pm

thegnnu wrote:poing
Sorry do not under stand the code
found php.ini in \etc\php5\apache
it had
; short_open_tag
; Default Value: On
so changed to Off even restarted the PI and results for the test is still no image is saved
Terry
Please put that back; The remark of ednl was only about the difference between '<?' and '<?php' as an opening tag for a PHP code block, which has nothing to do with your problem. You now made it so that only '<?php' works while my code uses '<?'
:? Thanks, Ed! :lol:
thegnnu wrote:I have the file number appear above the buttons and increments on each button press
OK, that's good because it means that PHP can write to your file system.
thegnnu wrote:I ran the testShoot.php and get a white empty screen and no file saved
The white empty screen is normal, but the 'test.jpg' image should be saved. Hmmm...

Can you change the contents of 'testShoot.php' to:

Code: Select all

<?php
$output=shell_exec("raspistill -t 1000 -o /var/www/test.jpg");
echo "Output = ".$output;
php?>
If there's a problem an error message should appear after 'Output ='

thegnnu
Posts: 157
Joined: Thu Oct 18, 2012 7:07 pm
Location: Bristol

Re: *Tutorial* - Control the PiCam with a browser through Aj

Sun Sep 22, 2013 8:39 pm

Error report
Output = * failed to open vchiq instance

poing
Posts: 1131
Joined: Thu Mar 08, 2012 3:32 pm

Re: *Tutorial* - Control the PiCam with a browser through Aj

Sun Sep 22, 2013 8:59 pm

Then you have to use Putty and execute:

Code: Select all

sudo chmod 777 /dev/vchiq
raspistill needs to use that file but it's not allowed to when launched by PHP. Using the above code gives everyone permission to use '/dev/vchiq'.

After you did the above with Putty, please run the 'testShoot.php' again. Then 'test.jpg' should be visible in '/var/www' and everything should work.

thegnnu
Posts: 157
Joined: Thu Oct 18, 2012 7:07 pm
Location: Bristol

Re: *Tutorial* - Control the PiCam with a browser through Aj

Sun Sep 22, 2013 9:24 pm

Thank you for your patience all working file great job
picture now appears on the main web page and in the img dir:D
Terry

poing
Posts: 1131
Joined: Thu Mar 08, 2012 3:32 pm

Re: *Tutorial* - Control the PiCam with a browser through Aj

Sun Sep 22, 2013 9:42 pm

Great that we got it to work!

One word of warning about this alpha software: While you're taking an exposure or timelapse or video, DO NOT press one of the buttons again, for than the camera will hang and you'll need to restart the Pi. I'll see if I can prevent that from happening somehow.

Watch this space as right now I'm slowly making a more advanced version where you can easily change some basic settings and store often used shooting scenarios.

poing
Posts: 1131
Joined: Thu Mar 08, 2012 3:32 pm

Re: *Tutorial* - Control the PiCam with a browser through Aj

Sun Sep 22, 2013 9:54 pm

OK, thanks. I appreciate your input but thegnnu got confused. I'll change my <? behavior ;)

tvjon
Posts: 708
Joined: Mon Jan 07, 2013 9:11 am

Re: *Tutorial* - Control the PiCam with a browser through Aj

Mon Sep 23, 2013 11:59 am

Poing,

thank you for your tutorial, & also thegnnu, as your posts mirrored my experience, except I don't use Apache, rather nginx, so I needed to use different paths, as nginx' default is

/usr/share/nginx/www

Poing, any particular reason you chose Apache?

<?php
$output=shell_exec("raspistill -t 1000 -o /var/www/test.jpg");
echo "Output = ".$output;
php?>

is a useful bit of debug code too:)

thegnnu
Posts: 157
Joined: Thu Oct 18, 2012 7:07 pm
Location: Bristol

Re: *Tutorial* - Control the PiCam with a browser through Aj

Mon Sep 23, 2013 12:22 pm

Poing A update for you this morning switched on the Pi and it did not work again so looking into the problem I found the file /dev/vchiq had changed back to it original setting changed, to 777 and all worked.
thegnnu

poing
Posts: 1131
Joined: Thu Mar 08, 2012 3:32 pm

Re: *Tutorial* - Control the PiCam with a browser through Aj

Mon Sep 23, 2013 12:32 pm

@tvjon: Thanks for the feedback, that's helpful.

I chose Apache a while back because I wanted to replicate functionality of my home server to the Pi so I could use it on the road. I know Apache is considered a bit heavyweight for the Pi, but it runs like clockwork.

I think I'll make a more user friendly install method where you just copy a complete shootpi directory to your server and then first run a more sophisticated 'testShoot.php' which then iterates through the possible pitfalls and creates sensible debug output.

I'm also changing ShootPi so that you can easily change the -ev option (make the image lighter or darker) and can easily store different raspistill and raspivid commands for quick re use.

At the moment I'm trying to decide between a storage system based on MySQL (my personal preference as I already have it installed and is easy to implement) or plain text files that would 'just work' without users first installing MySQL and creating a database with permissions etc. If anyone has an opinion about that feel free to share ;)

For now I guess I'll go for the text files as I want shootpi to be as easy to use and install as possible.

poing
Posts: 1131
Joined: Thu Mar 08, 2012 3:32 pm

Re: *Tutorial* - Control the PiCam with a browser through Aj

Mon Sep 23, 2013 12:33 pm

thegnnu wrote:Poing A update for you this morning switched on the Pi and it did not work again so looking into the problem I found the file /dev/vchiq had changed back to it original setting changed, to 777 and all worked.
thegnnu
Thanks for the feedback. But I have no clue how that could have happened to be honest.

tvjon
Posts: 708
Joined: Mon Jan 07, 2013 9:11 am

Re: *Tutorial* - Control the PiCam with a browser through Aj

Mon Sep 23, 2013 12:58 pm

Poing,

Useful feedback from you too thanks.

I did a find/replace on your directories specifying the nginx ones. I think it'd be easier if the relevant directories (for different servers, eg.lighty) were defined just once, & "filled in" in the appropriate places in the php files on execution?

There's an interesting post by "billybilly" in the media players section, "Web based remote control", which I thought would be adaptable to this task, & in fact I suppose your tutorial could apply to his task, controlling omxplayer. Now I have both approaches working I'll see if I can adapt each to the opposite task & see if there's any practical significant differences.

Although I'm pleased to feedback what I find, I suspect people with vastly more experience than I with javascript & php would be able to give you more meaningful info' :) I wondered if you had experience with js too, but think php is a better approach? In fact any thoughts on the pros & cons of each method?

Your mod's sound like they'll be very welcome, thanks.

cchisholm
Posts: 84
Joined: Sat Mar 07, 2015 4:47 pm

Re: *Tutorial* - Control the PiCam with a browser through Aj

Tue Apr 14, 2015 10:45 pm

Your tutorial is great and exactly what I was looking for. One problem though: (don't you just hate that)....
I changed the permissions on /dev/vchiq and it works great until I reboot. The permissions changes don't seem to be persistent. Have you run into that or found a solution or will I just have to chmod every time I restart RP. I am very new to RP and Linux, so the answer may be pretty obvious to someone more experienced.

Charlie

poing
Posts: 1131
Joined: Thu Mar 08, 2012 3:32 pm

Re: *Tutorial* - Control the PiCam with a browser through Aj

Wed Apr 22, 2015 3:43 pm

cchisholm wrote:Your tutorial is great and exactly what I was looking for. One problem though: (don't you just hate that)....
I changed the permissions on /dev/vchiq and it works great until I reboot. The permissions changes don't seem to be persistent. Have you run into that or found a solution or will I just have to chmod every time I restart RP. I am very new to RP and Linux, so the answer may be pretty obvious to someone more experienced.

Charlie
I must admit I have no idea. I'm also a bit out of the loop with the Pi and Linux due to other work so I'd try to find other sources than me.

Besides, did you see this: viewtopic.php?f=43&t=63276 ? It's a much better implementation of what I tried to do here and made by a real programmer. Good luck.

orcsriver
Posts: 20
Joined: Tue Aug 08, 2017 8:40 am

Re: *Tutorial* - Control the PiCam with a browser through Ajax

Fri Oct 27, 2017 5:47 am

Hi m8s

To enable PHP to execute RASPISTILL from shell, you need to add user 'www-data' to group 'video' in order to access the file '/dev/vchiq'

This is how I did it:

Code: Select all

sudo adduser www-data video
No need to change any other permissions using CHMOD or CHOWN.

Hope this helps

HappyCoder
Posts: 8
Joined: Tue Jan 02, 2018 10:17 pm

Re: *Tutorial* - Control the PiCam with a browser through Ajax

Tue Jan 02, 2018 10:24 pm

I think the php files may start with

<?php

... here is your code ...

?>

panjip
Posts: 1
Joined: Tue May 15, 2018 1:32 pm

Re: *Tutorial* - Control the PiCam with a browser through Aj

Tue May 15, 2018 1:37 pm

poing wrote:
Sun Sep 22, 2013 8:59 pm
Then you have to use Putty and execute:

Code: Select all

sudo chmod 777 /dev/vchiq
raspistill needs to use that file but it's not allowed to when launched by PHP. Using the above code gives everyone permission to use '/dev/vchiq'.

After you did the above with Putty, please run the 'testShoot.php' again. Then 'test.jpg' should be visible in '/var/www' and everything should work.



Great!!!
this solution works for me thank you.

Code: Select all

sudo chmod 777 /dev/vchiq

Return to “Camera board”