forked from itownsResearch/alegoria
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlaunchMicMac.php
77 lines (64 loc) · 2.13 KB
/
launchMicMac.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
<?php
$img_name = $_GET['imagename'];
//Method to execute a command in the terminal
function terminal($command)
{
//system
//add MicMac to global Path
$path = '/var/www/micmac/bin';
putenv('PATH=' . getenv('PATH') . PATH_SEPARATOR . $path);
if(function_exists('system'))
{
ob_start();
system($command , $return_var);
$output = ob_get_contents();
ob_end_clean();
}
//passthru
else if(function_exists('passthru'))
{
ob_start();
passthru($command , $return_var);
$output = ob_get_contents();
ob_end_clean();
}
//exec
else if(function_exists('exec'))
{
exec($command , $output , $return_var);
$output = implode("n" , $output);
}
//shell_exec
else if(function_exists('shell_exec'))
{
$output = shell_exec($command) ;
}
else
{
$output = 'Command execution not possible on this system';
$return_var = 1;
}
return array('input' => $command, 'output' => $output , 'status' => $return_var);
}
//MicMac inputs
$path_to_output = "../data/test";
$path_to_data = "../data";
//$img_name = "FRAN_0207_0628_L.jpg";
$calib_file = "Ori-CalInit";
$imagename = preg_replace('/\\.[^.\\s]{3,4}$/', '', $img_name);
$gcp_file = 'gcp_'. $imagename . '.xml';
$appuis_file = 'appuis_'. $imagename . '.xml';
//copy image from data directory to outputs directory for micmac reasons...
//copy($path_to_data."\\".$img_name,$path_to_output."\\".$img_name);
copy($path_to_data.DIRECTORY_SEPARATOR.$img_name,$path_to_output.DIRECTORY_SEPARATOR.$img_name);
//change current directory to outputs directory
chdir($path_to_output);
//MicMac command to compute image orientation based on calibration file, 2D image coordinates file, and 3D ground control points file
$cmd = "mm3d aspro" . " " . $img_name . " " . $calib_file . " " . $gcp_file . " " . $appuis_file;
//echo $cmd ;
// $cmd = "mm3d Init11P " . $gcp_file . " " . $appuis_file . " Rans=[500,6]" ;
//retrieve MicMac command output and store it into an array
$output_array = terminal($cmd);
//encode the output as json
echo json_encode($output_array);
?>