private bool InitDev() { if (Global.dllEncoder == "utf8") { SPlate.SP_SetCodeType(1); } else { SPlate.SP_SetCodeType(2); } int ret = SPlate.SP_InitNVR(Global.clsNvrInfo.ip, Global.clsNvrInfo.port, Global.clsNvrInfo.loginName, Global.clsNvrInfo.password); Global.LogServer.Add(new LogInfo("Debug", "Main->InitDev->SP_InitNVR 初始化设备完成,返回值:" + ret.ToString(), (int)EnumLogLevel.DEBUG)); if (ret == 0) { if (Global.nCaptureFlag == 1) { SetNozzleParamToDll(); } if (Global.nVideoRecogFlag == 1) { SetVideoChanParamToDll(); } return(true); } else { return(false); } }
private void SetNozzleParamToDll() { int structLenth = Marshal.SizeOf(typeof(struNozzleRecog)); struNozzleRecog[] nozzleRecog = new struNozzleRecog[Global.nozzleList.Count]; byte[] ipp = new byte[10000]; int offset = 0; for (int i = 0; i < Global.nozzleList.Count; i++) { nozzleRecog[i].nozzleNo = Global.nozzleList[i].nozzleNo; nozzleRecog[i].areas = new struArea[8]; nozzleRecog[i].areaCount = Global.nozzleList[i].linkedMainAreaList.Count; for (int j = 0; j < nozzleRecog[i].areaCount; j++) { if (Global.areaMap.ContainsKey(Global.nozzleList[i].linkedMainAreaList[j])) { int index = Global.areaMap[Global.nozzleList[i].linkedMainAreaList[j]]; nozzleRecog[i].videoChan = Global.areaList[index].videoChannel; nozzleRecog[i].areas[j].areaNo = Global.areaList[index].id; nozzleRecog[i].areas[j].left = (int)(Global.areaList[index].left * Global.nDefaultWidth); nozzleRecog[i].areas[j].right = (int)(Global.areaList[index].right * Global.nDefaultWidth); nozzleRecog[i].areas[j].top = (int)(Global.areaList[index].top * Global.nDefaultHeight); nozzleRecog[i].areas[j].bottom = (int)(Global.areaList[index].bottom * Global.nDefaultHeight); nozzleRecog[i].areas[j].videoLaneNo = Global.areaList[index].videoLaneNo; } // foreach (ClsRecogArea area in Global.areaList) // { // if (Global.nozzleList[i].linkedMainAreaList[j] == area.id) // { // nozzleRecog[i].videoChan = area.videoChannel; // nozzleRecog[i].areas[j].areaNo = area.id; // nozzleRecog[i].areas[j].left = (int)(area.left * Global.nDefaultWidth); // nozzleRecog[i].areas[j].right = (int)(area.right * Global.nDefaultWidth); // nozzleRecog[i].areas[j].top = (int)(area.top * Global.nDefaultHeight); // nozzleRecog[i].areas[j].bottom = (int)(area.bottom * Global.nDefaultHeight); // nozzleRecog[i].areas[j].videoLaneNo = area.videoLaneNo; // } // } } byte[] bNozzle = SystemUnit.StrutsToBytesArray(nozzleRecog[i]); Buffer.BlockCopy(bNozzle, 0, ipp, offset, structLenth); offset += structLenth; } SPlate.SP_InitRunParam_Nozzle(ipp, Global.nozzleList.Count); Global.LogServer.Add(new LogInfo("Debug", "Main->InitDev->SetNozzleParamToDll 油枪参数传入动态库完成,油枪数:" + Global.nozzleList.Count.ToString(), (int)EnumLogLevel.DEBUG)); }
private void FormMain_Load(object sender, EventArgs e) { //TODO 临时关闭保护线程 startProtectProcess();//启动保护进程 lastMessageTime = DateTime.Now; int ret = Init(); if (Global.bUseCacheCar) { Global.listCarArrive = new List <ClsCarArrive>(); timerClearCarlist.Enabled = true; } InitFormInfo(); if (ret == 0) { SPlate.SP_BeginRecog(); ShowNozzleCarList(); ShowAreaCarList(); return; } if ((ret & 0x01) == 0x01) { MessageBox.Show("日志启动失败"); } if ((ret & 0x02) == 0x02) { MessageBox.Show("数据库连接失败"); } if ((ret & 0x04) == 0x04) { MessageBox.Show("参数初始化失败"); } if ((ret & 0x08) == 0x08) { MessageBox.Show("算法初始化失败"); } if ((ret & 0x10) == 0x10) { MessageBox.Show("设备初始化失败"); } if ((ret & 0x20) == 0x20) { MessageBox.Show("网络服务初始化失败"); } }
private void FormMain_Load(object sender, EventArgs e) { startProtectProcess();//启动保护进程 lastMessageTime = DateTime.Now; int ret = Init(); InitFormInfo(); if (ret == 0) { SPlate.SP_BeginRecog(); ShowNozzleCarList(); ShowAreaCarList(); return; } if ((ret & 0x01) == 0x01) { MessageBox.Show("日志启动失败"); } if ((ret & 0x02) == 0x02) { MessageBox.Show("数据库连接失败"); } if ((ret & 0x04) == 0x04) { MessageBox.Show("参数初始化失败"); } if ((ret & 0x08) == 0x08) { MessageBox.Show("算法初始化失败"); } if ((ret & 0x10) == 0x10) { MessageBox.Show("设备初始化失败"); } if ((ret & 0x20) == 0x20) { MessageBox.Show("网络服务初始化失败"); } }
private bool InitAlg() { Global.LogServer.Add(new LogInfo("Debug", "main->SP_InitAlg 识别算法初始化开始", (int)EnumLogLevel.DEBUG)); TH_PlateIDCfg th_PlateIDCfg = new TH_PlateIDCfg(); th_PlateIDCfg.nMaxPlateWidth = 400; th_PlateIDCfg.nMinPlateWidth = 60; th_PlateIDCfg.nMaxImageWidth = 2000; th_PlateIDCfg.nMaxImageHeight = 1100; th_PlateIDCfg.nFastMemorySize = 16000; //DSP内存大小 th_PlateIDCfg.pFastMemory = Marshal.AllocHGlobal(16000); //DSP申请内存 th_PlateIDCfg.pMemory = Marshal.AllocHGlobal(100000000); //申请普通内存 th_PlateIDCfg.nMemorySize = 100000000; th_PlateIDCfg.bUTF8 = 0; th_PlateIDCfg.bShadow = 1; th_PlateIDCfg.bCarLogo = 0; th_PlateIDCfg.bLeanCorrection = 1; th_PlateIDCfg.bCarModel = 0; //TODO 注意模式切换 th_PlateIDCfg.bOutputSingleFrame = 1; th_PlateIDCfg.bMovingImage = 0; //0 识别静止图片,1识别动态视频(结果输出延时) int lenth = Marshal.SizeOf(th_PlateIDCfg); int ret = SPlate.SP_InitAlg(ref th_PlateIDCfg, lenth); Global.LogServer.Add(new LogInfo("Debug", "main->SP_InitAlg 识别算法初始化完成,返回值:" + ret.ToString(), (int)EnumLogLevel.DEBUG)); if (ret == 0) { return(true); } else { return(false); } }
private void SetVideoChanParamToDll() { int structLenth = Marshal.SizeOf(typeof(struVideoChan)); //IntPtr ip = Marshal.AllocHGlobal(Global.nozzleList.Count* structLenth); struVideoChan[] videoChan = new struVideoChan[Global.videoChanList.Count]; byte[] ipp = new byte[10000]; int offset = 0; for (int i = 0; i < Global.videoChanList.Count; i++) { videoChan[i].chanNo = Global.videoChanList[i].channelNo; videoChan[i].areaCount = Global.videoChanList[i].areaNoList.Count; videoChan[i].videoType = Global.videoChanList[i].videoType; videoChan[i].areas = new struArea[8]; for (int j = 0; j < videoChan[i].areaCount; j++) { if (Global.areaMap.ContainsKey(Global.videoChanList[i].areaNoList[j])) { int index = Global.areaMap[Global.videoChanList[i].areaNoList[j]]; videoChan[i].areas[j].areaNo = Global.areaList[index].id; videoChan[i].areas[j].left = (int)(Global.areaList[index].left * Global.nDefaultWidth); videoChan[i].areas[j].right = (int)(Global.areaList[index].right * Global.nDefaultWidth); videoChan[i].areas[j].top = (int)(Global.areaList[index].top * Global.nDefaultHeight); videoChan[i].areas[j].bottom = (int)(Global.areaList[index].bottom * Global.nDefaultHeight); videoChan[i].areas[j].videoChanNo = videoChan[i].chanNo; videoChan[i].areas[j].videoLaneNo = Global.areaList[index].videoLaneNo; } } byte[] byVideo = SystemUnit.StrutsToBytesArray(videoChan[i]); Buffer.BlockCopy(byVideo, 0, ipp, offset, structLenth); offset += structLenth; } SPlate.SP_InitRunParam_Video(ipp, Global.videoChanList.Count); Global.LogServer.Add(new LogInfo("Debug", "Main->InitDev->SetVideoParamToDll 视频通道参数传入动态库完成,油枪数:" + Global.videoChanList.Count.ToString(), (int)EnumLogLevel.DEBUG)); }
private void btnSwitch_Click(object sender, EventArgs e) { SPlate.SP_TestAPI(); }
private void btnChangeLogLevel_Click(object sender, EventArgs e) { Global.nLogLevel = comboLogLevel.SelectedIndex + 1; SPlate.SP_SetLogLevel(comboLogLevel.SelectedIndex + 1); }