Commit 0baa7e8b authored by Oleg Dzhimiev's avatar Oleg Dzhimiev
Browse files

added photo finish demo

parent 8957a60a
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
# Runs 'make', 'make install', and 'make clean' in specified subdirectories
SUBDIRS := src/php_top src/python_tests src/debugfs-webgui src/jp4-canvas src/update src/eyesis4pi src/index src/pointers src/snapshot src/jp4-viewer # src1
SUBDIRS := src/php_top src/python_tests src/debugfs-webgui src/jp4-canvas src/update src/eyesis4pi src/index src/pointers src/snapshot src/jp4-viewer src/photofinish # src1
INSTALLDIRS = $(SUBDIRS:%=install-%)
CLEANDIRS =   $(SUBDIRS:%=clean-%)

+41 −0
Original line number Diff line number Diff line
<!doctype html>
<html lang="en">
  <head>
    <meta charset="utf-8"/>
    <meta name="author" content="?"/>
    <link rel="stylesheet" href="/js/bootstrap/css/bootstrap.css">
    <style>
      #control-panel{
        padding: 5px 5px 0px 5px;
      }
      #display-panel{
        padding: 5px 5px 0px 5px;
      }

    </style>
  </head>
  <body>

    <table>
    <tr>
      <td>
        <div id='control-panel'>
          <button id='init' title='init linescan mode' class='btn btn-default btn-danger '>init</button>
          <button id='refresh' title='refresh image (no sync)' class='btn btn-default btn-success '>refresh</button>
        </div>
      </td>
    </tr>
    <tr>
      <td><div id='display-panel'></div></td>
    </tr>
    </table>

    <script src="/js/elphel.js"></script>
    <script src="/js/jquery-3.1.1.js"></script>
    <script src="/js/jcanvas.js"></script>
    <script src="/js/exif.js"></script>
    <script src="/js/jquery-jp4.js"></script>
    <script src="photo-finish.js"></script>

  </body>
</html>
+75 −0
Original line number Diff line number Diff line
/**
 * @file photo-finish.js
 * @brief simple demo
 * @copyright Copyright (C) 2018 Elphel Inc.
 * @author Oleg Dzhimiev <oleg@elphel.com>
 *
 * @licstart  The following is the entire license notice for the
 * JavaScript code in this page.
 *
 *   The JavaScript code in this page is free software: you can
 *   redistribute it and/or modify it under the terms of the GNU
 *   General Public License (GNU GPL) as published by the Free Software
 *   Foundation, either version 3 of the License, or (at your option)
 *   any later version.  The code is distributed WITHOUT ANY WARRANTY;
 *   without even the implied warranty of MERCHANTABILITY or FITNESS
 *   FOR A PARTICULAR PURPOSE.  See the GNU GPL for more details.
 *
 *   As additional permission under GNU GPL version 3 section 7, you
 *   may distribute non-source (e.g., minimized or compacted) forms of
 *   that code without the copy of the GNU GPL normally required by
 *   section 4, provided you include this license notice and a URL
 *   through which recipients can access the Corresponding Source.
 *
 *  @licend  The above is the entire license notice
 *  for the JavaScript code in this page.
 */

$(function(){

  $("#init").on('click',function(){
    console.log("init photo finish");
  });

  $("#refresh").on('click',function(){
    console.log("refresh images");
  });

  var t1 = $("#display-panel").jp4({
    ip:"127.0.0.1",
    port:2323,
    width:600,
    fast:true,
    lowres:0,
    webworker_path:"/js"
  });

  $("#display-panel").on("canvas_ready",function(){

    // get display canvas - hide
    var cnv_old = $(this).find("#display")[0];

    $(cnv_old).hide();

    var w = cnv_old.width;
    var h = cnv_old.height;

    var parent = $(cnv_old).parent();

    cnv_new = $("<canvas>",{id:"display2"});
    parent.append(cnv_new);

    var ctx = cnv_new[0].getContext("2d");

    ctx.canvas.width=h;
    ctx.canvas.height=w;

    ctx.save();
    ctx.rotate(90*Math.PI/180);
    ctx.scale(1, -1);
    ctx.drawImage(cnv_old,0,0,w,h,0,0,w,h);
    ctx.restore();

  });

});
+88 −0
Original line number Diff line number Diff line
<?php
/**
 * @file photo-finish.php
 * @brief -
 * @copyright Copyright (C) 2018 Elphel Inc.
 * @author Oleg Dzhimiev <oleg@elphel.com>
 *
 * @par <b>License</b>:
 *  This program is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/

$help = <<<HELP
Description:
  This scripts sets up a photo finish mode. Will work for port 0, to change
  the port - edit this script.
HELP;

if (isset($argv[1])){
  $_GET['cmd'] = $argv[1];
}

if (isset($_GET['cmd'])){
  $cmd = $_GET['cmd'];
}else{
  $cmd = "donothing";
}

$sensor_port = 0;
$master_port = 0;

// $pars_init_X order is important,
// photo finish is a sensitive mode

// reset
$pars_init_0 = array(
  'WB_EN' => 0,
  'AUTOEXP_ON' => 0,
  'TRIG' => 0,
  'EXPOS' => 300,
  'COMPRESSOR_RUN' => 0
);

// set linescan mode
$pars_init_1 = array(
  'COLOR' => 5,
  'TRIG' => 4,
  'TRIG_PERIOD' => 100000, // 2000fps
  'PF_HEIGHT' => 2,
  'WOI_HEIGHT' => 16, // for faster work
);

$pars_init_2 = array(
  'WOI_HEIGHT' => 8000 // equals to 10 seconds for 400fps
);

$pars_init_3 = array(
  'EXPOS' => 300,
  'TRIG_PERIOD' => 250000, // 400fps, 2xFPS should cover 1 second
  'COMPRESSOR_RUN' => 2
);

if ($cmd=="init"){

  $frame_num = elphel_get_frame($sensor_port);

  elphel_set_P_arr($sensor_port,$pars_init_0,$frame_num+3);
  elphel_set_P_arr($sensor_port,$pars_init_1,$frame_num+6);
  elphel_set_P_arr($sensor_port,$pars_init_2,$frame_num+9);
  elphel_set_P_arr($sensor_port,$pars_init_3,$frame_num+11);

  elphel_wait_frame_abs($sensor_port,$frame_num+12);

  echo "OK\n";

}

?>