void AI_LoadAllTrainTickets() { TrainTicketsInfoView.Items.Clear(); TrainTicket.TrainTickets_Info.Clear(); TrainTicket.TrainTickets_Image.Clear(); var AllTrainticketimage = TicketImageTool.LoadAllTrainTicketsImage(); foreach (var item in AllTrainticketimage) { TrainTicket.AI_TrainTicket(item); } }
private void TrainTicketsInfoView_SelectedIndexChanged(object sender, EventArgs e) { // MessageBox.Show(TrainTicketsInfoView.SelectedItem.ToString(), "信息", MessageBoxButtons.OK); if (TrainTicketsInfoView.SelectedItem == null) { TrainTicketsInfoView.ClearSelected(); return; } var logid = TrainTicketsInfoView.SelectedItem.ToString(); NowSlectTickets = TrainTicket.GetTrainTicket(logid); text_ticket_num.Text = NowSlectTickets.ticket_num; text_train_num.Text = NowSlectTickets.train_num; text_ticket_rates.Text = NowSlectTickets.ticket_rates; text_starting_station.Text = NowSlectTickets.starting_station; text_destination_station.Text = NowSlectTickets.destination_station; text_ID.Text = NowSlectTickets.ID; text_name.Text = NowSlectTickets.name; text_date.Text = NowSlectTickets.date; text_starttime.Text = NowSlectTickets.train_starttime; text_seat_category.Text = NowSlectTickets.seat_category; text_bottomid.Text = NowSlectTickets.bottomid; text_jianpiao.Text = NowSlectTickets.jianpiao; text_che.Text = NowSlectTickets.train_che; text_hao.Text = NowSlectTickets.train_hao; if (TrainTicket.TrainTickets_Image.ContainsKey(logid)) { var findimage = TrainTicket.GetTrainTicketImage(logid); var trimvalue = 222; if (findimage == null) { MessageBox.Show("由于没有模板文件,车票无法制作成功", "错误", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } TicketPictureBox.Image = TicketImageTool.shrinkTo(findimage, new Size((findimage.Width + trimvalue) / 3, (findimage.Height + trimvalue) / 3), false); } else { UpateTicketPictureBoxImage(TrainTicketsInfoView.SelectedItem.ToString()); } if (Width < OpenWidth) { ISOpen = true; FormOpentimer.Enabled = true; } }
void UpateTicketPictureBoxImage(string number) { var Tickets = TrainTicket.GetTrainTicket(number); if (TrainTicket.TrainTickets_Image.ContainsKey(number)) { TrainTicket.TrainTickets_Image.Remove(number); } TrainTicket.TrainTickets_Image.Add(number, TicketImageTool.MakeTrainTickImage(Tickets)); NowSlectTickets = TrainTicket.GetTrainTicket(number); var findimage = TrainTicket.GetTrainTicketImage(number); var trimvalue = 222; if (findimage == null) { MessageBox.Show("由于没有模板文件,车票无法制作成功", "错误", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } TicketPictureBox.Image = TicketImageTool.shrinkTo(findimage, new Size((findimage.Width + trimvalue) / 3, (findimage.Height + trimvalue) / 3), false); }
private void TrainTicketMainForm_Load(object sender, EventArgs e) { var APP_ID = "16672550"; var API_KEY = "lNls0VC4YjB4LocNTDGB9jn0"; var SECRET_KEY = "OoGRDa7sYsM6qjOwGEDvx7r7mWBLPsG0"; Console.WriteLine(AppDomain.CurrentDomain.BaseDirectory); // PhotoName = Console.ReadLine(); TrainTicket.client = new Baidu.Aip.Ocr.Ocr(API_KEY, SECRET_KEY); TrainTicket.client.Timeout = 60000; // 修改超时时间 Console.WriteLine(TrainTicket.LoudTicketsPath); TrainTicket.InitPeople_ID(); TrainTicket.BaseTicketImage = TicketImageTool.LoadAllBaseTrainTicketsImage(); TrainTicket.OnTrainTicketMaked += UpdateTrainTicketView; TrainTicket.OnTrainTicketError += TrainTicketError; Control.CheckForIllegalCrossThreadCalls = false; _S.Opacity = 0; _S.timer1.Enabled = true; _S.Text = String.Format("AI智能火车票[识别/修改]系统-版本:{0}", Application.ProductVersion); OpenWidth = Width; Width = 350; }