static void Main() { var form = new MatchForm(); form.Image = new Image <Bgr, byte>(@"C:\IMAGES\PB\PB742001.jpg"); Application.Run(form); }
public bool Run(string imageFullFileName) { using (Done = new ManualResetEventSlim(false)) { Task.Factory.StartNew((o) => { Tuple <MainFormHelper, string> ev = (Tuple <MainFormHelper, string>)o; try { var form = new MatchForm(); form.Key = ev.Item1.Key; form.Image = new Image <Bgr, byte>(ev.Item2); Application.Run(form); } finally { ev.Item1.Done.Set(); } }, new Tuple <MainFormHelper, string>(this, imageFullFileName), TaskCreationOptions.LongRunning); Done.Wait(); } DomainTable table = new DomainTable(); return(table.GetValue <bool>(Key.ToString(), false)); }
private static void NewCommandFileEvent(object sender, ValueEventArgs <Guid, string> e) { Task.Factory.StartNew((o) => { var r = (ValueEventArgs <Guid, string>)o; FileInfo file = new FileInfo(r.Value2); try { using (var matcher = new TemplateMatcher(file.FullName)) { if (!matcher.MatchTemplate()) { if (!MatchForm.Run(file.FullName)) { AppContext.Default.SaveResult(r.Value1, ""); return; } } if (matcher.MatchTemplate()) { var @out = new DirectoryInfo(Config.OUT_FOLDER); @out.EnsureDirectory(); var imgcc = @out.CombineFileName(string.Concat(file.GetFileNameWithoutExtension(), "_ccimg", file.Extension)); matcher.PixellateHiddenAreasAndSaveUnderArea(imgcc.FullName); var img = @out.CombineFileName(string.Concat(file.GetFileNameWithoutExtension(), "_cc", file.Extension)); matcher.SaveResult(img.FullName); AppContext.Default.SaveResult(r.Value1, imgcc.FullName, img.FullName); } else { throw new ApplicationException("Cannot match template"); } } } catch (Exception ex) { AppContext.Default.FireError(ex); } }, e, TaskCreationOptions.LongRunning); }