packages/web/353/php_top/whitebalance.php

Go to the documentation of this file.
00001 <?php
00002 /*!*******************************************************************************
00003 *! FILE NAME  : whitebalance.php
00004 *! DESCRIPTION: Demo script to balance white
00005 *! Copyright (C) 2008 Elphel, Inc
00006 *! -----------------------------------------------------------------------------**
00007 *!
00008 *!  This program is free software: you can redistribute it and/or modify
00009 *!  it under the terms of the GNU General Public License as published by
00010 *!  the Free Software Foundation, either version 3 of the License, or
00011 *!  (at your option) any later version.
00012 *!
00013 *!  This program is distributed in the hope that it will be useful,
00014 *!  but WITHOUT ANY WARRANTY; without even the implied warranty of
00015 *!  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00016 *!  GNU General Public License for more details.
00017 *!
00018 *!  You should have received a copy of the GNU General Public License
00019 *!  along with this program.  If not, see <http://www.gnu.org/licenses/>.
00020 *! -----------------------------------------------------------------------------**
00021 *!  $Log: whitebalance.php,v $
00022 *!  Revision 1.3  2008/03/20 22:33:43  elphel
00023 *!  cleanup, returns xml now
00024 *!
00025 *!  Revision 1.2  2008/01/10 02:45:27  elphel
00026 *!  Added debug/status information
00027 *!
00028 *!  Revision 1.1  2008/01/09 10:21:13  elphel
00029 *!  added whitebalance.php - demo script to automatically adjust white balance
00030 *!
00031 *!
00032 */
00035 
00036  $balance_pars=array(
00037   "RSCALE" =>       256,            
00038   "BSCALE" =>       256,            
00039   "GSCALE" =>       256,            
00040   "GAINR" =>        512,            
00041   "GAING" =>        512,            
00042   "GAINB" =>        512,            
00043   "GAINGB" =>       512,            
00044   );
00045   $xml = new SimpleXMLElement("<?xml version='1.0'?><white_balance/>");
00046   $xml->addChild ('pars');
00047   $xml->addChild ('before');
00048 
00049 
00050   $thrsh=0.98;
00051   $minfrac=0.01;
00052   $rscale=1.0;
00053   $bscale=1.0;
00054   $v=$_GET['thrsh'];   if (is_numeric ($v) && ($v > 0) && ($v <= 1)) $thrsh=$v;
00055   $v=$_GET['minfrac']; if (is_numeric ($v) && ($v > 0) && ($v <  1)) $minfrac=$v;
00056   $v=$_GET['rscale'];  if (is_numeric ($v) && ($v >= 0.1) && ($v <=  10.0)) $rscale=$v;
00057   $v=$_GET['bscale'];  if (is_numeric ($v) && ($v >= 0.1) && ($v <=  10.0)) $bscale=$v;
00058   $balance_pars=elphel_get_P_arr($balance_pars);
00059   foreach ($balance_pars as $key=>$value) {
00060     $xml->before->addChild ($key,$value);
00061   }
00062   $xml->pars->addChild ('thrsh',$thrsh);
00063   $xml->pars->addChild ('minfrac',$minfrac);
00064   $xml->pars->addChild ('rscale',$rscale);
00065   $xml->pars->addChild ('bscale',$bscale);
00066   $rslt= elphel_white_balance ($thrsh, $minfrac, $rscale, $bscale);
00067   $xml->addChild ('result',($rslt>=0)?"OK":"failure");
00068   if ($rslt>=0) {
00069      $xml->addChild ('after');
00070      elphel_program_sensor (1); 
00071      $balance_pars=elphel_get_P_arr($balance_pars);
00072      foreach ($balance_pars as $key=>$value) {
00073        $xml->after->addChild ($key,$value);
00074      }
00075   }
00076   $sxml=$xml->asXML();
00077   header("Content-Type: text/xml");
00078   header("Content-Length: ".strlen($sxml)."\n");
00079   header("Pragma: no-cache\n");
00080   printf($sxml);
00081 ?>

Generated on Thu Aug 7 16:19:01 2008 for elphel by  doxygen 1.5.1