00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
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 ?>