示例#1
0
        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();
                }
            }
        }
示例#2
0
        private void Form1_Paint(object sender, PaintEventArgs e)
        {
            CalibratedThermalFrame data = lastUsableFrame;
            if (data == null) return;
            int y;
            if(data != lastRenderedFrame)
            {
                lastRenderedFrame = data;
                // Process new frame
                Bitmap bmp = new Bitmap(data.Width, data.Height);
                int c = 0;

                for (y = 0; y < 156; y++)
                {
                    for (int x = 0; x < 208; x++)
                    {
                        int v = data.PixelData[c++];

                        v = (v - data.MinValue) * 255 / (data.MaxValue - data.MinValue);
                        if (v < 0) v = 0;
                        if (v > 255) v = 255;

                        bmp.SetPixel(x, y, Color.FromArgb(v, v, v));
                    }
                }

                bmpQueue.Enqueue(bmp);
                if (bmpQueue.Count > 5) bmpQueue.Dequeue(); 
            }

            y = 10;
            foreach(Bitmap b in bmpQueue.Reverse())
            {
                e.Graphics.DrawImage(b, 10, y);
                y += b.Height + 10;
            }
        }