public void Apply() { string output_dir = @"C:\Users\ronaldiscool\Documents\GitHub\strabo-command-line\Strabo.CommandLine\data\output\"; Log.SetLogDir(output_dir); Log.SetOutputDir(output_dir); GetMapFromServiceWorker gmfsWoker = new GetMapFromServiceWorker(); gmfsWoker.Apply("12957312", "4852401", "Tianditu_cva", output_dir, "map.png"); }
public void Apply(InputArgs inputArgs, bool processLocalFiles, double top, double left, double bottom, double right) { ExtractTextLayerFromMapWorker _textLayerExtractionWorker = new ExtractTextLayerFromMapWorker(); TextDetectionWorker _textDetectionWorker = new TextDetectionWorker(); TextRecognitionWorker _textRecognitionWorker = new TextRecognitionWorker(); ColorSegmentationWorker _colorSegmentationWorker = new ColorSegmentationWorker(); //set log folders Log.SetLogDir(inputArgs.intermediatePath); Log.SetOutputDir(inputArgs.intermediatePath); Log.WriteLine("************Strabo Starts************"); Log.WriteLine("CommandLineWorker in progress..."); Log.SetStartTime(); //read settings try { StraboParameters.readConfigFile(inputArgs.mapLayerName); } catch (Exception e) { Log.WriteLine("Error reading app.config: " + e.Message); throw; } Log.WriteLine("Strabo release version:" + StraboParameters.straboReleaseVersion); Log.WriteLine("Process map: " + inputArgs.mapLayerName); //set and clear folders SetFolder(inputArgs.intermediatePath); SetFolder(inputArgs.outputPath); if (!inputArgs.intermediatePath.EndsWith("\\")) { inputArgs.intermediatePath = inputArgs.intermediatePath + "\\"; } if (!inputArgs.outputPath.EndsWith("\\")) { inputArgs.outputPath = inputArgs.outputPath + "\\"; } Log.WriteLine("Initialization finished. Folders checked and cleaned."); try { MapServerParameters.BBOXW = inputArgs.bbx.BBW; MapServerParameters.BBOXN = inputArgs.bbx.BBN; MapServerParameters.layer = inputArgs.mapLayerName; MapServerParameters.URLBuilder(); if (!processLocalFiles) { GetMapFromServiceWorker gmfsWoker = new GetMapFromServiceWorker(); gmfsWoker.Apply(inputArgs); } else { File.Copy(inputArgs.outputPath + StraboParameters.sourceMapFileName, inputArgs.intermediatePath + StraboParameters.sourceMapFileName, true); } File.Copy(inputArgs.intermediatePath + StraboParameters.sourceMapFileName, inputArgs.outputPath + StraboParameters.sourceMapFileName, true); } catch (Exception e) { Log.WriteLine("ApplyWMSWorker/ApplyWMTSWorker: " + e.Message); throw; } string color_segmentation_result_fn; if (StraboParameters.numberOfSegmentationColor > 0) { try { Log.WriteLine("ColorSegmentationWorker in progress..."); color_segmentation_result_fn = _colorSegmentationWorker.Apply(inputArgs.intermediatePath, inputArgs.threadNumber); Log.WriteLine("ColorSegmentationWorker finished"); } catch (Exception e) { Log.WriteLine("ColorSegmentationWorker: " + e.Message); throw; } } else { color_segmentation_result_fn = inputArgs.intermediatePath + StraboParameters.sourceMapFileName; } try { Log.WriteLine("TextExtractionWorker in progress..."); _textLayerExtractionWorker.Apply(color_segmentation_result_fn, inputArgs.intermediatePath, inputArgs.threadNumber); Log.WriteLine("ApplyTextExtarionWorker finished"); } catch (Exception e) { Log.WriteLine("ApplyTextExtractionWorker: " + e.Message); throw; } try { Log.WriteLine("TextDetectionWorker in progress..."); _textDetectionWorker.Apply(inputArgs.intermediatePath, 2.5, false, inputArgs.threadNumber); Log.WriteLine("ApllyTextDetection finished"); } catch (Exception e) { Log.WriteLine("ApplyTextDetectionWorker: " + e.Message); throw; } try { Log.WriteLine("TextRecognition in progress..."); _textRecognitionWorker.Apply(inputArgs.intermediatePath, inputArgs.outputPath, inputArgs.outputFileName, top, left, bottom, right); Log.WriteLine("TextRecognitionWorker finished"); } catch (Exception e) { Log.WriteLine("ApplyTextRecognition: " + e.Message); throw; } Log.WriteLine("Execution time: " + Log.GetDurationInSeconds().ToString()); }
public void Apply(InputArgs inputArgs, bool processLocalFiles, double top, double left, double bottom, double right) { ExtractTextLayerFromMapWorker _textLayerExtractionWorker = new ExtractTextLayerFromMapWorker(); TextDetectionWorker _textDetectionWorker = new TextDetectionWorker(); TextRecognitionWorker _textRecognitionWorker = new TextRecognitionWorker(); ColorSegmentationWorker _colorSegmentationWorker = new ColorSegmentationWorker(); //set log folders Log.SetLogDir(inputArgs.intermediatePath); Log.SetOutputDir(inputArgs.intermediatePath); Log.WriteLine("************Strabo Starts************"); Log.WriteLine("CommandLineWorker in progress..."); Log.SetStartTime(); //read settings try { StraboParameters.readConfigFile(inputArgs.mapLayerName); } catch (Exception e) { Log.WriteLine("Error reading app.config: " + e.Message); throw; } Log.WriteLine("Strabo release version:" + StraboParameters.straboReleaseVersion); Log.WriteLine("Process map: " + inputArgs.mapLayerName); //set and clear folders SetFolder(inputArgs.intermediatePath); SetFolder(inputArgs.outputPath); if (!inputArgs.intermediatePath.EndsWith("\\")) inputArgs.intermediatePath = inputArgs.intermediatePath + "\\"; if (!inputArgs.outputPath.EndsWith("\\")) inputArgs.outputPath = inputArgs.outputPath + "\\"; Log.WriteLine("Initialization finished. Folders checked and cleaned."); try { MapServerParameters.BBOXW = inputArgs.bbx.BBW; MapServerParameters.BBOXN = inputArgs.bbx.BBN; MapServerParameters.layer = inputArgs.mapLayerName; MapServerParameters.URLBuilder(); if (!processLocalFiles) { GetMapFromServiceWorker gmfsWoker = new GetMapFromServiceWorker(); gmfsWoker.Apply(inputArgs); } else File.Copy(inputArgs.outputPath + StraboParameters.sourceMapFileName, inputArgs.intermediatePath + StraboParameters.sourceMapFileName, true); File.Copy(inputArgs.intermediatePath+StraboParameters.sourceMapFileName, inputArgs.outputPath+StraboParameters.sourceMapFileName,true); } catch (Exception e) { Log.WriteLine("ApplyWMSWorker/ApplyWMTSWorker: " + e.Message); throw; } string color_segmentation_result_fn; if (StraboParameters.numberOfSegmentationColor > 0) { try { Log.WriteLine("ColorSegmentationWorker in progress..."); color_segmentation_result_fn = _colorSegmentationWorker.Apply(inputArgs.intermediatePath, inputArgs.threadNumber); Log.WriteLine("ColorSegmentationWorker finished"); } catch (Exception e) { Log.WriteLine("ColorSegmentationWorker: " + e.Message); throw; } } else color_segmentation_result_fn = inputArgs.intermediatePath + StraboParameters.sourceMapFileName; try { Log.WriteLine("TextExtractionWorker in progress..."); _textLayerExtractionWorker.Apply(color_segmentation_result_fn, inputArgs.intermediatePath, inputArgs.threadNumber); Log.WriteLine("ApplyTextExtarionWorker finished"); } catch (Exception e) { Log.WriteLine("ApplyTextExtractionWorker: " + e.Message); throw; } try { Log.WriteLine("TextDetectionWorker in progress..."); _textDetectionWorker.Apply(inputArgs.intermediatePath, 2.5, false, inputArgs.threadNumber); Log.WriteLine("ApllyTextDetection finished"); } catch (Exception e) { Log.WriteLine("ApplyTextDetectionWorker: " + e.Message); throw; } try { Log.WriteLine("TextRecognition in progress..."); _textRecognitionWorker.Apply(inputArgs.intermediatePath, inputArgs.outputPath, inputArgs.outputFileName, top, left, bottom, right); Log.WriteLine("TextRecognitionWorker finished"); } catch (Exception e) { Log.WriteLine("ApplyTextRecognition: " + e.Message); throw; } Log.WriteLine("Execution time: " + Log.GetDurationInSeconds().ToString()); }