ZM working with Raspberry Pi Camera
Posted: Fri Oct 24, 2014 1:51 pm
Thought I'd share. Not happy with current camera (died), price of replacements, "No you can't have the login/passwrod." etc etc etc. I already had a RasPi board so I ordered a camera for $25. I have to say basic information - data structure etc - is a bit scarse/hidden. Seems the i developers like Python so the examples you get reads "RaspiCam::open ( bool StartCapture )". I learned to program in assy - lac, dac, jmp, isz... Not that there isn't a place for Python, Cobol, Fortran, Snobol, Ruby. But I'm off on a toot...
So I've been playing and got this to work: It's giving me aprox 5 fps. I plan on rewritting it in C using INT instead of CHAR - should be 3? 4? times faster.
That's true color - this morning, the sun, the clouds, just right, the world is ... pastel.
So I've been playing and got this to work: It's giving me aprox 5 fps. I plan on rewritting it in C using INT instead of CHAR - should be 3? 4? times faster.
Code: Select all
<?php
$len=0; $data = ""; $curfrm = "";
$fd1 = @fopen ("/dev/video0", "rb");
while ( $data = fread ($fd1, 4096) )
{
$m = strpos($data, 'Exif');
if ($m > 0)
{
$tailofframe = substr($data, 0, $m-6);
$headofnew = substr($data, $m-6);
$curfrm = $curfrm . $tailofframe;
$len = strlen($curfrm);
$fn = "/run/shm/ras~.jpg";
$fd2 = @fopen ($fn, "wb");
fwrite ($fd2, $curfrm, $len);
fclose ($fd2);
shell_exec("mv /run/shm/ras~.jpg /var/www/html/ras~.jpg ; mv /var/www/html/ras~.jpg /var/www/html/ras.jpg" );
$curfrm = $headofnew;
} else {
$curfrm = $curfrm . $data;
}
}
?>
That's true color - this morning, the sun, the clouds, just right, the world is ... pastel.