diff --git a/README.md b/README.md index dc191b4..1545272 100644 --- a/README.md +++ b/README.md @@ -12,6 +12,9 @@ Information on the provided functionalities can be found in the reports * [D5.4 Shape grammars for almost invisible structures Software prototype v2](http://duraark.eu/wp-content/uploads/2015/08/DURAARK_D5.5.4.pdf) * [D2.5 Software prototype v2, Section 4.4](http://duraark.eu/wp-content/uploads/2015/08/DURAARK_D2_5_final.pdf) (overview) +### Usage + +Usage documentation is available [here](https://github.com/DURAARK/duraark-geometricenrichment/wiki). ### Dependencies The service depends on the following DURAARK components: @@ -44,8 +47,9 @@ Our recommended stack is to install DURAARK on a Docker-compatible Linux system On the host you want to deploy the service execute the following steps (assuming that Docker and Docker Compose are installed and working): ```js -> git clone https://github.com/DURAARK/duraark-geometricenrichment.git +> git clone --recursive https://github.com/DURAARK/duraark-geometricenrichment.git > cd duraark-geometricenrichment +> sudo mkdir -p /duraark-storage/sessions > docker-compose up -d ``` @@ -58,9 +62,10 @@ The files you want to use have to be put into the folder **/tmp/duraark/files**. To setup the environment follow these steps: ```js -> git clone https://github.com/DURAARK/duraark-geometricenrichment.git +> git clone --recursive https://github.com/DURAARK/duraark-geometricenrichment.git > cd duraark-geometricenrichment > npm install +> mkdir -p /duraark-storage/sessions > docker-compose -f devenv-compose.yml build > docker-compose -f devenv-compose.yml up -d ``` diff --git a/src/api/controllers/RiseController.js b/src/api/controllers/RiseController.js index 784eaa5..8dd2b00 100644 --- a/src/api/controllers/RiseController.js +++ b/src/api/controllers/RiseController.js @@ -151,6 +151,7 @@ function prepareWiregen(session) { } function startWiregen(session) { + return new Promise(function(resolve, reject) { console.log('[SessionController::start Wiregen]'); prepareWiregen(session); @@ -158,11 +159,14 @@ function startWiregen(session) { wiregen.importDetections(session) .then(createInputSymbolList) .then(wiregen.createWiregenImages) - .then(wireGenResultSvg_grammar) - .then(wireGenResultSvg_hypothesis).then(function() { + //.then(wireGenResultSvg_grammar) + //.then(wireGenResultSvg_hypothesis) + .then(function() { console.log("[startWiregen::finished]"); resolve(session); - }); + }).catch(function(err) { + console.log('blablubb:' + err); + }); }); } @@ -190,7 +194,7 @@ function createInputSymbolList(session) { }); } console.log("imported " + session[category].length + " " + category + " symbols."); - console.log(JSON.stringify(session[category])); + //console.log(JSON.stringify(session[category])); }); session.wiregenPath = path.join(session.workingDir, 'wiregen'); @@ -540,8 +544,123 @@ module.exports = { }).status(200); }); }); - } + }, + evaluateElecdetect: function(req, res, next) + { + var session = prepareSession(req.body.e57master); + var wiregen = new Wiregen(); + prepareWiregen(session); + var symbol_elecdetect = wiregen.importElecdetectSymbols(session); + var symbol_groundtruth = wiregen.importGroundtruthSymbols(session); + + console.log('###################### Elecdetect Evaluation ###############'); + var symbol_statistics = function(m,s) { + console.log('***' + m + '***'); + for (var i in s) { + console.log(i + ":" + s[i].length + " symbols."); + } + }; + symbol_statistics('Elecdetect', symbol_elecdetect); + symbol_statistics('Groundtruth', symbol_groundtruth); + + // compare category GT (groundtruth) vs + // category D (detected) in terms of + // comparison per wall + // - matches (overlapping symbols) + // - false positives (object in D but not in GT) + // - false negatives (object in GT but not in D) + var compare_category = function(GT, D) + { + // build wall index + var wallIndex = function(symbols) + { + var wi = {}; + for (var i = 0, ie = symbols.length; i= 0.9) + { + console.log((area / areaA) + ' => match!'); + match_gt[i_gt] = '1'; + match_d[i_d] = '1'; + } + } + } + } + + // count matches and fals positives/negatives + if (wall_gt[wallid]) + for (var i_gt = 0, i_gte = wall_gt[wallid].length; i_gt < i_gte; ++i_gt) + { + if (match_gt[i_gt] == '1') { result.match += 1; } + else { result.false_negative +=1; } // gt but not detected + } + for (var i_d = 0, i_de = wall_d[wallid].length; i_d < i_de; ++i_d) + { + if (match_d[i_d] != '1') { result.false_positive += 1; } // detection not present in gt + } + + }); + + + return result; + } + + console.log('GT Sockets:' + JSON.stringify(symbol_groundtruth.Sockets)); + console.log('D Sockets:' + JSON.stringify(symbol_elecdetect.Sockets)); + var sockets = compare_category(symbol_groundtruth.Sockets, symbol_elecdetect.Sockets); + console.log(JSON.stringify(sockets)); + var switches = compare_category(symbol_groundtruth.Switches, symbol_elecdetect.Switches); + console.log(JSON.stringify(switches)); + + } }; diff --git a/src/bindings/wiregen/index.js b/src/bindings/wiregen/index.js index e07603b..a441789 100644 --- a/src/bindings/wiregen/index.js +++ b/src/bindings/wiregen/index.js @@ -4,29 +4,19 @@ var spawn = require('child_process').spawn, fs = require('fs'), xml2js = require('xml2js'); -var Wiregen = module.exports = function() { - //this.session = session; -}; - -Wiregen.prototype.importDetections = function(session) { - session.wiregenInput = []; - session.Sockets = []; - session.Switches = []; - - if (session.config.wiregen.roots) { - session.Roots = session.config.wiregen.roots; - } else { - session.Roots = []; - } - - var promises = []; - - if (session.useGroundtruth) +function importGroundtruthSymbols(session) +{ + var symbols = { + 'Sockets' : [], + 'Switches' : [], + 'Roots' : [] + }; + + console.log('[Wiregen::importGroundtruth]'); + + var walljson = JSON.parse(fs.readFileSync(session.wallfile, "utf8")); + for (var i=0; i