Web Weather > Weather Website PHP/AJAX scripting
PHP demo scrap that accesses a Panasonic PTZ camera.
(1/1)
SLOweather:
OK, here's a starter on getting images out of a Panasonic PTZ cam. Comments welcome.
--- Code: ---<?php
// This SLOweather.com demo script accesses a Panasonic BB-HCM580A PTZ camera,
// logs in, and moves the camera to a programmed preset position, grabs an image,
// and saves it. It should work for other Panasonic cameras in this family.
// It assumes that you already have programmed the presets in the camera via the internal
// web page, and that you are not using unprogrammed ones. In other words, there's no error
// checking.
// The full CGI reference manual for this camera is at:
// http://panasonic.co.jp/pcc/products/en/netwkcam/download/us/document/Camera_CGI_Interface_v3.13.pdf
// This version doesn't return an image directly to the browser, but saves it to
// the server for use in other pages. It's supposed to be run in a cron job, and,
// ultimately, be expanded to grab and save several images from different presets
// in the camera.
// The camera will supply other image resolutions, so this routine could be edited for them.
// You can test it by opening 2 browser windows. Run the script in one and see the
// status codes it returns. View the generated image in the other.
// You should set the camera up with a limited user just for the script.
// Pseudocode for the camera camera control:
// Hit a preset
// Hit autofocus
// Sleep for a bit for AF to settle
// Grab the image
// Enter info about the camera here...
$url = "IPorURLhere";
$user = "user"; // enter the login
$pw = "password"; //enter the password
// Create a blank image the right size
$dimg=imagecreatetruecolor(320,240);
// The camera access routine can be copied and pasted and edited for up to 20 presets
// for the BB-HCM381A.
// Log in to the camera and hit a preset. The camera returns messages for this type
// of command, so we'll get it in a temp file in case we need it later. In any case,
// it's a sneaky way of sending commands to the camera via http in PHP.
// Home Preset View
$temp= file_get_contents("http://$user:$pw@$url/Set?Func=PresetCntPos&Kind=Home");
// Print the returned status from the camera. Comment out for the cron job.
echo $temp;
// Hit autofocus, just in case
$temp= file_get_contents("http://$user:$pw@$url/Set?Func=Focus&Kind=0&FocusMode=5");
// Wait for autofocus to settle. Adjust as necessary.
sleep (1);
// Print the returned status from the camera. Comment out for the cron job.
echo $temp;
//Get the image
$dimg=imagecreatefromjpeg("http://$user:$pw@$url/SnapshotJPEG?Resolution=320x240");
// Turn it into a jpg.
imagejpeg($dimg,"home.jpg",100);
// destroy the old destination image
imagedestroy($dimg);
// End of script
?>
--- End code ---
capeweather:
Chris,
I used the code tag to make it stand out a little better for ya. :grin:
SLOweather:
Thanks!
Navigation
[0] Message Index
Go to full version