public void ParseData_InvalidDataTooShort_ThrowsException() { byte[] data; data = HelperFunctions.ConvertHex(cDATA_INVALID); OutputParser.Parse(data); }
/// <summary> /// Initializes a new instance of the <see cref="ColorfulConsoleManager"/> class. /// </summary> /// <param name="appName">The application name (to display in console header).</param> public ColorfulConsoleManager(string appName) { _outputParser = new OutputParser(); _outputPrinter = new ColorOutputPrinter(); WriteHeader(appName); }
public void TestParameters() { RootEntry root = OutputParser.parse(@"a|color=#ff0"); Assert.AreEqual(1, root.children.Count); Assert.AreEqual("#ff0", root.children[0].color); }
public void TestTokenizerWithQuotes() { var root = OutputParser.Tokenize("a=b c=d f=\"a a\""); Assert.AreEqual("b", root["a"]); Assert.AreEqual("d", root["c"]); Assert.AreEqual("a a", root["f"]); }
public void TestTokenizerWithSingleQuotes() { var root = OutputParser.Tokenize("a=b f='a a' c=d"); Assert.AreEqual("b", root["a"]); Assert.AreEqual("d", root["c"]); Assert.AreEqual("a a", root["f"]); }
/// <summary> /// Gets bounding boxes/objects from bitmap /// </summary> /// <param name="imageInputData"></param> /// <returns></returns> private List <BoundingBox> GetObjectsFromModel(ImageInputData imageInputData) { var labels = CustomVisionPredictionEngine?.Predict(imageInputData).PredictedLabels ?? TinyYoloPredictionEngine?.Predict(imageInputData).PredictedLabels; var boundingBoxes = OutputParser.ParseOutputs(labels); var filteredBoxes = OutputParser.FilterBoundingBoxes(boundingBoxes, 5, 0.5f); return(filteredBoxes); }
public void ParseStream_EmptyData_ThrowsException() { MemoryStream stream = new MemoryStream { Capacity = 0 }; OutputParser.Parse(stream); }
public void TestSingleLine() { RootEntry root = OutputParser.parse("hello"); Assert.AreEqual(root.children.Count, 1); Assert.AreEqual(root.menu.Count, 0); Assert.AreEqual(root.children[0].text, "hello"); }
public void ParseStream_InvalidDataTooShort_ThrowsException() { byte[] data; MemoryStream stream; data = HelperFunctions.ConvertHex(cDATA_INVALID); stream = new MemoryStream(data); OutputParser.Parse(stream); }
private void GenerateOutputVariables(Results result, Dictionary <string, string> paramMatch, BranchConfiguration branchConfig) { // Handle output variables var gitInfo = new Dictionary <string, string>(); var paramHead = new Dictionary <string, string>(); var paramVS = new Dictionary <string, string>(); gitInfo.Add("BranchName", result.GitInfo.BranchName); gitInfo.Add("ShortBranchName", result.GitInfo.ShortBranchName); gitInfo.Add("Path", result.GitInfo.Path); paramHead.Add("Author", result.GitInfo.LastAuthor); paramHead.Add("Date", result.GitInfo.LastCommitDate.ToString(CultureInfo.InvariantCulture)); paramHead.Add("Sha", result.GitInfo.Head.Sha); paramHead.Add("Message", result.GitInfo.Head.Message); paramHead.Add("MessageShort", result.GitInfo.Head.MessageShort); paramVS.Add("CommitAuthor", result.VersionSource.Commit.Author); paramVS.Add("CommitDateTime", result.VersionSource.Commit.CommitDate.ToString(CultureInfo.InvariantCulture)); paramVS.Add("CommitSha", result.VersionSource.Commit.Sha); paramVS.Add("CommitMessage", result.VersionSource.Commit.Message); paramVS.Add("CommitMessageShort", result.VersionSource.Commit.MessageShort); paramVS.Add("Message", result.VersionSource.Message); paramVS.Add("MessageShort", result.VersionSource.MessageShort); foreach (var output in branchConfig.Output) { var inputStream = new AntlrInputStream(output.Value); var lexer = new OutputLexer(inputStream); var commonTokenStream = new CommonTokenStream(lexer); var parser = new OutputParser(commonTokenStream); parser.RemoveErrorListeners(); parser.AddErrorListener(new OutputErrorListener()); // add ours var visitor = new OutputVisitor(output.Key, output.Value, _paramArgs, gitInfo, paramHead, paramMatch, result.Output, paramVS); var parseOutput = visitor.Visit(parser.start()); result.Output.Add(output.Key, parseOutput); } // Strip away temporary items, unless we are in diagnostic mode var res = new Dictionary <string, string>(); foreach (var output in result.Output) { if (output.Key.StartsWith("~")) { Logger.Debug($"Stripping temporary variable: {output.Key}='{output.Value}'"); continue; } res.Add(output.Key, output.Value); } result.Output = res; }
public void TestTwoLinesInRoot() { RootEntry root = OutputParser.parse(@"hello there"); Assert.AreEqual(root.children.Count, 2); Assert.AreEqual(root.menu.Count, 0); Assert.AreEqual(root.children[0].text, "hello"); Assert.AreEqual(root.children[1].text, "there"); }
public void OutputParserParse() { int errorCount = 0, warningCount = 0; Logger errorLogger = (errorCode, file, lineNumber, message) => errorCount++; Logger warningLogger = (errorCode, file, lineNumber, message) => warningCount++; OutputParser parser = new OutputParser("FxCopTask.xml", errorLogger, warningLogger); Assert.IsFalse(parser.Parse(true, false)); Assert.AreEqual(15, errorCount); Assert.AreEqual(0, warningCount); }
public static void Main() { var assetsRelativePath = @"../../../assets"; var assetsPath = GetAbsolutePath(assetsRelativePath); var modelFilePath = Path.Combine(assetsPath, "Model", "TinyYolo2_model.onnx"); //var modelFilePath = Path.Combine(assetsPath, "Model", "Yolov3.onnx"); //var modelFilePath = Path.Combine(assetsPath, "Model", "model.onnx"); var imagesFolder = Path.Combine(assetsPath, "people"); var outputFolder = Path.Combine(imagesFolder, "output"); // Initialize MLContext var mlContext = new MLContext(); try { // Load Data var images = ImageNetData.ReadFromFile(imagesFolder); var imageDataView = mlContext.Data.LoadFromEnumerable(images); // Create instance of model scorer var modelScorer = new Scorer(imagesFolder, modelFilePath, mlContext); // Use model to score data var probabilities = modelScorer.Score(imageDataView); // Post-process model output var parser = new OutputParser(); var boundingBoxes = probabilities .Select(probability => parser.ParseOutputs(probability)) .Select(boxes => parser.FilterBoundingBoxes(boxes, 5, .5F)) .ToList() ; // Draw bounding boxes for detected objects in each of the images for (var i = 0; i < images.Count(); i++) { var imageFileName = images.ElementAt(i).Label; var detectedObjects = boundingBoxes.ElementAt(i); DrawBoundingBox(imagesFolder, outputFolder, imageFileName, detectedObjects); LogDetectedObjects(imageFileName, detectedObjects); } } catch (Exception ex) { Console.WriteLine(ex.ToString()); } Console.WriteLine("========= End of Process..Hit any Key ========"); Console.ReadLine(); }
public void TestOneContext() { RootEntry root = OutputParser.parse(@"hello --- there"); Assert.AreEqual(root.children.Count, 1); Assert.AreEqual(root.menu.Count, 1); Assert.AreEqual(root.children[0].text, "hello"); Assert.AreEqual(root.menu[0].text, "there"); }
public CommandCenter(ICommandParser _commandParser, ICommandInvoker _commandInvoker) { robots = new List <IRobot>(); Mars = new Mars(); reportComposer = new OutputParser(); commandParser = _commandParser; commandInvoker = _commandInvoker; commandInvoker.SetDimensionMars(Mars); commandInvoker.SetRobots(robots); }
public List <CubicBoundingBox> DetectFromFiles(IEnumerable <string> imagePaths, string path) { IEnumerable <ImageNetData> images = ImageNetData.ReadFromFiles(imagePaths); IDataView imageDataView = mlContext.Data.LoadFromEnumerable(images); var modelScorer = new OnnxModelScorer(path, onnxPath, mlContext); var probabilities = modelScorer.Score(imageDataView); OutputParser outputParser = new OutputParser(probabilities, 13, 5); var boxes = outputParser.BoundingBoxes; return(boxes); }
public void SplitString() { const string value = "9327777777777 Y 10978 001111111111111111 2 "; var bounds = new int[] { 36, 53, 68, 93, 95 }; var actual = OutputParser.Split(value, bounds); Assert.AreEqual(5, actual.Length); Assert.AreEqual("9327777777777", actual[0]); Assert.AreEqual("Y", actual[1]); Assert.AreEqual("10978", actual[2]); Assert.AreEqual("001111111111111111", actual[3]); Assert.AreEqual("2", actual[4]); }
public void TestNested() { RootEntry root = OutputParser.parse(@"a --- b --c ----d"); Assert.AreEqual(root.children.Count, 1); Assert.AreEqual(root.menu.Count, 1); Assert.AreEqual(root.menu[0].children.Count, 1); Assert.AreEqual(root.menu[0].children[0].children.Count, 1); }
private void ModelPredict() { if (CheckImagePath()) { var output = yoloV5Onnx?.Predict(currentPreProcessing.ModelInput); currentParser = new OutputParser(output, currentPreProcessing); OutputSource = currentPreProcessing.outputBitmap.ToBitmapSource(); ViewItems.Clear(); foreach (var info in currentParser.boxesInfo) { ViewItems.Add(info); } } }
internal DisassemblyResult Disassemble(Benchmark benchmark, MonoRuntime mono) { Debug.Assert(mono == null || !RuntimeInformation.IsMono(), "Must never be called for Non-Mono benchmarks"); var monoMethodName = GetMethodName(benchmark.Target); var output = ProcessHelper.RunAndReadOutputLineByLine( mono?.CustomPath ?? "mono", "-v -v -v -v " + $"--compile {monoMethodName} " + (benchmark.Job.Env.Jit == Jit.Llvm ? "--llvm" : "--nollvm") + $" \"{benchmark.Target.Type.GetTypeInfo().Assembly.Location}\""); return(OutputParser.Parse(output, monoMethodName, benchmark.Target.Method.Name)); }
public void TestFull() { RootEntry root = OutputParser.parse(@"a --- b --- c --d ----- --e --f"); Assert.AreEqual(root.children.Count, 1); Assert.AreEqual(3, root.menu.Count); }
public void TestSubmenuSeparator() { RootEntry root = OutputParser.parse(@"hello --- there --b ----- --c"); Assert.AreEqual(root.children.Count, 1); Assert.AreEqual(root.menu.Count, 1); Assert.AreEqual(root.children[0].text, "hello"); Assert.AreEqual(root.menu[0].text, "there"); Assert.AreEqual(root.menu[0].children[0].text, "b"); Assert.AreEqual(root.menu[0].children[1].isSeparator, true); }
public void ParseData_ValidData_IsValid() { byte[] data; Output result; byte[] scriptSig; data = HelperFunctions.ConvertHex(cDATA_VALID); result = OutputParser.Parse(data); Assert.IsNotNull(result); scriptSig = HelperFunctions.ConvertHex(cVALID_SCRIPTSIG); Assert.AreEqual(result.ScriptPubKey.Length, scriptSig.Length); Assert.IsTrue(result.ScriptPubKey.SequenceEqual(scriptSig)); Assert.AreEqual(result.Value, cVALID_VALUE); }
internal DisassemblyResult Disassemble(Benchmark benchmark, MonoRuntime mono) { Debug.Assert(mono == null || !RuntimeInformation.IsMono, "Must never be called for Non-Mono benchmarks"); var benchmarkTarget = benchmark.Target; string fqnMethod = GetMethodName(benchmarkTarget); string exePath = benchmarkTarget.Type.GetTypeInfo().Assembly.Location; var environmentVariables = new Dictionary <string, string> { ["MONO_VERBOSE_METHOD"] = fqnMethod }; string monoPath = mono?.CustomPath ?? "mono"; string arguments = $"--compile {fqnMethod} {exePath}"; var output = ProcessHelper.RunAndReadOutputLineByLine(monoPath, arguments, environmentVariables, includeErros: true); string commandLine = $"{GetEnvironmentVariables(environmentVariables)} {monoPath} {arguments}"; return(OutputParser.Parse(output, benchmarkTarget.Method.Name, commandLine)); }
public void TestNestedDifferentLevels() { RootEntry root = OutputParser.parse(@"a --- b --c ----d ----e ------f ------g --h ----l"); Assert.AreEqual(1, root.children.Count); Assert.AreEqual(1, root.menu.Count); Assert.AreEqual(2, root.menu[0].children.Count); Assert.AreEqual(2, root.menu[0].children[0].children.Count); Assert.AreEqual(2, root.menu[0].children[0].children[1].children.Count); Assert.AreEqual(1, root.menu[0].children[1].children.Count); }
public async Task <List <CubicBoundingBox> > DetectObjectPoseFromImagePixelsAsync(byte[] imagePixels) { List <CubicBoundingBox> boxes = new List <CubicBoundingBox>(); using (var imageTensor = ConvertPixelsByteToTensor(imagePixels, BitmapPixelFormat.Bgra8)) using (var input = new SingelObjectApeModelV8Input() { Image = imageTensor }) using (var output = await model.EvaluateAsync(input).ConfigureAwait(true)) { var shape = output.Grid.Shape; var content = output.Grid.GetAsVectorView().ToArray(); List <float[]> abc = new List <float[]> { content }; using (OutputParser outputParser = new OutputParser(abc, classCount, anchorCount, confThresh)) { foreach (var box in outputParser.BoundingBoxes) { var newBox = new CubicBoundingBox() { Confidence = box.Confidence, Identity = box.Identity }; foreach (var point in box.ControlPoint) { newBox.ControlPoint.Append(point); } boxes.Add(box); } } } return(boxes); }
public static void Run(string[] args) { var assetsRelativePath = @"../../../../Assets"; string assetsPath = GetAbsolutePath(assetsRelativePath); var modelFilePath = Path.Combine(assetsPath, "OnnxModel", "MultiObjectDetectionModel.onnx"); var imagesFolder = Path.Combine(assetsPath, "images"); var outputFolder = Path.Combine(assetsPath, "images", "output"); MLContext mlContext = new MLContext(); IEnumerable <ImageNetData> images = ImageNetData.ReadFromFile(imagesFolder); IDataView imageDataView = mlContext.Data.LoadFromEnumerable(images); var modelScorer = new OnnxModelScorer(imagesFolder, modelFilePath, mlContext); var probabilities = modelScorer.Score(imageDataView); OutputParser outputParser = new OutputParser(probabilities, 13, 5); var boxes = outputParser.BoundingBoxes; DrawBoundingBox(Path.Combine(imagesFolder, "000005.jpg"), null, "fuckoff.jpg", boxes); }
/// <summary>Initializes a new instance of the <see cref="GitCLI"/> class.</summary> /// <param name="provider">Provider of this accessor.</param> public GitCLI(IGitAccessorProvider provider) { Verify.Argument.IsNotNull(provider, "provider"); _provider = provider; _executor = new GitCommandExecutor(this); _commandBuilder = new CommandBuilder(this); _outputParser = new OutputParser(this); _autodetectGitExePath = true; _manualGitExePath = string.Empty; GitProcess.GitExePath = GitExecutablePath; GitCliMethod.Create(out _init, this, CommandBuilder.GetInitCommand); GitCliMethod.Create(out _clone, CommandExecutor, CommandBuilder.GetCloneCommand); GitCliMethod.Create(out _queryConfig, CommandExecutor, CommandBuilder.GetQueryConfigCommand, OutputParser.ParseQueryConfigResults); GitCliMethod.Create(out _queryConfigParameter, CommandExecutor, CommandBuilder.GetQueryConfigParameterCommand, OutputParser.ParseQueryConfigParameterResult); GitCliMethod.Create(out _addConfigValue, CommandExecutor, CommandBuilder.GetAddConfigValueCommand, OutputParser.HandleConfigResults); GitCliMethod.Create(out _setConfigValue, CommandExecutor, CommandBuilder.GetSetConfigValueCommand, OutputParser.HandleConfigResults); GitCliMethod.Create(out _unsetConfigValue, CommandExecutor, CommandBuilder.GetUnsetConfigValueCommand, OutputParser.HandleConfigResults); GitCliMethod.Create(out _renameConfigSection, CommandExecutor, CommandBuilder.GetRenameConfigSectionCommand, OutputParser.HandleConfigResults); GitCliMethod.Create(out _deleteConfigSection, CommandExecutor, CommandBuilder.GetDeleteConfigSectionCommand, OutputParser.HandleConfigResults); }
static void Main(string[] args) { Stopwatch sw = new Stopwatch(); OutputParser parser = new OutputParser(args); Object answer = parser.OutputClass(); if (answer is HelpInfo help) { help.Output(); } sw.Start(); if (answer is ConsoleInOut conInOut) { conInOut.Output(); } if (answer is ConsoleInFileOut conInFilOut) { conInFilOut.Output(); } if (answer is FileInConsoleOut filInConOut) { filInConOut.Output(); } if (answer is FileInOut filInOut) { filInOut.Output(); } sw.Stop(); if (answer is Exception exept) { Console.Write(exept.Message); } if (sw.ElapsedMilliseconds > 0) { Console.Write($"\nпотрачено времени на преобразование данных: {sw.ElapsedMilliseconds} мс."); } }
private async void DetectObjectPoseFromPicFile(StorageFile inputFile) { openedFile = inputFile; var file = inputFile; //var transform = new BitmapTransform() { ScaledWidth = 416, ScaledHeight = 416, InterpolationMode = BitmapInterpolationMode.Fant }; using (var stream = await file.OpenAsync(FileAccessMode.Read)) { BitmapSource bitmapSource = new BitmapImage(); bitmapSource.SetSource(stream); InputImage.Source = bitmapSource; BitmapDecoder decoder = await BitmapDecoder.CreateAsync(stream); using (var imageTensor = await ConvertImageToTensorAsync(decoder).ConfigureAwait(true)) using (var input = new SingelObjectApeModelV8Input() { Image = imageTensor }) using (var output = await model.EvaluateAsync(input).ConfigureAwait(true)) { var shape = output.Grid.Shape; var content = output.Grid.GetAsVectorView().ToArray(); List <float[]> rawOutput = new List <float[]> { content }; using (OutputParser outputParser = new OutputParser(rawOutput, classCount, anchorCount, confThresh)) { var boxes = outputParser.BoundingBoxes; DrawBoxes(stream, boxes); } } } }
public FilterOutputControl() : base() { this._buildIcons = new BuildIcons(); this.ImageList = _buildIcons.Icons; outputParser = new OutputParser(); }
/// <summary> /// Launches the specified executable as a child process, capturing its stdout and parsing its output into /// a display segment set. /// </summary> /// /// <param name="executablePath">The path, including filename, to the executable to launch.</param> /// <param name="arguments">The arguments to pass to the child process.</param> /// <param name="workingPath">The working path to specify for the child process.</param> /// <param name="displaySegmentProcessor">The callback function responsible for processing any display segments parsed from the child process' stdout captures.</param> /// <param name="outputParser">The callback function responsible for parsing the output captured from the child process' stdout stream.</param> /// /// <remarks> /// This call will block until the child process exits. /// </remarks> /// public static void Launch(string executablePath, string arguments, string workingPath, DisplaySegmentProcessor displaySegmentProcessor, OutputParser outputParser) { if (executablePath == null) { throw new ArgumentNullException("executablePath"); } if (displaySegmentProcessor == null) { throw new ArgumentNullException("displaySegmentProcessor"); } if (outputParser == null) { throw new ArgumentNullException("outputParser"); } if (!File.Exists(executablePath)) { throw new ArgumentException("The path does not exist", "executablePath"); } var dataRecieveCompleted = new ManualResetEvent(false); var processStartInfo = new ProcessStartInfo { CreateNoWindow = true, RedirectStandardOutput = true, UseShellExecute = false, ErrorDialog = false, Arguments = arguments, FileName = executablePath, WorkingDirectory = workingPath }; DataReceivedEventHandler dataHandler = (sender, args) => { if ((args == null ) || (args.Data == null)) { dataRecieveCompleted.Set(); return; } var result = outputParser(args.Data); displaySegmentProcessor(result); }; using (var process = new Process()) { try { process.StartInfo = processStartInfo; process.OutputDataReceived += dataHandler; if (process.Start()) { process.BeginOutputReadLine(); process.WaitForExit(); // Because the data recieved can be sent after the process exited, wait // until a null data event happens or a second has passed to return. dataRecieveCompleted.WaitOne(TimeSpan.FromSeconds(1)); } } finally { if (process != null) { process.OutputDataReceived -= dataHandler; } } } }
public FilterOutputControl(): base() { this._buildIcons = new BuildIcons(); this.ImageList = _buildIcons.Icons; outputParser = new OutputParser(); }