void 手动拍照(object LockWatingThread) { SerialFunc.SerialCommand3(rxNeed, ls); while (true) { WFNetLib.WFGlobal.WaitMS(1); if (waitProc.HasBeenCancelled()) { break; } else { waitProc.SetProcessBar(rxFrame); } if (rxFrame == rxNeed) { break; } } for (int i = 0; i < rxNeed; i++) { byte[] yByteArray = wfSapGUI.ReadPicDatas(m_Buffers, i); SystemParam.CreateBINFile(yByteArray, saveFileFolder + "//" + toolStripTextBox2.Text + "(" + (i + 1).ToString() + ")" + ".bin"); // SystemParam.WriteTempFile(yByteArray, i * FPN_Len + j - 1, FPNFile_Path + "TempData\\Light\\" + (k + 1).ToString() + "bin"); } }
void NopCam(ushort count, uint ls) { while (true) { SerialFunc.SerialCommand3(count, ls); if (WaitCam(count)) { break; } } WFGlobal.WaitMS(200); }
void 手动拍照(object LockWatingThread) { SerialFunc.SerialCommand3(rxNeed, ls); while (true) { WFNetLib.WFGlobal.WaitMS(1); if (waitProc.HasBeenCancelled()) { break; } else { waitProc.SetProcessBar(rxFrame); } if (rxFrame == rxNeed) { break; } } }
void 第二步明场采集(object LockWatingThread) { byte[] yByteArray; rxFrame = 0; uint ls = SystemParam.eStart + (uint)Calc1.Saturated50Index * SystemParam.eStep; Calc2.y50 = new double[m_Buffers.Height, m_Buffers.Width]; int nCount = SystemParam.L / SystemParam.Step2_len; this.Invoke((EventHandler)(delegate { textBox1.AppendText("开始50%曝光明场采集\r\n"); })); //NopCam((ushort)(SystemParam.Step2_len + 1), ls); // waitProc.SetProcessBar(SystemParam.Step2_len); int saveindex = 0; for (int i = 0; i < nCount; i++) { if (waitProc.HasBeenCancelled()) { return; } SerialFunc.SerialCommand3((ushort)(SystemParam.Step2_len + CamEx), ls); if (!WaitCam(SystemParam.Step2_len + CamEx)) { i--; continue; } for (int j = 0; j < SystemParam.Step2_len; j++) { saveindex++; m_Buffers.Save(Calc2.TempPicPath_Light + saveindex.ToString() + ".bmp", "-format bmp", j + CamEx, 0); Thread.Sleep(SystemParam.PicDelay); } for (int j = 0; j < SystemParam.Step2_len; j++) { yByteArray = wfSapGUI.ReadPicDatas(m_Buffers, j + CamEx); SystemParam.WriteTempFile(yByteArray, i * SystemParam.Step2_len + j, Calc2.LightTempFile); } this.Invoke((EventHandler)(delegate { listView1.Items[12].SubItems[1].Text = (((double)(i + 1) * SystemParam.Step2_len) * 100 / SystemParam.L).ToString("F1") + "%"; })); waitProc.SetProcessBar((int)((i + 1) * SystemParam.Step2_len)); } if (nCount * SystemParam.Step2_len < SystemParam.L)//还有一个 { while (true) { int left = SystemParam.L - nCount * SystemParam.Step2_len; rxFrame = 0; SerialFunc.SerialCommand3((ushort)(SystemParam.Step2_len + CamEx), ls); if (!WaitCam(SystemParam.Step2_len + CamEx)) { continue; } for (int j = 0; j < SystemParam.Step2_len; j++) { saveindex++; m_Buffers.Save(Calc2.TempPicPath_Light + saveindex.ToString() + ".bmp", "-format bmp", j + CamEx, 0); Thread.Sleep(SystemParam.PicDelay); } for (int j = 0; j < left; j++) { yByteArray = wfSapGUI.ReadPicDatas(m_Buffers, j + CamEx); SystemParam.WriteTempFile(yByteArray, nCount * SystemParam.Step2_len + j, Calc2.LightTempFile); } break; } } waitProc.SetProcessBar(100); this.Invoke((EventHandler)(delegate { listView1.Items[12].SubItems[1].Text = "完成"; textBox1.AppendText("50%曝光明场采集完成\r\n"); })); }
void FPNTest_Light(object LockWatingThread) { byte[] yByteArray; uint lsup = SystemParam.eStart + (uint)(Calc1.saturation * FPN_Per / 100) * SystemParam.eStep; for (int k = 0; k < FPN_L; k++) { rxFrame = 0; uint ls = (uint)(lsup / FPN_L * (k + 1)); Calc2.y50 = new double[m_Buffers.Height, m_Buffers.Width]; int nCount = FPN_Ns / FPN_Len; this.Invoke((EventHandler)(delegate { if (bLight) { textBox1.AppendText("开始" + (FPN_Per / FPN_L * (k + 1)).ToString("F2") + "%曝光明场采集\r\n"); } else { textBox1.AppendText("开始" + (FPN_Per / FPN_L * (k + 1)).ToString("F2") + "%曝光暗场采集\r\n"); } toolStripLabel3.Text = (ls * SystemParam.Ts).ToString("F2") + " ms"; })); NopCam((ushort)(FPN_Len + +CamEx), ls); int saveindex = 0; for (int i = 0; i < nCount; i++) { if (waitProc.HasBeenCancelled()) { return; } SerialFunc.SerialCommand3((ushort)(FPN_Len + +CamEx), ls); if (!WaitCam(FPN_Len + CamEx)) { i--; continue; } if (bLight) { for (int j = 1; j < FPN_Len + 1; j++) { saveindex++; m_Buffers.Save(FPNFile_Path + "TempPic\\Light\\" + saveindex.ToString() + ".bmp", "-format bmp", j, 0); Thread.Sleep(SystemParam.PicDelay); } for (int j = 1; j < FPN_Len + 1; j++) { yByteArray = wfSapGUI.ReadPicDatas(m_Buffers, j); SystemParam.WriteTempFile(yByteArray, i * FPN_Len + j - 1, FPNFile_Path + "TempData\\Light\\" + (k + 1).ToString() + "bin"); } } else { for (int j = 1; j < FPN_Len + 1; j++) { saveindex++; m_Buffers.Save(FPNFile_Path + "TempPic\\Dark\\" + saveindex.ToString() + ".bmp", "-format bmp", j, 0); Thread.Sleep(SystemParam.PicDelay); } for (int j = 1; j < FPN_Len + 1; j++) { yByteArray = wfSapGUI.ReadPicDatas(m_Buffers, j); SystemParam.WriteTempFile(yByteArray, i * FPN_Len + j - 1, FPNFile_Path + "TempData\\Dark\\" + (k + 1).ToString() + "bin"); } } } if (nCount * FPN_Len < FPN_L)//还有一个 { while (true) { int left = FPN_L - nCount * FPN_Len; rxFrame = 0; SerialFunc.SerialCommand3((ushort)(FPN_Len + +CamEx), ls); if (!WaitCam(SystemParam.Step2_len + CamEx)) { continue; } if (bLight) { for (int j = 1; j < left + 1; j++) { saveindex++; m_Buffers.Save(FPNFile_Path + "TempPic\\Light\\" + saveindex.ToString() + ".bmp", "-format bmp", j, 0); Thread.Sleep(SystemParam.PicDelay); } for (int j = 1; j < left + 1; j++) { yByteArray = wfSapGUI.ReadPicDatas(m_Buffers, j); SystemParam.WriteTempFile(yByteArray, nCount * FPN_Len + j - 1, FPNFile_Path + "TempData\\Light\\" + (k + 1).ToString() + "bin"); } } else { for (int j = 1; j < left + 1; j++) { saveindex++; m_Buffers.Save(FPNFile_Path + "TempPic\\Dark\\" + saveindex.ToString() + ".bmp", "-format bmp", j, 0); Thread.Sleep(SystemParam.PicDelay); } for (int j = 1; j < left + 1; j++) { yByteArray = wfSapGUI.ReadPicDatas(m_Buffers, j); SystemParam.WriteTempFile(yByteArray, nCount * FPN_Len + j - 1, FPNFile_Path + "TempData\\Dark\\" + (k + 1).ToString() + "bin"); } } break; } } waitProc.SetProcessBar(k + 1); } waitProc.SetProcessBar(FPN_L); this.Invoke((EventHandler)(delegate { if (bLight) { textBox1.AppendText("FPN明场采集完成\r\n"); } else { textBox1.AppendText("FPN暗场采集完成\r\n"); } })); }
void 暗场采集(object LockWatingThread) { double y, d; double t; Calc1.miu_y_dark = new List <double>(); Calc1.delta_y_dark = new List <double>(); this.Invoke((EventHandler)(delegate { chart1.Series[0].Points.Clear(); chart1.Series[1].Points.Clear(); chart1.ChartAreas[0].AxisY.Title = "暗场均值"; chart1.ChartAreas[1].AxisY.Title = "暗场方差"; })); NopCam((ushort)(PicN + 1), SystemParam.eStart); int saveindex = 0; int step = (int)(MaxTime / SystemParam.Ts / PhotoNs); for (uint i = 0; i < PhotoNs; i++) { uint ls = SystemParam.eStart + (uint)(i * step); this.Invoke((EventHandler)(delegate { toolStripLabel3.Text = SystemParam.GetTime((int)i).ToString("F2") + " ms"; })); if (waitProc.HasBeenCancelled()) { return; } SerialFunc.SerialCommand3((ushort)(PicN + 1), ls); if (!WaitCam((ushort)(PicN + 1))) { i--; continue; } for (int j = 1; j < PicN + 1; j++) { saveindex++; m_Buffers.Save(Calc1.TempPicPath_Dark + saveindex.ToString() + ".bmp", "-format bmp", j, 0); Thread.Sleep(SystemParam.PicDelay); } byte[] yByteArray; t = ls * SystemParam.Ts; for (int j = 1; j < PicN + 1; j++) { yByteArray = wfSapGUI.ReadPicDatas(m_Buffers, j); SystemParam.CreateBINFile(yByteArray, SystemParam.TxtCustomDarkDataPath + dtStart.ToString("yyyyMMdd_HHmmss") + "\\" + t.ToString("F3") + "_" + j.ToString() + ".bin"); } // yByteArray = wfSapGUI.ReadPicDatas(m_Buffers, 1); // SystemParam.CreateBINFile(yByteArray, SystemParam.TxtCustomDarkDataPath + dtStart.ToString("yyyyMMdd_HHmmss") + "\\" + t.ToString("F3") + "_1.bin"); // yByteArray = wfSapGUI.ReadPicDatas(m_Buffers, 2); // SystemParam.CreateBINFile(yByteArray, SystemParam.TxtCustomDarkDataPath + dtStart.ToString("yyyyMMdd_HHmmss") + "\\" + t.ToString("F3") + "_2.bin"); ya = wfSapGUI.ReadPicDatas(m_Buffers, PicN); //yb = wfSapGUI.ReadPicDatas(m_Buffers, 2); Calc1.TestExposureTime1(ya, m_Buffers.Height, m_Buffers.Width, SystemParam.cmosInfo.PixelDepth, out y, out d); this.Invoke((EventHandler)(delegate { chart1.Series[0].Points.AddXY(t, y); chart1.Series[1].Points.AddXY(t, d); waitProc.SetProcessBar((int)(i + 1)); })); TextLog.AddTextLog(String.Format(SystemParam.TxtCustomDarkDataFormat, t.ToString("F3"), y.ToString("F6"), d.ToString("F6")), fileName, false); } }