private void ShowAllVariables() { ShowData GetTask = new ShowData(); //数据缓存队列 while (true) { //接收数据 TaskSemaphore1.WaitOne(); //等待接收队列 lock (ThreadLock1) //锁线程 { GetTask = ShowQueue.Dequeue(); } if (GetTask.ThzImage != null) { if (!Directory.Exists("ZHEN")) { Directory.CreateDirectory("ZHEN"); } } if (ShowEvent != null && GetTask.ThzImage != null) { ShowEvent(GetTask.ThzImage, GetTask.Duration, GetTask.Temparture, GetTask.IsPeople, GetTask.IsHidden); } } }
/// <summary> /// 数据解码图像处理 /// </summary> private void DataDecodeImageProcessThread() { try { List <Byte[]> GetTask = new List <Byte[]>(); //数据缓存队列 List <Byte[]> listBuff = new List <Byte[]>(); //多余数据缓存区 THZData thzdata = new THZData(); //Thz数据 while (true) { //接收数据 TaskSemaphore.WaitOne(); //等待接收队列 lock (ThreadLock) //锁线程 { GetTask = DataQueue.Dequeue(); //Queue<List<Byte[]>> DataQueue = new Queue<List<Byte[]>>(); } string[] duration = new string[3] { "", "", "" }; elapsetime.Restart();//计时开始 //数据解析解码 //DataDecode(GetTask, ref listBuff, ref thzdata); DataDecode_v1(GetTask, ref listBuff, ref thzdata); //Console.WriteLine("123"); MainForm f1 = new MainForm(); f1.ShowThread(); elapsetime.Stop();//计时结束 duration[0] = elapsetime.ElapsedMilliseconds.ToString("000"); //背景校准 //if (getMeanMatFlag) //{ // if (frame.UserData != null) // MeanMatList.Add(frame); // if (MeanMatList.Count == 10) // { // MeanMat = getMeanMat(MeanMatList); // MeanMatList.Clear(); // getMeanMatFlag = false; // } // ImageClass.MeanMat = MeanMat; //} elapsetime.Restart();//计时开始 thzdata.StartImageProcess(); if (thzdata.FilterImage != null) ///FilterImage滤波后图像 { if (!Directory.Exists("ZHEN")) { Directory.CreateDirectory("ZHEN"); } thzdata.FilterImage.Mat.Bitmap.Save("ZHEN\\" + DateTime.Now.ToString("HHmmssfff") + ".bmp"); } elapsetime.Stop();//计时结束 duration[1] = elapsetime.ElapsedMilliseconds.ToString("0000"); duration[2] = (Convert.ToInt32(duration[0]) + Convert.ToInt32(duration[1])).ToString("0000"); //温度显示 double[] temparture = thzdata.GetTemparture(); if (thzdata.FinalImage != null) { ShowData SD = new ShowData(thzdata.FinalImage.Bitmap, temparture, duration, thzdata.isPeople, thzdata.isHidden);//thzdata.isPeople // 任务队列为临界资源,需要锁 lock (ThreadLock1) { ShowQueue.Enqueue(SD); } // 每添加一个任务,信号量加1 TaskSemaphore1.Release(1); } //if (ShowEvent != null && thzdata.FinalImage != null) // ShowEvent(thzdata.FinalImage.Bitmap, duration, Temparture, thzdata.isPeople); //ShowEvent(PB1Image, ImageClass.lImage, ImageClass.isPeople, elapsetime.ElapsedMilliseconds.ToString(), ImageClass.HideGoods, "错帧数:" + ErrorNum); //ShowTextEvent.Invoke(ImageClass.OutArray.Bitmap); } } catch (Exception ex) { string fileName = "Log\\debug" + localPort + "_DataDecode.txt"; string content = DateTime.Now.ToLocalTime() + ex.Message + "\n" + ex.StackTrace + "\r\n"; Logger(fileName, content); } }