PHP and Gamma values
From ElphelWiki
How to change Gamma values in an Elphel camera
Changing Gamma and BlackLevel values at present requires some special treatment. Here is a short PHP script that does it:
<?php // Set default frame ahead if (!array_key_exists("ahead",$_GET)) $ahead=3; // Special treatment for the gamma values and blacklevel. // Get exising gamma values if a gamma parameter is requested if (array_key_exists("gamma",$_GET) || array_key_exists("black",$_GET)) { $gammas=array( "GTAB_R__0816"=>"", "GTAB_G__0816"=>"", "GTAB_GB__0816"=>"", "GTAB_B__0816"=>"", "GTAB_R__0824"=>"", "GTAB_G__0824"=>"", "GTAB_GB__0824"=>"", "GTAB_B__0824"=>"" ); // get existing gamma values $gammas= elphel_get_P_arr($gammas); } foreach($_GET as $key=>$value) { if(strtolower(substr($s, 0, 2))=="0x") $value= hexdec($value); switch ($key) { case "gamma": // set gammas array and postpone setting values in the camera $value = intval($value); foreach (array( "GTAB_R__0816", "GTAB_G__0816", "GTAB_GB__0816", "GTAB_B__0816" ) as $key) $gammas[$key] = $value; break; case "black": // set gammas array and postpone setting values in the camera $value = intval($value); foreach (array( "GTAB_R__0824", "GTAB_G__0824", "GTAB_GB__0824", "GTAB_B__0824" ) as $key) $gammas[$key] = $value; break; } // If any gamma value was set, set all gamma values in the camera. // Was postponed earlier if ($gammas != NULL) { elphel_gamma_add($gammas["GTAB_G__0816"]/100, $gammas["GTAB_G__0824"]); // Apply the values at the frame ahead elphel_set_P_arr($gammas,$ahead); } // // Add code to form the output here } ?>
The code looks for HTTP query parameters black (level of black) and gamma and sets them at the same time.
The parameters should be integers: 1 < gamma <= 100 and 0 <= black <= 50.
The undocumented function elphel_gamma_add(int gamma, int black) is used, where the value of gamma for this function must be a float 0.1 < gamma <= 1.0. Without it the gamma values are not effected. More can be found in the file camvc.php in /mnt/flash/html.