Author Topic: PHP demo scrap that accesses a Panasonic PTZ camera.  (Read 4204 times)

0 Members and 1 Guest are viewing this topic.

Offline SLOweather

  • Global Moderator
  • Forecaster
  • *****
  • Posts: 3456
    • Weatherelement Moline IL
PHP demo scrap that accesses a Panasonic PTZ camera.
« on: December 30, 2007, 12:25:59 PM »
OK, here's a starter on getting images out of a Panasonic PTZ cam. Comments welcome.


Code: [Select]
<?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

$tempfile_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
$tempfile_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
?>

« Last Edit: December 30, 2007, 09:21:57 PM by capeweather »

Offline capeweather

  • Global Moderator
  • Forecaster
  • *****
  • Posts: 1309
    • http://www.capeweather.com
Re: PHP demo scrap that accesses a Panasonic PTZ camera.
« Reply #1 on: December 30, 2007, 09:22:46 PM »
Chris,
I used the code tag to make it stand out a little better for ya.  :grin:

Chris
Cape Coral, Florida
Website: http://www.capeweather.com
Website: http://www.fortmyersweather.net

Offline SLOweather

  • Global Moderator
  • Forecaster
  • *****
  • Posts: 3456
    • Weatherelement Moline IL
Re: PHP demo scrap that accesses a Panasonic PTZ camera.
« Reply #2 on: December 30, 2007, 10:58:55 PM »
Thanks!

 

anything