/
image.php
51 lines (39 loc) · 1.26 KB
/
image.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
<?php
require_once('lib/nusoap.php');
// set default timezone
date_default_timezone_set('Europe/Sofia');
function classifyImage($image) {
file_put_contents('tmp/img', base64_decode($image));
$command = escapeshellcmd('python /var/www/soap/classificator/classify.py /var/www/soap/tmp/img');
$output = shell_exec($command);
return $output;
}
function getSobel($image) {
file_put_contents('tmp/img', base64_decode($image));
$command = escapeshellcmd('python /var/www/soap/sobel/sobel.py /var/www/soap/tmp/img');
$output = shell_exec($command);
return $output;
}
// create soap server
$server = new soap_server();
// configure wisdl
$server->configureWSDL("image", "urn:image");
// register classify image method
$server->register("classifyImage",
array("image" => "xsd:string"),
array("return" => "xsd:string"),
"urn:image",
"urn:image#classifyImage",
"rpc",
"encoded",
"Classify image in a category");
// register get sobel method
$server->register("getSobel",
array("image" => "xsd:string"),
array("return" => "xsd:string"),
"urn:image",
"urn:image#getSobel",
"rpc",
"encoded",
"Get the Sobel edge detection image");
$server->service($HTTP_RAW_POST_DATA);