/// <summary> /// 识别 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btn_ToDistinguish_Click(object sender, EventArgs e) { if (cb_Side.Checked)//反面 { if (string.IsNullOrWhiteSpace(pb_SidePic.ImageLocation)) { AttrMessage.ErrorMsg("请上传需要识别的反面身份证图片!"); } else { Distinguish(pb_SidePic.ImageLocation, "back", false, "true"); } } if (cb_Positive.Checked)//正面 { if (string.IsNullOrWhiteSpace(pb_PositivePic.ImageLocation)) { AttrMessage.ErrorMsg("请上传需要识别的正面身份证图片!"); } else { Distinguish(pb_PositivePic.ImageLocation, "front", false, "true"); } } }
private void btn_Start_Click(object sender, EventArgs e) { if (string.IsNullOrWhiteSpace(pic_CarId.ImageLocation)) { AttrMessage.ErrorMsg("请上传图片!"); } else { var result = OcrAPI.GetPlateLicense(pic_CarId.Image); if (result.state) { tb_result.Text = result.contextModel.ToJson(); } else { tb_result.Text = result.errorMsg; } } string verificationMsg = ""; //errorMsg = ""; //var verifyResult = ImageVerification.VerificationImage<IDCardRecognitionModel>(imagePath, System.Drawing.Imaging.ImageFormat.Jpeg, tempModel, out verificationMsg, out strbaser64); //if (!verifyResult.state) //{ // return verifyResult; //} }
/// <summary> /// 识别操作 /// </summary> /// <param name="filePath"></param> /// <param name="id_card_side">身份证 正面还是背面</param> /// <param name="detect_direction"></param> /// <param name="detect_risk"></param> public void Distinguish(string filePath, string id_card_side = "front", bool detect_direction = false, string detect_risk = "false") { DoTime();//主线程执行进度条,子线程进行数据请求操作 t1 = new Thread(new ThreadStart(() => { var temp = BaiduAIAPI.Access_Token.GetAccessToken(); if (temp.IsSuccess) { string data = ""; string error = ""; var result = IDCardRecognition.GetIdcardRecognitionString(temp.SuccessModel.access_token, filePath, ref data, out error, id_card_side, detect_direction, detect_risk); this.Invoke(new Action(() => { tb_showInfo.AppendText("\r\n -----------------------------------------------------------------"); })); if (result.state) { this.Invoke(new Action(() => { tb_showInfo.AppendText("\r\n ---------------------------识别成功-------------------------------"); tb_showInfo.AppendText("\r\n" + result.successModel.ToJson() + "\r\n"); })); } else { this.Invoke(new Action(() => { tb_showInfo.AppendText("\r\n-----------------------------识别失败!--------------------------------"); tb_showInfo.AppendText("\r\n" + result.successModel.ToJson() + result.errorMsg + "\r\n"); })); } } else { this.Invoke(new Action(() => { AttrMessage.ErrorMsg(temp.ErrorModel.error); })); } this.Invoke(new Action(() => { progressBar_ToReadDistinguish.Value = 100; timer1.Enabled = false; progressBar_ToReadDistinguish.Value = 0; })); })); t1.IsBackground = true; t1.Start(); }
private void btn_Stop_Click(object sender, EventArgs e) { string error = ""; bool result = QF.QZServiceRpository.StopAllQuartzServer(out error); if (result) { AttrMessage.RightMsg("所有服务停止成功!"); } else { AttrMessage.ErrorMsg("所有服务停止失败!"); } BingCbb_List(); BingDGV_List(); }
private void btn_ReStart_Click(object sender, EventArgs e) { string temp = cbb_ServiceList.SelectedValue.ToString(); ShowModel showModel = CacheList.Where(x => x.JobKeyName == temp).FirstOrDefault(); bool result = QF.QZServiceRpository.ResumeQuartzServer(showModel.JobsTrigger.JobKey); if (result) { AttrMessage.RightMsg("服务" + temp + "恢复成功!"); } else { AttrMessage.ErrorMsg("服务" + temp + "恢复失败!"); } BingCbb_List(); BingDGV_List(); }
private void Btn_InputPlugin_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(tb_path.Text)) { AttrMessage.ErrorMsg("请选择要导入的插件文件!"); return; } string error = ""; bool result = QF.QZServiceRpository.AddQZServerDLL(tb_path.Text.ToString(), out error); if (result) { BingCbb_List(); BingDGV_List(); AttrMessage.RightMsg("服务加载成功!"); } else { AttrMessage.ErrorMsg("插件加载失败"); } }
public void UploadPic(PictureBox picbox) { try { string startPath = "C:\\"; string fileType = "图片|*.jpg;*.png;*.bmp;"; string filePath = DialogHelper.OpenDialog(openFileDialog1, startPath, fileType); if (string.IsNullOrWhiteSpace(filePath)) { AttrMessage.ErrorMsg("请上传图片!"); } else { string saveDir = System.Environment.CurrentDirectory + "\\Pic\\"; FileHelper.CreateDir(saveDir); string savePath = saveDir + System.IO.Path.GetFileNameWithoutExtension(filePath) + DateTime.Now.ToString("yyyyMMdd") + System.IO.Path.GetExtension(filePath); if (!File.Exists(savePath)) { File.Copy(filePath, savePath); } if (File.Exists(savePath)) { picbox.ImageLocation = savePath; picPath = savePath; } } } catch (Exception ex) { AttrMessage.ErrorMsg(ex.Message); } }