Commit 89621f29 authored by Oleg Dzhimiev's avatar Oleg Dzhimiev

dl exif histories if '?debug' in GET

parent 0221ad74
...@@ -25,12 +25,14 @@ ...@@ -25,12 +25,14 @@
$port0 = 2323; $port0 = 2323;
$path = "/sys/devices/soc0/elphel393-detect_sensors@0"; $path = "/sys/devices/soc0/elphel393-detect_sensors@0";
$available_ports = Array(); $available_ports = Array();
$trig_master = -1; $trig_master = -1;
$trig_master_port = -1; $trig_master_port = -1;
$dl_exif_histories = 0;
for($i=0;$i<4;$i++){ for($i=0;$i<4;$i++){
$sensor = $path."/sensor{$i}0"; $sensor = $path."/sensor{$i}0";
if (is_file($sensor)){ if (is_file($sensor)){
$c = trim(file_get_contents($sensor)); $c = trim(file_get_contents($sensor));
...@@ -46,20 +48,53 @@ ...@@ -46,20 +48,53 @@
$trig_master = intval(elphel_get_P_value($available_ports[0]-$port0,ELPHEL_TRIG_MASTER)); $trig_master = intval(elphel_get_P_value($available_ports[0]-$port0,ELPHEL_TRIG_MASTER));
$trig_master_port = $trig_master + $port0; $trig_master_port = $trig_master + $port0;
} }
if (isset($_GET['debug'])){
$dl_exif_histories = 1;
}
if ($trig_master>=0){ if ($trig_master>=0){
if (isset($_GET['trig'])){ if (isset($_GET['trig'])){
// just in case one wants to override master // just in case one wants to override master
if (isset($_GET['port'])){ if (isset($_GET['port'])){
$trig_master_port = $_GET['port']; $trig_master_port = $_GET['port'];
} }
$f = fopen("http://{$_SERVER['SERVER_ADDR']}:$trig_master_port/trig/pointers", 'r'); $f = fopen("http://{$_SERVER['SERVER_ADDR']}:$trig_master_port/trig/pointers", 'r');
fclose($f); fclose($f);
die("trigger ok: http://{$_SERVER['SERVER_ADDR']}:$trig_master_port/trig/pointers"); die("trigger ok: http://{$_SERVER['SERVER_ADDR']}:$trig_master_port/trig/pointers");
}
// get exif data from all buffers in a single text file
if (isset($_GET['exifs'])){
if (isset($_GET['sensor_port'])){
$port = $_GET['sensor_port'];
}else{
$port = $available_ports[0]-$port0;
}
$circbuf_pointers = elphel_get_circbuf_pointers($port,1);
// get metas
$meta = array();
foreach($circbuf_pointers as $k=>$v){
$meta[$k] = array (
'circbuf_pointer' => $v['circbuf_pointer'],
'meta' => elphel_get_interframe_meta($port,$v['circbuf_pointer']),
'Exif' => elphel_get_exif_elphel($port, $v['exif_pointer'])
);
}
print_r($meta);
die();
} }
} }
?> ?>
...@@ -68,16 +103,16 @@ ...@@ -68,16 +103,16 @@
<head> <head>
<meta charset="utf-8"/> <meta charset="utf-8"/>
<title>Snapshot</title> <title>Snapshot</title>
<script type='text/javascript' src='snapshot.js'></script> <script type='text/javascript' src='snapshot.js'></script>
<script type='text/javascript' src='../js/jquery-3.1.1.js'></script> <script type='text/javascript' src='../js/jquery-3.1.1.js'></script>
<style> <style>
body { body {
font-family: "Helvetica Neue", Helvetica; font-family: "Helvetica Neue", Helvetica;
} }
.button{ .button{
font-weight: bold; font-weight: bold;
border-radius:3px; border-radius:3px;
...@@ -88,7 +123,7 @@ ...@@ -88,7 +123,7 @@
text-decoration: none; text-decoration: none;
display: inline-block; display: inline-block;
} }
#snapshot{ #snapshot{
background-color: #CF4040; /* not Green */ background-color: #CF4040; /* not Green */
padding: 32px 32px; padding: 32px 32px;
...@@ -102,41 +137,44 @@ ...@@ -102,41 +137,44 @@
#snapshot:active{ #snapshot:active{
background-color: #9F4040; /* not Green */ background-color: #9F4040; /* not Green */
} }
#snapshot:disabled{ #snapshot:disabled{
background-color: #A0A0A0; /* not Green */ background-color: #A0A0A0; /* not Green */
} }
#synced{ #synced{
width:25px; width:25px;
height:25px; height:25px;
} }
#help_button{ #help_button{
background-color: #404040; /* not Green */ background-color: #404040; /* not Green */
padding: 3px 7px; padding: 3px 7px;
font-size: 15px; font-size: 15px;
} }
#help_button:hover{ #help_button:hover{
background-color: #303030; /* not Green */ background-color: #303030; /* not Green */
} }
#help_button:active{ #help_button:active{
background-color: #202020; /* not Green */ background-color: #202020; /* not Green */
} }
</style> </style>
<script> <script>
var ip = location.origin; var ip = location.origin;
var href = location.href; //var href = location.href;
var ports = [<?php echo implode(",",$available_ports);?>]; var ports = [<?php echo implode(",",$available_ports);?>];
var trig_master = <?php echo $trig_master;?>; var trig_master = <?php echo $trig_master;?>;
var trig_master_port = <?php echo $trig_master_port;?>; var trig_master_port = <?php echo $trig_master_port;?>;
var dl_exif_histories = <?php echo $dl_exif_histories;?>;
</script> </script>
</head> </head>
<body> <body>
<div> <div>
...@@ -154,7 +192,7 @@ ...@@ -154,7 +192,7 @@
</div> </div>
<br/> <br/>
<div id='help' style='display:none;'> <div id='help' style='display:none;'>
<b>if checked</b>: <b>if checked</b>:
<ul> <ul>
<li>all ports - same timestamp</li> <li>all ports - same timestamp</li>
<li>fps will be reprogrammed - set to single trigger mode then restored - careful if some other program is doing recording</li> <li>fps will be reprogrammed - set to single trigger mode then restored - careful if some other program is doing recording</li>
......
var tp_old = 0; var tp_old = 0;
var DLC = 0; var DLC = 0;
var DLC_exif = 0;
var filenames = [];
function take_snapshot(){ function take_snapshot(){
...@@ -31,7 +33,7 @@ function read_trig_master(){ ...@@ -31,7 +33,7 @@ function read_trig_master(){
function trigger(){ function trigger(){
$.ajax({ $.ajax({
url:href+"?trig", url:"?trig",
success:function(){ success:function(){
setTimeout(function(){ setTimeout(function(){
...@@ -46,7 +48,8 @@ function download_all(rtp){ ...@@ -46,7 +48,8 @@ function download_all(rtp){
DLC = 0; DLC = 0;
ports.forEach(function(c,i){ ports.forEach(function(c,i){
download_single(ip+":"+c+"/timestamp_name/img"); //download_single(ip+":"+c+"/timestamp_name/img");
download_single(ip+":"+c+"/timestamp_name/bimg");
}); });
} }
...@@ -71,7 +74,12 @@ function download_single(addr){ ...@@ -71,7 +74,12 @@ function download_single(addr){
DLC++; DLC++;
if (DLC==ports.length){ if (DLC==ports.length){
if ($("#synced").prop("checked")) { if ($("#synced").prop("checked")) {
read_tp(); if (dl_exif_histories==1){
console.log("getting exif histories");
get_exifs();
}else{
read_tp();
}
}else{ }else{
$("#snapshot").attr("disabled",false); $("#snapshot").attr("disabled",false);
} }
...@@ -100,6 +108,8 @@ function pass_to_file_reader(filename,fileblob){ ...@@ -100,6 +108,8 @@ function pass_to_file_reader(filename,fileblob){
} }
} }
filenames.push(filename);
var url = window.URL.createObjectURL(fileblob); var url = window.URL.createObjectURL(fileblob);
var a = $('<a>') var a = $('<a>')
...@@ -158,6 +168,55 @@ function pass_to_file_reader(filename,fileblob){ ...@@ -158,6 +168,55 @@ function pass_to_file_reader(filename,fileblob){
} }
function get_exifs(){
DLC_exif = 0;
filenames.forEach(function(c,i){
var base = c.split(".");
base = base[0];
var port = base.split("_");
port = port[2];
var filename = base+"_exifs.txt";
var addr = "?exifs&sensor_port="+port;
var http = new XMLHttpRequest();
http.open("GET", addr, true);
http.responseType = "blob";
http.onload = function(e){
if (this.status === 200) {
// To access the header, had to add
// printf("Access-Control-Expose-Headers: Content-Disposition\r\n");
// to imgsrv
//var filename = this.getResponseHeader("Content-Disposition");
pass_to_file_reader(filename,http.response);
DLC_exif++;
if (DLC_exif==ports.length){
if ($("#synced").prop("checked")) {
// empty
filenames = [];
read_tp();
}else{
$("#snapshot").attr("disabled",false);
}
}
}
}
http.send();
});
}
function read_tp(){ function read_tp(){
var param = "TRIG_PERIOD"; var param = "TRIG_PERIOD";
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment