public static void Input() { VideoCapture cap = null; var dic = new Dictionary <FrameInfo, PrintEffectBase>(); Camera cam = null; string msg = "Enter the command..."; while (true) { string[] cmd = Inline(msg, true).Split(" "); msg = null; if (cmd[0] == "exit") { break; } else if (cmd[0] == "load") { if (!File.Exists(cmd[1])) { Log.Error("The file is not found."); continue; } cap = new VideoCapture(cmd[1]); Log.Info("Loading OK."); } else if (cmd[0] == "unload") { cap.Dispose(); Log.Info("Unloading completed."); } else if (cmd[0] == "effect") { if (cmd[1] == "flip") { var fi = new FrameInfo(uint.Parse(cmd[3], SystemLang), uint.Parse(cmd[4], SystemLang)); if (cmd[2] == "X") { dic.Add(fi, PrintEffect.FLIP(FlipMode.X)); } } } else if (cmd[0] == "output") { Movie.OutputMovie(cmd[1], ".avi", VideoWriter.FourCC('J', 'P', 'E', 'G'), cap, dic); } else if (cmd[0] == "cam") { if (cam == null) { cam = new Camera(); } if (cmd[1] == "open") { cam.Open(); } else if (cmd[1] == "show" && !cam.IsShow) { Task.Run(() => { cam.Show(); }); } else if (cmd[1] == "close") { cam.Close(); } else { continue; } Log.Info("Camera " + cmd[1]); } else if (cmd[0] == "show") { if (cap != null) { Task.Run(() => { Show(cap); }); } } else { Log.Warn("Illegual command : " + cmd[0]); } } cap.Dispose(); cam.Dispose(); }
public IActionResult PostComponent(JsonElement obj) { if (!ServerData.IsAccessable(HttpContext.Connection.RemoteIpAddress)) { return(Forbid()); } var json = JObject.Parse(obj.GetRawText()); var id = json["uuid"].Value <string>(); if (!ServerData.ProjectList.ContainsKey(id)) { return(NotFound()); } var project = ServerData.ProjectList[id]; foreach (var comp in json["components"].Children <JProperty>()) { var c = comp.Value.ToObject <JObject>(); var cid = comp.Name; var def = false; TimelinePrintObject tpo = null; List <PrintEffectBase> list = new(); foreach (var block in c["blocks"].Children <JProperty>()) { var b = block.Value.ToObject <ComponentBlockBase>(); if (b.Kind == "DefineComponentBlock") { if (def) { return(BadRequest()); } def = true; continue; } if (!def) { return(BadRequest()); } if (b.Kind == "MovieLoadingBlock") { var mlb = block.Value.ToObject <MovieLoadingBlock>(); tpo = new TimelineMovie(new(0, 0), mlb.MaterialPath, project.OutputSize); } else if (b.Kind == "GrayScaleFilterBlock") { list.Add(PrintEffect.COLORCONVERT(OpenCvSharp.ColorConversionCodes.GRAY2BGR)); } } var tc = new TimelineComponent(new(0, 0), project.OutputSize, list.ToArray(), tpo); project.Timeline.RegistComponent(comp.Name, tc); } foreach (var clip in json["clips"].Children <JProperty>()) { var c = clip.Value; project.Timeline.AddObject(c["layer"].Value <ushort>(), new(c["frame"]["begin"].Value <uint>(), c["frame"]["end"].Value <uint>()), project.Timeline.ComponentList[c["componentUuid"].Value <string>()]); } return(Ok()); }