void ThermalThreadProc() { while (!stopThread && thermal != null) { bool progress = false; lastFrame = thermal.GetFrameBlocking(); if (lastFrame.IsCalibrationFrame) { lastCalibrationFrame = lastFrame; } else { if (lastCalibrationFrame != null && lastFrame.IsUsableFrame) { lastUsableFrame = lastFrame.ProcessFrame(lastCalibrationFrame); progress = true; } } //System.Diagnostics.Debug.Print("Start of data: " + string.Join(" ", lastFrame.RawData.Take(64).Select(b => b.ToString("x2")).ToArray())); //System.Diagnostics.Debug.Print("End of data: " + string.Join(" ", lastFrame.RawData.Reverse().Take(32).Reverse().Select(b => b.ToString("x2")).ToArray())); // Do stuff frameCount++; if (progress) { Invalidate(); } } }
void ThermalThreadProc() { while (!stopThread && thermal != null) { bool progress = false; currentFrame = thermal.GetFrameBlocking(); switch (currentFrame.StatusByte) { case 4: //gain calibration frame4stuff(); break; case 1: //shutter calibration markBadPixels(); if (!usignExternalCal) { frame1stuff(); } firstAfterCal = true; break; case 3: //image frame markBadPixels(); if (grabExternalReference) //use this image as reference { grabExternalReference = false; usignExternalCal = true; frame1stuff(); } else { frame3stuff(); lastUsableFrame = currentFrame; progress = true; } break; default: break; } if (progress) { Invalidate();//redraw form } } }
void ThermalThreadProc() { BinaryWriter tw; DateTime currentFrameTime = DateTime.Now; DateTime previousFrameTime = currentFrameTime; DateTime currentTime = DateTime.Now; DateTime previousTime = currentTime; int framesToCapture = 100; // Initialize frame (1 based) frameCount = 1; // Create the output files to save first 20 frames and associated metadata. //bw = new BinaryWriter(new FileStream("data.dat", FileMode.Create)); tw = new BinaryWriter(new FileStream("data.txt", FileMode.Create)); while (!stopThread && thermal != null) { bool progress = false; // Get frame lastFrame = thermal.GetFrameBlocking(); // Keep the ID4 and ID1 frame switch (lastFrame.StatusByte) { case 1: //shutter cal frameID1 = lastFrame; firstAfterCal = true; break; case 4: //first frame gain cal frameID4 = lastFrame; break; default: break; } // Time after frame capture previousTime = currentTime; currentTime = DateTime.Now; // Save data and metadata for the first framesToCapture frames if (frameCount <= framesToCapture) { tw.Write(Encoding.ASCII.GetBytes(String.Format("Frame {0} ID {1}\n", frameCount, lastFrame.RawDataU16[10]))); tw.Write(Encoding.ASCII.GetBytes(String.Format(lastFrame.AvgValue.ToString()))); tw.Write(Encoding.ASCII.GetBytes(String.Format("\n"))); if (frameCount == framesToCapture) { tw.Close(); } } switch (lastFrame.StatusByte) { case 4: //prvi frame za izračuna gaina markBadPixels(); getGainCalibration(); //konec: prvi frame za izračuna gaina break; case 1: //shutter frame za izračun offseta markBadPixels(); applyGainCalibration(); if (!usignExternalCal) { getOffsetCalibration(); } lastCalibrationFrame = frameID1; saveExternalFrames = false; //konec: shutter frame break; case 3: //pravi slikovni frame markZeroPixels(); applyGainCalibration(); if (m_get_extra_cal) //if this pixel should be used as reference { m_get_extra_cal = false; usignExternalCal = true; getOffsetCalibration(); saveExternalFrames = true; } applyOffsetCalibration(); fixBadPixels(); lastUsableFrame = lastFrame.ProcessFrameU16(lastReferenceFrame, frameID4); progress = true; //konec: pravi slikovni frame break; default: break; } // Increase frame count. frameCount++; if (progress) { Invalidate();//ponovno izriši formo... } } }