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.1.1.1  2008/11/27 20:04:03  elphel
00023 *!
00024 *!
00025 *!  Revision 1.3  2008/03/20 22:33:43  elphel
00026 *!  cleanup, returns xml now
00027 *!
00028 *!  Revision 1.2  2008/01/10 02:45:27  elphel
00029 *!  Added debug/status information
00030 *!
00031 *!  Revision 1.1  2008/01/09 10:21:13  elphel
00032 *!  added whitebalance.php - demo script to automatically adjust white balance
00033 *!
00034 *!
00035 */
00038 
00039  $balance_pars=array(
00040   "RSCALE" =>       256,            
00041   "BSCALE" =>       256,            
00042   "GSCALE" =>       256,            
00043   "GAINR" =>        512,            
00044   "GAING" =>        512,            
00045   "GAINB" =>        512,            
00046   "GAINGB" =>       512,            
00047   );
00048   $xml = new SimpleXMLElement("<?xml version='1.0'?><white_balance/>");
00049   $xml->addChild ('pars');
00050   $xml->addChild ('before');
00051 
00052 
00053   $thrsh=0.98;
00054   $minfrac=0.01;
00055   $rscale=1.0;
00056   $bscale=1.0;
00057   $v=$_GET['thrsh'];   if (is_numeric ($v) && ($v > 0) && ($v <= 1)) $thrsh=$v;
00058   $v=$_GET['minfrac']; if (is_numeric ($v) && ($v > 0) && ($v <  1)) $minfrac=$v;
00059   $v=$_GET['rscale'];  if (is_numeric ($v) && ($v >= 0.1) && ($v <=  10.0)) $rscale=$v;
00060   $v=$_GET['bscale'];  if (is_numeric ($v) && ($v >= 0.1) && ($v <=  10.0)) $bscale=$v;
00061   $balance_pars=elphel_get_P_arr($balance_pars);
00062   foreach ($balance_pars as $key=>$value) {
00063     $xml->before->addChild ($key,$value);
00064   }
00065   $xml->pars->addChild ('thrsh',$thrsh);
00066   $xml->pars->addChild ('minfrac',$minfrac);
00067   $xml->pars->addChild ('rscale',$rscale);
00068   $xml->pars->addChild ('bscale',$bscale);
00069   $rslt= elphel_white_balance ($thrsh, $minfrac, $rscale, $bscale);
00070   $xml->addChild ('result',($rslt>=0)?"OK":"failure");
00071   if ($rslt>=0) {
00072      $xml->addChild ('after');
00073      elphel_program_sensor (1); 
00074      $balance_pars=elphel_get_P_arr($balance_pars);
00075      foreach ($balance_pars as $key=>$value) {
00076        $xml->after->addChild ($key,$value);
00077      }
00078   }
00079   $sxml=$xml->asXML();
00080   header("Content-Type: text/xml");
00081   header("Content-Length: ".strlen($sxml)."\n");
00082   header("Pragma: no-cache\n");
00083   printf($sxml);
00084 ?>

Generated on Fri Nov 28 00:06:25 2008 for elphel by  doxygen 1.5.1