Commit eb070e5d authored by Clément Démoulins's avatar Clément Démoulins
Browse files

Make use of new functions for running binaries.

parent d31eb70a
......@@ -72,14 +72,11 @@ class DocumentSegmentation extends DemoPage
protected function exec_($input, $tmpfile)
{
exec("sudo -u webapp LD_LIBRARY_PATH=/home/lazzara/local/lib /home/lazzara/bin/content_in_doc {$input} {$tmpfile}.xml --more-xml-format page --more-xml-file {$tmpfile}_page.xml --debug-regions {$tmpfile}_regions.png", $output, $retval);
handle_errors($retval, $output);
exec("sudo -u webapp TEMPLATE_PATH=/home/lazzara/local/share/olena /home/lazzara/bin/scribo-xml2doc --pdf ${tmpfile}.xml {$input} {$tmpfile}.pdf 2>&1", $output, $retval);
handle_errors($retval, $output);
exec("sudo -u webapp TEMPLATE_PATH=/home/lazzara/local/share/olena /home/lazzara/bin/scribo-xml2doc --html ${tmpfile}.xml {$input} {$tmpfile}.html 2>&1", $output, $retval);
handle_errors($retval, $output);
$this->last_output = $output;
global $demos_bindir, $share_olena_templatepath;
$this->run("$demos_bindir/content_in_doc", "{$input} {$tmpfile}.xml --more-xml-format page --more-xml-file {$tmpfile}_page.xml --debug-regions {$tmpfile}_regions.png");
$this->run("$demos_bindir/scribo-xml2doc", "--template-path $share_olena_templatepath --pdf ${tmpfile}.xml {$input} {$tmpfile}.pdf 2>&1");
$this->run("$demos_bindir/scribo-xml2doc", "--template-path $share_olena_templatepath --html ${tmpfile}.xml {$input} {$tmpfile}.html 2>&1");
return Array("{$tmpfile}_regions.png", "{$tmpfile}.xml", "{$tmpfile}_page.xml", "{$tmpfile}.pdf", "{$tmpfile}.html");
}
......
<?php
include_once "inc/demopage.php";
......@@ -10,8 +11,6 @@ include_once "form_maker.php";
class EnergyEstimator extends DemoPage
{
private $last_output;
public function id()
{
return 3;
......@@ -121,28 +120,20 @@ HEADER;
protected function exec_($input, $tmpfile)
{
global $demos_bindir;
$args = check_object_segmentation_args();
if ($args['filtermode'] == 1)
exec("sudo -u webapp /home/lazzara/bin/tos_object_segmentation $input {$tmpfile}_orig.png {$tmpfile}.png \
-tk {$args['tk']} -c1 {$args['c1']} -c2 {$args['c2']} -a {$args['a']} -h {$args['h']} -tv {$args['tv']} -s 1",
$output, $retval);
$this->run("$demos_bindir/tos_object_segmentation",
"$input {$tmpfile}_orig.png {$tmpfile}.png \
-tk {$args['tk']} -c1 {$args['c1']} -c2 {$args['c2']} -a {$args['a']} -h {$args['h']} -tv {$args['tv']} -s 1");
else if ($args['filtermode'] == 2)
exec("sudo -u webapp /home/lazzara/bin/tos_object_segmentation $input {$tmpfile}_orig.png {$tmpfile}.png \
-tk {$args['tk']} -c1 {$args['c1']} -c2 {$args['c2']} -a {$args['a']} -e {$args['e']} -s 2",
$output, $retval);
$this->run("$demos_bindir/tos_object_segmentation",
"$input {$tmpfile}_orig.png {$tmpfile}.png \
-tk {$args['tk']} -c1 {$args['c1']} -c2 {$args['c2']} -a {$args['a']} -e {$args['e']} -s 2");
else
handle_errors(1);
handle_errors($retval, $output);
// A copy of the input file is made and will be deleted by the
// crontab after 15min. It is intended in order to allow the user to
// reuse the uploaded image and adjust parameters.
/* if(is_file("{$input}")) */
/* exec("sudo -u webapp rm {$input}"); */
$this->last_output = $output;
return Array("{$tmpfile}.png", "{$tmpfile}_orig.png");
}
......
......@@ -72,8 +72,8 @@ class HistoricalDocumentSegmentation extends DemoPage
protected function exec_($input, $tmpfile)
{
exec("sudo -u webapp LD_LIBRARY_PATH=/home/lazzara/local/lib /home/lazzara/bin/content_in_hdoc_hdlac {$input} {$tmpfile}_page.xml {$tmpfile}_regions.png", $output, $retval);
handle_errors($retval, $output);
global $demos_bindir;
$this->run("$demos_bindir/content_in_hdoc_hdlac", "{$input} {$tmpfile}_page.xml {$tmpfile}_regions.png");
return Array("{$tmpfile}_page.xml", "{$tmpfile}_regions.png");
}
......
......@@ -7,8 +7,6 @@ include_once "form_maker.php";
class RegionAdjacencyGraph extends DemoPage
{
private $last_output;
public function id()
{
return 4;
......@@ -70,19 +68,11 @@ class RegionAdjacencyGraph extends DemoPage
protected function exec_($input, $tmpfile)
{
global $demos_bindir;
$args = check_region_adjacency_graph_args();
exec("sudo -u webapp /home/lazzara/bin/region_adjacency_graph $input {$tmpfile}_orig.png {$tmpfile}.png {$args['area']}",
$output, $retval);
handle_errors($retval, $output);
// A copy of the input file is made and will be deleted by the
// crontab after 15min. It is intended in order to allow the user to
// reuse the uploaded image and adjust parameters.
// Output files will also be deleted within 15minutes.
$this->run("$demos_bindir/region_adjacency_graph", "$input {$tmpfile}_orig.png {$tmpfile}.png {$args['area']}");
$this->last_output = $output;
return Array("{$tmpfile}_orig.png", "{$tmpfile}.png");
}
......
......@@ -9,8 +9,6 @@ include_once "form_maker.php";
class SauvolaMs extends DemoPage
{
private $last_output;
public function id()
{
return 1;
......@@ -85,19 +83,17 @@ class SauvolaMs extends DemoPage
protected function exec_($input, $tmpfile)
{
global $demos_bindir;
$args = check_sauvola_ms_args();
// Make sure the input image can be displayed in the browser.
exec("sudo -u webapp convert {$input} {$tmpfile}_orig.png", $trash, $retval);
handle_errors($retval);
exec("sudo -u webapp /home/lazzara/bin/sauvola_ms {$tmpfile}_orig.png {$tmpfile}.png --k2 {$args['opt_k2']} --k3 {$args['opt_k3']} --k4 {$args['opt_k4']} --win-size {$args['opt_win']} --verbose full 2>&1", $output, $retval);
handle_errors($retval);
$this->last_output = $output;
$this->run("convert", "{$input} {$tmpfile}_orig.png", false);
exec("sudo -u webapp convert -negate {$tmpfile}.png {$tmpfile}.png", $trash, $retval);
// Run binarization.
$this->run("$demos_bindir/sauvola_ms",
"{$tmpfile}_orig.png {$tmpfile}.png --k2 {$args['opt_k2']} --k3 {$args['opt_k3']} --k4 {$args['opt_k4']} --win-size {$args['opt_win']} --verbose full --enable-negate 2>&1",
true);
handle_errors($retval);
return Array("{$tmpfile}.png", "{$tmpfile}_orig.png");
}
......
......@@ -17,8 +17,6 @@ $nbhs = Array( "C4" => "4", "C8" => "8" );
class ShapeMorphology extends DemoPage
{
private $last_output;
public function id()
{
return 5;
......@@ -106,6 +104,7 @@ class ShapeMorphology extends DemoPage
protected function exec_($input, $tmpfile)
{
global $demos_bindir;
$args = check_shape_morpho_args();
$reverse="";
......@@ -113,44 +112,32 @@ class ShapeMorphology extends DemoPage
$reverse=" -r ";
// Make sure the input image can be displayed in the browser.
exec("sudo -u webapp convert {$input} {$tmpfile}.png", $trash, $retval);
handle_errors($retval);
$this->run("convert", "{$input} {$tmpfile}.png");
// Adjust options according to the shape operator.
if ($args['opt_shape_op'] == 1)
{
$bin = "/home/lazzara/bin/tos_filter_exe_online";
$bin = "$demos_bindir/tos_filter_exe_online";
$nbh = "";
}
else
{
$bin = "/home/lazzara/bin/mintree_filter_exe_online";
$bin = "$demos_bindir/mintree_filter_exe_online";
$nbh = "-n {$args['opt_nbh']}";
}
// Run algorithm according to filtering strategy
if ($args['opt_strategy'] == 2) // Extinction
{
exec("sudo -u webapp $bin $input -e {$args['opt_attribute']} -t {$args['opt_thresval']} -a {$args['opt_area']} -s {$args['opt_strategy']} -c {$args['opt_reconstructionrule']} $reverse $nbh -o {$tmpfile}_orig.png",
$output, $retval);
$this->run("$bin", "$input -e {$args['opt_attribute']} -t {$args['opt_thresval']} -a {$args['opt_area']} -s {$args['opt_strategy']} -c {$args['opt_reconstructionrule']} $reverse $nbh -o {$tmpfile}_orig.png");
}
else if ($args['opt_strategy'] == 1) // Pruning
{
exec("sudo -u webapp $bin $input -e {$args['opt_attribute']} -t {$args['opt_thresval']} -ee {$args['opt_secondattrib']} -a {$args['opt_area']} -s {$args['opt_strategy']} -c {$args['opt_reconstructionrule']} $reverse $nbh -o {$tmpfile}_orig.png",
$output, $retval);
$this->run("$bin", "$input -e {$args['opt_attribute']} -t {$args['opt_thresval']} -ee {$args['opt_secondattrib']} -a {$args['opt_area']} -s {$args['opt_strategy']} -c {$args['opt_reconstructionrule']} $reverse $nbh -o {$tmpfile}_orig.png");
}
else
handle_errors(1);
handle_errors($retval, $output);
// A copy of the input file is made and will be deleted by the
// crontab after 15min. It is intended in order to allow the user to
// reuse the uploaded image and adjust parameters.
/* if(is_file("{$input}")) */
/* exec("sudo -u webapp rm {$input}"); */
$this->last_output = $output;
return Array("{$tmpfile}.png", "{$tmpfile}_orig.png");
}
......
......@@ -50,11 +50,6 @@ include_once "inc/demopage.php";
class Example extends DemoPage
{
// Last execution output. Useful for error handling and/or
// displaying results.
private $last_output;
// Edit inc/config.php to find the new demo id.
public function id()
{
......@@ -125,14 +120,14 @@ class Example extends DemoPage
// Execution of the demo
protected function exec_($input, $tmpfile)
{
global $demos_bindir;
// Make sure the input image can be displayed in the browser.
exec("sudo -u webapp convert {$input} {$tmpfile}_orig.png", $trash, $retval);
handle_errors($retval);
$this->run("convert", "{$input} {$tmpfile}_orig.png");
// Run the demo
exec("sudo -u webapp /home/lazzara/bin/staff_removal {$tmpfile}_orig.png {$tmpfile}.png", $output, $retval);
handle_errors($retval);
$this->last_output = $output;
$this->run("$demos_bindir/staff_removal",
"{$tmpfile}_orig.png {$tmpfile}.png");
// Files to be displayed as results should be listed here.
return Array("{$tmpfile}.png", "{$tmpfile}_orig.png");
......@@ -160,8 +155,8 @@ class Example extends DemoPage
$dir = $session->current_example_dir();
$file = $session->current_example_file();
$res1 = "examples/$dir/results/{$file}_1.png";
$res2 = "examples/$dir/results/{$file}_2.png";
$res1 = "examples/$dir/results/{$file}_2.png";
$res2 = "examples/$dir/results/{$file}_1.png";
return render_image_result($this, $this->last_output, 'time_functor', $res1, $res2, false);
}
......
......@@ -8,9 +8,6 @@ include_once "inc/demopage.php";
class TextDetectionInPics extends DemoPage
{
private $last_output;
public function id()
{
return 0;
......@@ -63,21 +60,11 @@ class TextDetectionInPics extends DemoPage
protected function exec_($input, $tmpfile)
{
exec("sudo -u webapp convert {$input} {$tmpfile}_orig.png");
exec("sudo -u webapp /home/lazzara/bin/text_in_picture {$tmpfile}_orig.png $tmpfile 1 1 1 1 1", $output, $retval);
exec("sudo -u webapp convert $tmpfile {$tmpfile}.png");
exec("sudo -u webapp convert ${tmpfile}_input_with_bboxes.ppm {$tmpfile}_orig.png");
handle_errors($retval);
if(is_file($tmpfile))
exec("sudo -u webapp rm $tmpfile");
if(is_file($tmpfile."_input_with_bboxes.ppm"))
exec("sudo -u webapp rm {$tmpfile}_input_with_bboxes.ppm");
global $demos_bindir;
$this->last_output = $output;
$this->run("convert", "{$input} {$tmpfile}_orig.png", false);
$this->run("$demos_bindir/text_in_picture", "{$tmpfile}_orig.png {$tmpfile}.png --enable-fg-extraction --enable-alternate-results --debug-prefix $tmpfile");
$this->run("convert", "${tmpfile}_001_input_with_bboxes.ppm {$tmpfile}_orig.png");
return Array("{$tmpfile}.png", "{$tmpfile}_orig.png");
}
......
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