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 $imgsrv="http://".$_SERVER['SERVER_ADDR'].":8081";
00032 if (count($_GET)==0) {
00033 showUsage();
00034 exit (0);
00035 }
00036
00037 $elp_const=get_defined_constants(true);
00038 $elp_const=$elp_const["elphel"];
00039 foreach($_GET as $key=>$value) switch($key) {
00040 case "profile": profileShow(myval($value)); break;
00041 case "histogram_direct":
00042 case "histogram_reverse":
00043 case "gamma_direct":
00044 case "gamma_reverse": showHistGamma ($key,floatval($value)); break;
00045 case "jpegheader": showJpegHeader(); break;
00046 case "constants": echo "<pre>\n";print_r($elp_const); echo "</pre>\n"; break;
00047 case "frame": printRawFrame(myval($value)); break;
00048 case "hist_raw": printRawHistogram(0xfff,myval($value)); break;
00049 case "hist":
00050 case "histogram": printHistogram(myval($value)); break;
00051 case "gamma": printGammaStructure(); break;
00052 case "gamma_page": printRawGamma(myval($value)); break;
00053 default: showUsage();
00054 }
00055 exit (0);
00057 function showUsage() {
00058 echo <<<USAGE
00059 <p>This is a collection of tools for the 8.0 software development/testing, you can provide parameters in HTTP GET request.</p>
00060 <p>Here are some of the current options</p>
00061 <ul>
00062 <li><a href="?constants">constants</a> - list all defined PHP constants related to Elphel camera</li>
00063 <li><a href="?profile=50">profile=50</a> - show last 50 (up to ELPHEL_CONST_PASTPARS_SAVE_ENTRIES=2048) profile entries - recorded if profiling is enabled</li>
00064 <li><a href="?histogram_direct=0.5">histogram_direct=0.5</a> - show part of the pixels below specified output value (on 0..1.0 scale - 0.5 in this example) for each color channel </li>
00065 <li><a href="?histogram_reverse=0.5">histogram_reverse=0.5</a> - show pixel output value (on 0..1.0 scale) so that specified part of all pixels have output (after gamma conversion) valuebelow it, for each color channel </li>
00066 <li><a href="?gamma_direct=0.5">gamma_direct=0.5</a> - show output pixel value (on 0..1.0 scale) for the specified (0..1.0 scale) sensor pixel value, for each color channel </li>
00067 <li><a href="?gamma_reverse=0.5">gamma_reverse=0.5</a> - show what sensor pixel value would produce specified output (after gamma conversion) value (on 0..1.0 scale), for each color channel </li>
00068 <li><a href="?jpegheader">jpegheader</a> - show data in the current JPEG header</li>
00069 <li><a href="?frame=0">frame=0</a> - show raw data for the frame parameters internal data. There are 8 parameter pages used in sequence, so only the 3 least significant bits of the frame number are used</li>
00070 <li><a href="?histogram=prev">histogram=prev</a> - Show histogram data for the specified frame - in addition to the absolute frame number you may specify prev1...prev6. Giving future or too long ago frame will result in an (uncaught) error</li>
00071 <li><a href="?hist_raw=prev">hist_raw=prev</a> - Show raw histogram data for the specified frame - in addition to the absolute frame number you may specify prev1...prev6. Giving future or too long ago frame will result in an (uncaught) error. It shows the same data as <a href="?histogram=prev">histogram=prev</a> - just uses different access to the histogram arrays.</li>
00072 <li><a href="?gamma">gamma</a> - show structure of the gamma tables cache. Among othe data it provides links to the individual gamma tables pages. This command takes morfe than 10 seconds to complete.</li>
00073 <li><a href="?gamma_page=255">gamma_page=255</a> - contents of the gamma tables cache page (0 - index page, 1..255 - cache pages). Individual pages links are provided by the <a href="?gamma">?gamma</a> command. Some of the tables in the cache (reverse, FPGA) may be missing if they were never requested.</li>
00074 </ul>
00075 <p>There are additional development pages links available:</p>
00076 <ul>
00077 <li><a href="tuneseq.php">tuneseq.php</a> - run-time tuning of sequencer latencies;</li>
00078 <li><a href="$imgsrv">imgsrv</a> getting images from the camera internal buffer (you have to acquire them there first)</li>
00079 <li><a href="var/klog.txt">var/klog.txt</a> - read kernel messages (you first need to telnet to the camera and run "printk_mod &" and enable some of the DEBUG bits)</li>
00080 </ul>
00081 <h4>Make sure to run "printk_mod &" before enabling debug bits - some are from interrupt service routine, and default printk() output to console can really mess up things and make the camera "freeze".</h4>
00082
00083
00084 USAGE;
00085 }
00086
00087 function showJpegHeader() {
00088 $xml = new SimpleXMLElement("<?xml version='1.0'?><framepars/>");
00089 $circbuf_file=fopen("/dev/circbuf","r");
00090 fseek($circbuf_file,ELPHEL_LSEEK_CIRC_LAST,SEEK_END);
00091 $jpeg_start=ftell($circbuf_file);
00092 $xml->addChild ('circbuf_pointer',sprintf("0x%x (0x%x)",$jpeg_start,$jpeg_start>>2));
00093 fclose($circbuf_file);
00094 $header_file=fopen("/dev/jpeghead","r");
00096 fseek($header_file,$jpeg_start+1,SEEK_END);
00097 fseek($header_file,0,SEEK_END);
00098 $header_size=ftell($header_file);
00099 $xml->addChild ('header_size',$header_size);
00100 fseek($header_file,0,SEEK_SET);
00101 $header=fread ($header_file,8192);
00102 $xml->addChild ('header_read_length',strlen($header));
00103 fclose($header_file);
00104 $aheader=unpack('C*',$header);
00105 for ($i=0; $i<count($aheader) ;$i+=16){
00106 $d="";
00107 for ($j=$i; ($j<$i+16) && ($j<count($aheader)); $j++) $d.=sprintf(" %02x",$aheader[$j+1]);
00108 $xml->addChild (sprintf('header%03x',$i),$d);
00109 }
00110 $rslt=$xml->asXML();
00111 header("Content-Type: text/xml");
00112 header("Content-Length: ".strlen($rslt)."\n");
00113 header("Pragma: no-cache\n");
00114 printf($rslt);
00115 }
00116
00117 function showHistGamma ($key,$value) {
00118 $xml = new SimpleXMLElement("<?xml version='1.0'?><framepars/>");
00119 switch($key) {
00120 case "histogram_direct":
00121 $xml->addChild ('histogram_direct_r', elphel_histogram(0,$value));
00122 $xml->addChild ('histogram_direct_g', elphel_histogram(1,$value));
00123 $xml->addChild ('histogram_direct_gb',elphel_histogram(2,$value));
00124 $xml->addChild ('histogram_direct_b', elphel_histogram(3,$value));
00125 break;
00126 case "histogram_reverse":
00127 $xml->addChild ('histogram_reverse_r', elphel_reverse_histogram(0,$value));
00128 $xml->addChild ('histogram_reverse_g', elphel_reverse_histogram(1,$value));
00129 $xml->addChild ('histogram_reverse_gb',elphel_reverse_histogram(2,$value));
00130 $xml->addChild ('histogram_reverse_b', elphel_reverse_histogram(3,$value));
00131 break;
00132 case "gamma_direct":
00133 $xml->addChild ('gamma_direct_r', elphel_gamma(0,$value));
00134 $xml->addChild ('gamma_direct_g', elphel_gamma(1,$value));
00135 $xml->addChild ('gamma_direct_gb',elphel_gamma(2,$value));
00136 $xml->addChild ('gamma_direct_b', elphel_gamma(3,$value));
00137 break;
00138 case "gamma_reverse":
00139 $xml->addChild ('gamma_reverse_r', elphel_reverse_gamma(0,$value));
00140 $xml->addChild ('gamma_reverse_g', elphel_reverse_gamma(1,$value));
00141 $xml->addChild ('gamma_reverse_gb',elphel_reverse_gamma(2,$value));
00142 $xml->addChild ('gamma_reverse_b', elphel_reverse_gamma(3,$value));
00143 break;
00144 }
00145 $rslt=$xml->asXML();
00146 header("Content-Type: text/xml");
00147 header("Content-Length: ".strlen($rslt)."\n");
00148 header("Pragma: no-cache\n");
00149 printf($rslt);
00150 }
00151
00152 function profileShow($num_entries) {
00153
00154
00155 $prof_template=array(
00156 "PROFILE00"=>0,"PROFILE01"=>0,
00157 "PROFILE02"=>0,"PROFILE03"=>0,
00158 "PROFILE04"=>0,"PROFILE05"=>0,
00159 "PROFILE06"=>0,"PROFILE07"=>0,
00160 "PROFILE08"=>0,"PROFILE09"=>0,
00161 "PROFILE10"=>0,"PROFILE11"=>0,
00162 "PROFILE12"=>0,"PROFILE13"=>0,
00163 "PROFILE14"=>0,"PROFILE15"=>0
00164 );
00165 $now=elphel_get_frame()-2;
00166 $time_start=elphel_get_fpga_time();
00167 $prof_raw=array();
00168 for ($i=$now-$num_entries-1;$i<=$now;$i++) {
00169 $prof_raw[$i]=elphel_get_P_arr($prof_template,$i);
00170 }
00171 $time_end=elphel_get_fpga_time();
00172 $prof=array();
00173 for ($i=$now-$num_entries;$i<=$now;$i++) {
00174 $prof[$i]=array ( "dt0"=>($prof_raw[$i]["PROFILE00"]-$prof_raw[$i-1]["PROFILE00"])*1000000+($prof_raw[$i]["PROFILE01"]-$prof_raw[$i-1]["PROFILE01"]),
00175 "dt1"=>($prof_raw[$i]["PROFILE02"]-$prof_raw[$i]["PROFILE00"])*1000000+($prof_raw[$i]["PROFILE03"]-$prof_raw[$i]["PROFILE01"]),
00176 "dt2"=>($prof_raw[$i]["PROFILE04"]-$prof_raw[$i]["PROFILE00"])*1000000+($prof_raw[$i]["PROFILE05"]-$prof_raw[$i]["PROFILE01"]),
00177 "dt3"=>($prof_raw[$i]["PROFILE06"]-$prof_raw[$i]["PROFILE00"])*1000000+($prof_raw[$i]["PROFILE07"]-$prof_raw[$i]["PROFILE01"]),
00178 "dt4"=>($prof_raw[$i]["PROFILE08"]-$prof_raw[$i]["PROFILE00"])*1000000+($prof_raw[$i]["PROFILE09"]-$prof_raw[$i]["PROFILE01"]),
00179 "dt5"=>($prof_raw[$i]["PROFILE10"]-$prof_raw[$i]["PROFILE00"])*1000000+($prof_raw[$i]["PROFILE11"]-$prof_raw[$i]["PROFILE01"]),
00180 "dt6"=>($prof_raw[$i]["PROFILE12"]-$prof_raw[$i]["PROFILE00"])*1000000+($prof_raw[$i]["PROFILE13"]-$prof_raw[$i]["PROFILE01"]),
00181 "dt7"=>($prof_raw[$i]["PROFILE14"]-$prof_raw[$i]["PROFILE00"])*1000000+($prof_raw[$i]["PROFILE15"]-$prof_raw[$i]["PROFILE01"]));
00182 foreach ($prof[$i] as $key=>$value) if ($prof[$i][$key]<0)$prof[$i][$key]="";
00183 }
00184 if (!elphel_get_P_value(ELPHEL_PROFILING_EN)) {
00185 echo <<<PROFILE_ENABLE
00186 <p><i>Interrupt service/tasklet profiling is currently disabled. You may enable it by following this link:
00187 <a href="/parsedit.php?PROFILING_EN=1">/parsedit.php?PROFILING_EN=1</a>
00188 </i></p>
00189 PROFILE_ENABLE;
00190 }
00191 echo <<<CAPTION
00192 <p>reading profile time start=$time_start </p>
00193 <p>reading profile time end=$time_end </p>
00194 <ol>Profiling interrupt/tasklet execution time in microseconds, starting from the start of the frame
00195 <li>after updating frame pointers, Exif, parameters structures (IRQ service)</li>
00196 <li>start of the tasklet</li>
00197 <li>after Y histogram (G1) load from the FPGA (if enabled)</li>
00198 <li>after processing parameters (actions triggered by the parameter changes), </li>
00199 <li>after C histograms (R,G2,B) load from the FPGA (if enabled)</li>
00200 <li>When parameters are started to be written by appliaction(s) - overwritten if several calls take place during the same frame</li>
00201 <li>When parameters are finished to be written by appliaction(s) (may be overwritten)</li>
00202 </oul>
00203 <br/><br/>
00204 CAPTION;
00205
00206 printf ("<table border='1'><tr><td>Frame</td><td>(hex)</td><td>Period</td><td>1</td><td>2</td><td>3</td><td>4</td><td>5</td><td>6</td><td>7</td></tr>\n");
00207 for ($i=$now-$num_entries;$i<=$now;$i++) {
00208 printf("<tr style='align:right'><td>%d</td><td>%08x</td><td>%d</td>",$i,$i,$prof[$i]["dt0"]);
00209 for ($j=1;$j<8;$j++) {
00210 if ($prof[$i]["dt".$j]) printf("<td>%d</td>",$prof[$i]["dt".$j]);
00211 else printf("<td> </td>");
00212 }
00213 printf("</tr>\n");
00214 }
00215 printf("</table>");
00216
00217
00218 }
00219
00220
00221
00222
00223 function printGammaStructure() {
00224 $gammaStructure=getGammaStructure();
00225 printf("<table \"border=1\">\n");
00226 printf( "<tr><td>oldest_non_scaled</td><td><b>%d</b></td></tr>\n"
00227 ."<tr><td>newest_non_scaled</td><td><b>%d</b></td></tr>\n"
00228 ."<tr><td>oldest_all</td><td><b>%d</b></td></tr>\n"
00229 ."<tr><td>newest_all</td><td><b>%d</b></td></tr>\n"
00230 ."<tr><td>non_scaled_length</td><td><b>%d</b></td></tr>\n"
00231 ."<tr><td>num_locked</td><td><b>%d</b></td></tr>\n"
00232 ."<tr><td>locked_col 0</td><td><b>%d</b></td>\n"
00233 ."<tr><td>locked_col 1</td><td><b>%d</b></td>\n"
00234 ."<tr><td>locked_col 2</td><td><b>%d</b></td>\n"
00235 ."<tr><td>locked_col 3</td><td><b>%d</b></td>\n"
00236 ."</table>\n",
00237 $gammaStructure["oldest_non_scaled"],
00238 $gammaStructure["newest_non_scaled"],
00239 $gammaStructure["oldest_all"],
00240 $gammaStructure["newest_all"],
00241 $gammaStructure["non_scaled_length"],
00242 $gammaStructure["num_locked"],
00243 $gammaStructure["locked_col"][0],
00244 $gammaStructure["locked_col"][1],
00245 $gammaStructure["locked_col"][2],
00246 $gammaStructure["locked_col"][3]
00247 );
00248 printf("<br/><br/>\n");
00249
00250 printf("<table \"border=1\">\n");
00251
00252 printf("<tr><td>index </td>\n"); foreach ($gammaStructure["entries"] as $entry)
00253 printf ("<td><a href='?gamma_page=%d'><b>%d</b></a></td>",$entry["index"],$entry["index"]);printf("</tr>\n");
00254
00255 printf("<tr><td>hash32 </td>\n"); foreach ($gammaStructure["entries"] as $entry) printf ("<td><b>%08x</b></td>",$entry["hash32"]);printf("</tr>\n");
00256 printf("<tr><td>scale </td>\n"); foreach ($gammaStructure["entries"] as $entry) printf ("<td><b>%01.3f</b></td>",$entry["scale"]);printf("</tr>\n");
00257 printf("<tr><td>gamma </td>\n"); foreach ($gammaStructure["entries"] as $entry) printf ("<td><b>%01.3f</b></td>",$entry["gamma"]);printf("</tr>\n");
00258 printf("<tr><td>black </td>\n"); foreach ($gammaStructure["entries"] as $entry) printf ("<td><b>%d</b></td>",$entry["black"]);printf("</tr>\n");
00259 printf("<tr><td>valid </td>\n"); foreach ($gammaStructure["entries"] as $entry) printf ("<td><b>0x%x</b></td>",$entry["valid"]);printf("</tr>\n");
00260 printf("<tr><td>locked </td>\n"); foreach ($gammaStructure["entries"] as $entry) printf ("<td><b>0x%8x</b></td>",$entry["locked"]);printf("</tr>\n");
00261 printf("<tr><td>this_non_scaled </td>\n"); foreach ($gammaStructure["entries"] as $entry) printf ("<td><b>%d</b></td>",$entry["this_non_scaled"]);printf("</tr>\n");
00262 printf("<tr><td>newer_non_scaled</td>\n"); foreach ($gammaStructure["entries"] as $entry) printf ("<td><b>%d</b></td>",$entry["newer_non_scaled"]);printf("</tr>\n");
00263 printf("<tr><td>older_non_scaled</td>\n"); foreach ($gammaStructure["entries"] as $entry) printf ("<td><b>%d</b></td>",$entry["older_non_scaled"]);printf("</tr>\n");
00264 printf("<tr><td>newer_all </td>\n"); foreach ($gammaStructure["entries"] as $entry) printf ("<td><b>%d</b></td>",$entry["newer_all"]);printf("</tr>\n");
00265 printf("<tr><td>older_all </td>\n"); foreach ($gammaStructure["entries"] as $entry) printf ("<td><b>%d</b></td>",$entry["older_all"]);printf("</tr>\n");
00266 printf("<tr><td>oldest_scaled </td>\n"); foreach ($gammaStructure["entries"] as $entry) printf ("<td><b>%d</b></td>",$entry["oldest_scaled"]);printf("</tr>\n");
00267 printf("<tr><td>newest_scaled </td>\n"); foreach ($gammaStructure["entries"] as $entry) printf ("<td><b>%d</b></td>",$entry["newest_scaled"]);printf("</tr>\n");
00268 printf("<tr><td>newer_scaled </td>\n"); foreach ($gammaStructure["entries"] as $entry) printf ("<td><b>%d</b></td>",$entry["newer_scaled"]);printf("</tr>\n");
00269 printf("<tr><td>older_scaled </td>\n"); foreach ($gammaStructure["entries"] as $entry) printf ("<td><b>%d</b></td>",$entry["older_scaled"]);printf("</tr>\n");
00270 printf("</table>\n");
00271 }
00272
00273 function getGammaStructure() {
00274 $gammas_file=fopen("/dev/gamma_cache","r");
00275 fseek($gammas_file,0,SEEK_END);
00276 $numberOfEntries=ftell($gammas_file);
00277 fclose($gammas_file);
00278 $gammaStructure=array();
00279 $g_raw=elphel_gamma_get_raw(0);
00280 $g_raw_ul=unpack('V*',$g_raw);
00281 $gammaStructure["oldest_non_scaled"]=$g_raw_ul[5];
00282 $gammaStructure["newest_non_scaled"]=$g_raw_ul[6];
00283 $gammaStructure["oldest_all"]= $g_raw_ul[7];
00284 $gammaStructure["newest_all"]= $g_raw_ul[8];
00285 $gammaStructure["non_scaled_length"]=$g_raw_ul[9];
00286 $gammaStructure["num_locked"]= $g_raw_ul[10];
00287 $gammaStructure["locked_col"]= array ($g_raw_ul[11],$g_raw_ul[12],$g_raw_ul[13],$g_raw_ul[14]);
00288 $gammaStructure["entries"]= array ();
00289 for ($i=1; $i<$numberOfEntries; $i++) {
00290 $g_raw=elphel_gamma_get_raw($i);
00291 $g_raw_ul=unpack('V*',$g_raw);
00292 if ($g_raw_ul[ 4]>=0) {
00293 $hash32= $g_raw_ul[1];
00294 $gammaStructure["entries"][$i]= array (
00295 "index" => $i,
00296 "hash32"=> $hash32,
00297 "scale" => ($hash32 & 0xffff)/1024.0,
00298 "gamma" => (($hash32 >> 16) & 0xff)/100.0,
00299 "black" => (($hash32 >> 24) & 0xff),
00300 "valid" => $g_raw_ul[ 2],
00301 "locked" => $g_raw_ul[ 3],
00302 "this_non_scaled" => $g_raw_ul[ 4],
00303
00304 "newer_non_scaled" => $g_raw_ul[ 5],
00305 "older_non_scaled" => $g_raw_ul[ 6],
00306
00307 "newer_all" => $g_raw_ul[ 7],
00308 "older_all" => $g_raw_ul[ 8],
00309
00310 "oldest_scaled" => $g_raw_ul[ 9],
00311 "newest_scaled" => $g_raw_ul[10],
00312 "newer_scaled" => $g_raw_ul[ 9],
00313 "older_scaled" => $g_raw_ul[10]
00314 );
00315 }
00316 }
00317 return $gammaStructure;
00318 }
00319
00320 function printRawGamma($page=0) {
00321 $g_raw=elphel_gamma_get_raw($page);
00322
00323 $g_raw_ul=unpack('V*',$g_raw);
00324 echo "<pre>\n";
00325 printf ("Gamma cache page %d, length=%d\n",$page, strlen($g_raw));
00326 $a=1;
00327 $hash32= $g_raw_ul[$a++];
00328 $scale= ($hash32 & 0xffff)/1024.0;
00329 $gamma= (($hash32 >> 16) & 0xff)/100.0;
00330 $black= (($hash32 >> 24) & 0xff);
00331 printf ("hash32= %08x (scale=%f gamma=%f black=%d)\n",$hash32,$scale,$gamma,$black);
00332 $valid= $g_raw_ul[$a++];
00333 printf ("valid=%d, locked=%d\n",$valid & 1, $valid & 2);
00334
00335 $locked= $g_raw_ul[$a++];
00336 printf ("locked= 0x%x (for frame=%d/color=%d)\n",$locked, $locked & 7, ($locked>>3) & 3);
00337
00338 $this_non_scaled=$g_raw_ul[$a++];
00339 printf ("this_non_scaled=%d\n",$this_non_scaled);
00340 if ($page==0) {
00341 printf ("oldest_non_scaled=%d\n",$g_raw_ul[$a++]);
00342 printf ("newest_non_scaled=%d\n",$g_raw_ul[$a++]);
00343 } else {
00344 printf ("newer_non_scaled=%d\n",$g_raw_ul[$a++]);
00345 printf ("older_non_scaled=%d\n",$g_raw_ul[$a++]);
00346 }
00347
00348 if ($page==0) {
00349 printf ("oldest_all=%d\n",$g_raw_ul[$a++]);
00350 printf ("newest_all=%d\n",$g_raw_ul[$a++]);
00351 } else {
00352 printf ("newer_all=%d\n",$g_raw_ul[$a++]);
00353 printf ("older_all=%d\n",$g_raw_ul[$a++]);
00354 }
00355
00356 if ($page==0) {
00357 printf ("non_scaled_length=%d\n",$g_raw_ul[$a++]);
00358 printf ("num_locked=%d\n",$g_raw_ul[$a++]);
00359 } else if ($this_non_scaled==0){
00360 printf ("oldest_scaled=%d\n",$g_raw_ul[$a++]);
00361 printf ("newest_scaled=%d\n",$g_raw_ul[$a++]);
00362 } else {
00363 printf ("newer_scaled=%d\n",$g_raw_ul[$a++]);
00364 printf ("older_scaled=%d\n",$g_raw_ul[$a++]);
00365 }
00367 if ($page==0) {
00368 printf ("\nTable of locked indexes\n");
00369 for ($color=0;$color<4; $color++) {
00370
00371 printf (" %4d",$g_raw_ul[$a++]);
00372
00373
00374 }
00375 printf ("\n");
00377 printf ("\n\nUnused area on page 0:");
00378
00379 for ($i=0; $i<445; $i++) {
00380 if (($i & 0x0f)==0) printf ("\n0x%03x:",$i);
00381 $d=$g_raw_ul[$a++];
00382 printf (" %08x",$d);
00383 }
00384
00385 } else {
00386 printf ("\nGamma table (direct):");
00387 for ($i=0; $i<129; $i++) {
00388 if (($i & 0x07)==0) printf ("\n0x%03x:",$i*2);
00389 $d=$g_raw_ul[$a++];
00390 printf (" %04x %04x",$d & 0xffff, ($d>>16) & 0xffff );
00391 }
00392 printf ("\n\nGamma table (reverse):");
00393 for ($i=0; $i<64; $i++) {
00394 if (($i & 0x03)==0) printf ("\n0x%03x:",$i*4);
00395 $d=$g_raw_ul[$a++];
00396 printf (" %02x %02x %02x %02x",$d & 0xff, ($d>>8) & 0xff, ($d>>16) & 0xff, ($d>>24) & 0xff);
00397 }
00398
00399 printf ("\n\nFPGA gamma data:");
00400 for ($i=0; $i<256; $i++) {
00401 if (($i & 0x0f)==0) printf ("\n0x%03x:",$i);
00402 $d=$g_raw_ul[$a++];
00403 printf (" %05x",$d);
00404 }
00405 }
00406 echo "</pre>\n";
00407 }
00408
00409 function printHistogram($frame) {
00410 if (!$frame) $frame=elphel_get_frame()-1;
00411 $colors=array(0=>"R",1=>"G",2=>"GB",3=>"B");
00412 $h_arr=elphel_histogram_get(0xfff,$frame);
00413 $a=0;
00414 $offset2sum=1024+255;
00415 echo "<pre>\n";
00416 for ($color=0;$color<4;$color++) {
00417 printf("\nhistogram for color #%d %s, Total number of pixels=%d (0x%x):",$color,$colors[$color],$h_arr[$a+$offset2sum],$h_arr[$a+$offset2sum]);
00418 for ($i=0; $i<256; $i++) {
00419 if (($i & 0x0f)==0) printf ("\n0x%03x:",$i);
00420 printf (" %05x",$h_arr[$a++]);
00421 }
00422 printf ("\n");
00423 }
00424 for ($color=0;$color<4;$color++) {
00425 printf("\ncumulative histogram for color #%d %s:",$color,$colors[$color]);
00426 for ($i=0; $i<256; $i++) {
00427 if (($i & 0x0f)==0) printf ("\n0x%03x:",$i);
00428 printf (" %08x",$h_arr[$a++]);
00429 }
00430 printf ("\n");
00431 }
00432 for ($color=0;$color<4;$color++) {
00433 printf("\npercentile for color #%d %s:",$color,$colors[$color]);
00434 for ($i=0; $i<256; $i++) {
00435 if (($i & 0x01f)==0) printf ("\n0x%03x:",$i);
00436 printf (" %02x",$h_arr[$a++]);
00437 }
00438 printf ("\n");
00439 }
00440 echo "</pre>\n";
00441 }
00442
00443 function printRawHistogram($needed,$frame) {
00444 if (!$frame) $frame=elphel_get_frame()-1;
00445 $percentile_start=8232;
00446 $colors=array(0=>"R",1=>"G",2=>"GB",3=>"B");
00447 $h_raw=elphel_histogram_get_raw($needed,$frame);
00448
00449 $h_raw_ul=unpack('V*',substr($h_raw,0,$percentile_start));
00450 echo "<pre>\n";
00451 $a=1;
00452 $hframe= $h_raw_ul[$a++];
00453 $valid= $h_raw_ul[$a++];
00454 $hash32_r= $h_raw_ul[$a++];
00455 $hash32_g= $h_raw_ul[$a++];
00456 $hash32_gb=$h_raw_ul[$a++];
00457 $hash32_b= $h_raw_ul[$a++];
00458
00459 printf ("Histogram for frame= %d (0x%x), valid mask=0x%x, requested=0x%x, data length=%d (0x%x)\n",$hframe,$hframe, $valid,$needed,strlen($h_raw),strlen($h_raw));
00460 printf ("hash32: R:0x%x G:0x%x GB:0x%x B:0x%x)\n",$hash32_r,$hash32_g,$hash32_gb,$hash32_b);
00461 for ($color=0;$color<4;$color++) {
00462 $sum=0;
00463 for ($i=0; $i<256; $i++) $sum+=$h_raw_ul[$a+$i];
00464 printf("\nhistogram for color #%d %s sum=%d (0x%x):",$color,$colors[$color],$sum,$sum);
00465 for ($i=0; $i<256; $i++) {
00466 if (($i & 0x0f)==0) printf ("\n0x%03x:",$i);
00467 $d=$h_raw_ul[$a++];
00468 printf (" %05x",$d);
00469 }
00470 printf ("\n");
00471 }
00472 for ($color=0;$color<4;$color++) {
00473 printf("\ncumulative histogram for color #%d %s:",$color,$colors[$color]);
00474 for ($i=0; $i<256; $i++) {
00475 if (($i & 0x0f)==0) printf ("\n0x%03x:",$i);
00476 $d=$h_raw_ul[$a++];
00477 printf (" %08x",$d);
00478 }
00479 printf ("\n");
00480 }
00481 for ($color=0;$color<4;$color++) {
00482 printf("\npercentile for color #%d %s:",$color,$colors[$color]);
00483 for ($i=0; $i<256; $i++) {
00484 if (($i & 0x01f)==0) printf ("\n0x%03x:",$i);
00485 printf (" %02x",ord($h_raw[$percentile_start+(256*$color)+$i]));
00486 }
00487 printf ("\n");
00488 }
00489 echo "</pre>\n";
00490 }
00491
00492
00493 function printRawFrame($frame) {
00494 $fp_raw=elphel_framepars_get_raw($frame);
00495 $fp_raw_ul=unpack('V*',$fp_raw);
00496 echo "<pre>\n";
00497 printf ("\nFrame= %d(%08x)\n",$frame,$frame);
00498 $a=1;
00499 echo ".pars:";
00500 for ($i=0; $i<927; $i++) {
00501 if (($i & 0x0f)==0) printf ("\n0x%03x:",$i);
00502 printf (" %08x:",$fp_raw_ul[$a++]);
00503 }
00504 printf ("\n.functions= %08x:",$fp_raw_ul[$a++]);
00505 echo "\n.modsince:";
00506 for ($i=0; $i<31; $i++) {
00507 if (($i & 0x0f)==0) printf ("\n0x%03x:",$i);
00508 printf (" %08x:",$fp_raw_ul[$a++]);
00509 }
00510 printf ("\n.modsince32= %08x:",$fp_raw_ul[$a++]);
00511 echo "\n.mod:";
00512 for ($i=0; $i<31; $i++) {
00513 if (($i & 0x0f)==0) printf ("\n0x%03x:",$i);
00514 printf (" %08x:",$fp_raw_ul[$a++]);
00515 }
00516 printf ("\n.mod32= %08x:",$fp_raw_ul[$a++]);
00517 echo "\n.needproc:";
00518 for ($i=0; $i<31; $i++) {
00519 if (($i & 0x0f)==0) printf ("\n0x%03x:",$i);
00520 printf (" %08x:",$fp_raw_ul[$a++]);
00521 }
00522 printf ("\n.needproc32= %08x:",$fp_raw_ul[$a++]);
00523
00524 echo "</pre>\n";
00525 }
00526
00527
00528 function myval ($s) {
00529 $current_frame=elphel_get_frame();
00530 $s=trim($s,"\" ");
00531 if (strtoupper(substr($s,0,2))=="0X") return intval(hexdec($s));
00532 else switch ($s) {
00533 case "this": return elphel_get_frame();
00534 break;
00535 case "next":
00536 case "next1": return elphel_get_frame()+1;
00537 break;
00538 case "next2": return elphel_get_frame()+2;
00539 break;
00540 case "next3": return elphel_get_frame()+3;
00541 break;
00542 case "next4": return elphel_get_frame()+4;
00543 break;
00544 case "next5": return elphel_get_frame()+5;
00545 break;
00546 case "next6": return elphel_get_frame()+6;
00547 break;
00548 break;
00549 case "prev":
00550 case "prev1": return elphel_get_frame()-1;
00551 break;
00552 case "prev2": return elphel_get_frame()-2;
00553 break;
00554 case "prev3": return elphel_get_frame()-3;
00555 break;
00556 case "prev4": return elphel_get_frame()-4;
00557 break;
00558 case "prev5": return elphel_get_frame()-5;
00559 break;
00560 case "prev6": return elphel_get_frame()-6;
00561 break;
00562 default:
00563 return intval($s);
00564 }
00565 }
00566 ?>