private static void Main(String[] args) { var img = new Mat("image.png").ToImage <Bgr, Byte>(); var result = FrameAnalysis.GetAdaptiveThresholdedFrame(img); result.Save("res.png"); }
/// <summary>Analyses the <paramref name="frames" />.</summary> public static FrameAnalysis Analyse(this IEnumerable <IFrame> frames) { var analysis0 = new FrameAnalysis(); foreach (var frameAnalysis in frames.Where(x => x != null).Distinct().Select(x => x.Analyse())) { analysis0.Add(frameAnalysis); } return(analysis0); }
/// <summary>Analyses the <paramref name="frame" />.</summary> public static FrameAnalysis Analyse(this IFrame frame) { var unprocessedFrames = new Queue <IFrame>(); unprocessedFrames.Enqueue(frame); var frameAnalysis = new FrameAnalysis(); void Inner(IFrameItem ele) { if (ele is IFrameText) { frameAnalysis.Texts.Add((IFrameText)ele); } else if (ele is IFrameImage) { frameAnalysis.Images.Add((IFrameImage)ele); } else if (ele is IFrameVideo) { frameAnalysis.Videos.Add((IFrameVideo)ele); } else if (ele is IFrame) { unprocessedFrames.Enqueue((IFrame)ele); } } while (unprocessedFrames.Count != 0) { var fr = unprocessedFrames.Dequeue(); foreach (var child in fr.FrameChildren) { var collectionContainer = child as CollectionContainer; if (collectionContainer != null) { foreach (var o in collectionContainer.Collection) { Inner((IFrameItem)o); } } else { Inner((IFrameItem)child); } } } return(frameAnalysis); }
private static void OutputAsset(FrameAnalysis frameAnalysis, DirectoryInfo folder) { while (ui.GetInfo("a resource hash to dump lifecycle for", out var hex)) { uint hash; try { if (hex.Length != 8) { throw new InvalidDataException(nameof(hex)); } hash = uint.Parse(hex, NumberStyles.HexNumber); } catch { ui.Event($"Invalid hash: {hex} (must be 8 chars, alphanumetic hex)"); continue; } if (!frameAnalysis.Assets.TryGetValue(hash, out var asset)) { ui.Event($"Hash not found: {hex}"); continue; } using var assetFile = folder.File(asset.Hex + CSV.Extension).TryOpenWrite(ui); try { if (assetFile != null) { AssetWriter.Write(asset, assetFile); ui.Event($"Export of {asset.Hex} complete"); continue; } } catch (Exception e) { ui.Event(e.ToString()); } ui.Event($"Export of {asset.Hex} failed:"); } ui.Event("Export Asset aborted"); }
/// <summary> /// This is the method that actually does the work. /// </summary> /// <param name="DA">The DA object is used to retrieve from inputs and store in outputs.</param> protected override void SolveInstance(IGH_DataAccess DA) { StructureEngine.Model.ComputedStructure comp = new StructureEngine.Model.ComputedStructure(); // modify to get in solver to get output structure Types.StructureType structure1 = new Types.StructureType(); if (!DA.GetData(0, ref structure1)) { return; } structure1.CastTo <ComputedStructure>(ref comp); comp = structure1.Value; FrameAnalysis analysis = new FrameAnalysis(); analysis.RunAnalysis(comp); Types.StructureType Structure_GHrep = new Types.StructureType(comp); /*Assign the outputs via the DA object*/ DA.SetData(0, Structure_GHrep); }