public void ApplyConfig(IVisionParamConfig visionParamConfig) { if (visionParamConfig == null) { return; } visionParamConfig.VSName = CtrlUtil.GetComboBoxText(comboBox_vs); visionParamConfig.AutoSaveAlarmRecord = checkBox_autoSaveAlarmRecord.Checked; IVisionUserParamConfig visionUseParamConfig = visionParamConfig as IVisionUserParamConfig; if (visionUseParamConfig != null) { visionUseParamConfig.ProcessMode = checkBox_processMode.Checked ? 0 : 1; } IBlobTrackParamConfig blobTrackParamConfig = visionParamConfig as IBlobTrackParamConfig; if (blobTrackParamConfig != null) { blobTrackParamConfig.MinWidth = (int)numericUpDown_minWidth.Value; blobTrackParamConfig.MinHeight = (int)numericUpDown_minHeight.Value; blobTrackParamConfig.MaxWidth = (int)numericUpDown_maxWidth.Value; blobTrackParamConfig.MaxHeight = (int)numericUpDown_maxHeight.Value; blobTrackParamConfig.ProcessorParams = textBox_processorParams.Text; } }
public CBlobTrackerConfig(string name) : base(name) { IBlobTrackParamConfig paramConfig = VisionParamConfig as IBlobTrackParamConfig; paramConfig.GuardAlert = TAlertOpt.Any; paramConfig.ProcessorParams = "0,0,0,1,0,0:100"; }
private void InitUI() { textBox_processorParams.Text = "0,0,0,1,0,0:100"; if (mVisionParamConfig != null) { InitVSList(mVisionParamConfig.SystemContext); comboBox_vs.SelectedItem = mVisionParamConfig.SystemContext.VideoSourceConfigManager.GetConfig(mVisionParamConfig.VSName); checkBox_autoSaveAlarmRecord.Checked = mVisionParamConfig.AutoSaveAlarmRecord; IVisionUserParamConfig visionUseParamConfig = mVisionParamConfig as IVisionUserParamConfig; if (visionUseParamConfig != null) { checkBox_processMode.Checked = (visionUseParamConfig.ProcessMode == 0); } IBlobTrackParamConfig blobTrackParamConfig = mVisionParamConfig as IBlobTrackParamConfig; if (blobTrackParamConfig != null) { numericUpDown_minWidth.Value = blobTrackParamConfig.MinWidth; numericUpDown_minHeight.Value = blobTrackParamConfig.MinHeight; numericUpDown_maxWidth.Value = blobTrackParamConfig.MaxWidth; numericUpDown_maxHeight.Value = blobTrackParamConfig.MaxHeight; if (!blobTrackParamConfig.ProcessorParams.Equals("")) { textBox_processorParams.Text = blobTrackParamConfig.ProcessorParams; } } } else { comboBox_vs.Items.Clear(); checkBox_autoSaveAlarmRecord.Checked = false; checkBox_processMode.Checked = false; numericUpDown_minWidth.Value = 0; numericUpDown_minHeight.Value = 0; numericUpDown_maxWidth.Value = 0; numericUpDown_maxHeight.Value = 0; textBox_processorParams.Text = ""; } }
public void ApplyConfig(IBlobTrackParamConfig blobTrackParamConfig) { if (blobTrackParamConfig != null) { blobTrackParamConfig.ImageWidth = shapeDrawCtrl_alarmarea.ShapeManager.ImageWidth; blobTrackParamConfig.ImageHeight = shapeDrawCtrl_alarmarea.ShapeManager.ImageHeight; Hashtable acTable = new Hashtable(); IAreaConfig[] acs = blobTrackParamConfig.GetAreaConfigs(); if (acs != null) { foreach (IAreaConfig ac in acs) { acTable.Add(ac.Id, ac); } } blobTrackParamConfig.ClearAreaConfig(); IShape[] shapes = shapeDrawCtrl_alarmarea.GetShapes(); if (shapes != null) { IAreaConfig oac, ac; foreach (IGuardArea area in shapes) { if (area != null) { ac = area.GetAreaConfig(); oac = acTable[ac.Id] as IAreaConfig; if (oac != null) { oac.CopyPointsTo(ac); } blobTrackParamConfig.AddAreaConfig(ac); } } } } }
public bool BuildConfiguration(ref Configuration config, IBlobTrackParamConfig paramConfig) { if (paramConfig == null) { paramConfig = this.BlobTrackParamConfig; } unsafe { config.AvailableMinSize = new win32.POINT(); config.AvailableMinSize.x = paramConfig.MinWidth; config.AvailableMinSize.y = paramConfig.MinHeight; config.AvailableMaxSize = new win32.POINT(); config.AvailableMaxSize.x = paramConfig.MaxWidth; config.AvailableMaxSize.y = paramConfig.MaxHeight; config.AvailableMinSpeed = paramConfig.MinSpeed; config.AvailableMaxSpeed = paramConfig.MaxSpeed; config.TimeThreshold = paramConfig.TimeThreshold; config.DensityMinNum = 0; //config.FaceDetectTwoStep = false; //config.FaceDetectForeground = false; config.WanderAlertMinTimes = 0; config.StayAlertMinTimes = 0; config.ProcessMode = paramConfig.ProcessMode; config.GuardAlert = (ushort)paramConfig.GuardAlert; config.GuardAreaCount = paramConfig.AreaCount; if (config.GuardAreaCount > 0) { config.GuardAreas = (GuardArea *)Marshal.AllocHGlobal(config.GuardAreaCount * Marshal.SizeOf(typeof(GuardArea))); IAreaConfig curAreaConfig; win32.POINT[] points; win32.RECT rect; int width = paramConfig.ImageWidth; int height = paramConfig.ImageHeight; float xr = 1.0F; float yr = 1.0F; if (width > 352 || height > 288) { xr = ((float)352 / (float)width); yr = ((float)288 / (float)height); } IAreaConfig[] arrarList = paramConfig.GetAreaConfigs(); for (int i = 0; i < config.GuardAreaCount; i++) { curAreaConfig = arrarList[i]; config.GuardAreas[i].index = curAreaConfig.Index; config.GuardAreas[i].type = (int)curAreaConfig.AreaType; config.GuardAreas[i].level = (int)curAreaConfig.GuardLevel; config.GuardAreas[i].opt = curAreaConfig.AlertOpt; config.GuardAreas[i].sensitivity = curAreaConfig.Sensitivity; //config.GuardAreas[i].param = curAreaConfig.AlertParam; config.GuardAreas[i].wanderCount = curAreaConfig.WanderCount; config.GuardAreas[i].stayTime = curAreaConfig.StayTime; config.GuardAreas[i].assembleCount = curAreaConfig.AssembleCount; config.GuardAreas[i].interval = curAreaConfig.AlertInterval; config.GuardAreas[i].count = curAreaConfig.Count; if (curAreaConfig.Count > 0) { config.GuardAreas[i].points = (win32.POINT *)Marshal.AllocHGlobal(curAreaConfig.Count * Marshal.SizeOf(typeof(win32.POINT))); points = curAreaConfig.GetPoints(); for (int j = 0; j < points.Length; j++) { if (width <= 352 && height <= 288) { config.GuardAreas[i].points[j].x = points[j].x; config.GuardAreas[i].points[j].y = height - points[j].y; } else { config.GuardAreas[i].points[j].x = (int)(xr * (float)points[j].x); config.GuardAreas[i].points[j].y = (int)(yr * (float)(height - points[j].y)); } } } rect = curAreaConfig.Rect; if (width <= 352 && height <= 288) { rect.top = height - rect.top; rect.bottom = height - rect.bottom; } else { rect.top = (int)(yr * (float)(height - rect.top)); rect.bottom = (int)(yr * (float)(height - rect.bottom)); rect.left = (int)(xr * (float)rect.left); rect.right = (int)(xr * (float)rect.right); } config.GuardAreas[i].r = rect; config.GuardAreas[i].minsize = curAreaConfig.MinSize; config.GuardAreas[i].maxsize = curAreaConfig.MaxSize; } } config.DepthAreaCount = paramConfig.DepthAreaCount; if (config.DepthAreaCount > 0) { config.DepthAreas = (DepthArea *)Marshal.AllocHGlobal(config.DepthAreaCount * Marshal.SizeOf(typeof(DepthArea))); IDepthAreaConfig curDepthAreaConfig; IDepthAreaConfig[] depthAreaList = paramConfig.GetDepthAreaConfigs(); for (int i = 0; i < config.DepthAreaCount; i++) { curDepthAreaConfig = depthAreaList[i]; config.DepthAreas[i].x1 = curDepthAreaConfig.X1; config.DepthAreas[i].y1 = curDepthAreaConfig.Y1; config.DepthAreas[i].x2 = curDepthAreaConfig.X2; config.DepthAreas[i].y2 = curDepthAreaConfig.Y2; config.DepthAreas[i].height = curDepthAreaConfig.Height; config.DepthAreas[i].width = curDepthAreaConfig.Width; config.DepthAreas[i].IsDepth = curDepthAreaConfig.IsDepth ? 1 : 0; } } } return(true); }
private static void BuildAreaConfig(IBlobTrackParamConfig config, XmlNode xNode) { IAreaConfig areaConfig = null; foreach (XmlNode xSubNode in xNode.ChildNodes) { if (xSubNode.Name.Equals("Index")) { if (xSubNode.FirstChild != null && xSubNode.FirstChild.Value != null && !xSubNode.FirstChild.Value.Equals("")) { areaConfig = config.AddAreaConfig(Convert.ToInt32(xSubNode.FirstChild.Value)); } break; } } if (areaConfig == null) { areaConfig = config.AddAreaConfig(); } if (areaConfig != null) { foreach (XmlNode xSubNode in xNode.ChildNodes) { if (xSubNode.FirstChild != null) { if (xSubNode.Name.Equals("Index")) { areaConfig.Index = Convert.ToInt32(xSubNode.FirstChild.Value); } else if (xSubNode.Name.Equals("Desc")) { areaConfig.Desc = xSubNode.FirstChild.Value; } else if (xSubNode.Name.Equals("Type")) { areaConfig.AreaType = (TAreaType)Convert.ToInt32(xSubNode.FirstChild.Value); } else if (xSubNode.Name.Equals("Level")) { areaConfig.GuardLevel = (TGuardLevel)Convert.ToInt32(xSubNode.FirstChild.Value); } else if (xSubNode.Name.Equals("AlertOpt")) { areaConfig.AlertOpt = Convert.ToUInt16(xSubNode.FirstChild.Value); } else if (xSubNode.Name.Equals("Sensitivity")) { areaConfig.Sensitivity = Convert.ToUInt16(xSubNode.FirstChild.Value); } //else if (xSubNode.Name.Equals("AlertParam")) // areaConfig.AlertParam = Convert.ToInt32(xSubNode.FirstChild.Value); else if (xSubNode.Name.Equals("WanderCount")) { areaConfig.WanderCount = Convert.ToInt32(xSubNode.FirstChild.Value); } else if (xSubNode.Name.Equals("StayTime")) { areaConfig.StayTime = Convert.ToInt32(xSubNode.FirstChild.Value); } else if (xSubNode.Name.Equals("AssembleCount")) { areaConfig.AssembleCount = Convert.ToInt32(xSubNode.FirstChild.Value); } else if (xSubNode.Name.Equals("AlertInterval")) { areaConfig.AlertInterval = Convert.ToInt32(xSubNode.FirstChild.Value); } else if (xSubNode.Name.Equals("PointList")) { string[] data; foreach (XmlNode xPointNode in xSubNode.ChildNodes) { if (xPointNode.Name.Equals("Point") && xPointNode.FirstChild != null && xPointNode.FirstChild.Value != null) { data = xPointNode.FirstChild.Value.Split(','); if (data != null && data.Length == 2) { areaConfig.AddPoint(Convert.ToInt32(data[0]), Convert.ToInt32(data[1])); } } } } else if (xSubNode.Name.Equals("Rect")) { if (xSubNode.FirstChild.Value != null && !xSubNode.FirstChild.Value.Equals("")) { string[] data = xSubNode.FirstChild.Value.Split(','); if (data != null && data.Length == 4) { areaConfig.SetRect(Convert.ToInt32(data[0]), Convert.ToInt32(data[1]), Convert.ToInt32(data[2]), Convert.ToInt32(data[3])); } } } else if (xSubNode.Name.Equals("MinSize")) { if (xSubNode.FirstChild.Value != null && !xSubNode.FirstChild.Value.Equals("")) { string[] data = xSubNode.FirstChild.Value.Split(','); if (data != null && data.Length == 2) { areaConfig.SetMinSize(Convert.ToInt32(data[0]), Convert.ToInt32(data[1])); } } } else if (xSubNode.Name.Equals("MaxSize")) { if (xSubNode.FirstChild.Value != null && !xSubNode.FirstChild.Value.Equals("")) { string[] data = xSubNode.FirstChild.Value.Split(','); if (data != null && data.Length == 2) { areaConfig.SetMaxSize(Convert.ToInt32(data[0]), Convert.ToInt32(data[1])); } } } } } } }