private bool ReceiveFromEdison(int numBytes, int mode) { bool done = false; if (mode == THERMAL_IMAGE) { if (!ImageProcessing.CheckThermalImage(ImageBuffer)) { txtMain.AppendText("Failed to load Thermal Image"); txtMain.AppendText("\n"); txtMain.ScrollToCaret(); Thread.Sleep(500); return(false); } done = true; } else if (mode == RGB_IMAGE) { //received JPG image //using OpenCV to encoding if (!ImageProcessing.CheckRGBImage(ImageBuffer, numBytes)) { txtMain.AppendText("Failed to load RGB Image"); txtMain.AppendText("\n"); txtMain.ScrollToCaret(); Thread.Sleep(500); return(false); } done = true; } else if (mode == BOTH_IMAGE) { //received both thermal and rgb image //do the mixed image algorithm //display done = true; } if (done) { DisplayImage(numBytes, mode); txtMain.AppendText("Server: " + (++numImage).ToString()); txtMain.AppendText("\n"); txtMain.ScrollToCaret(); } return(done); }
private void DisplayImage(int numBytes, int mode) { if (mode == THERMAL_IMAGE) { byte[] zoomImg = ImageProcessing.ZoomIn(); Bitmap tempbmp = ImageProcessing.CreateBitmapFromBytes(zoomImg, ImageProcessing.NEW_WIDTH, ImageProcessing.NEW_HEIGHT); pictureBox1.Image = tempbmp; lblTemperature.Text = CalTemperature().ToString("F2"); //btnNote.Text = ImageProcessing.MaxVal.ToString(); } else if (mode == RGB_IMAGE) { Mat tempMat = ImageProcessing.UndistortImage(); pictureBox3.Image = tempMat.Bitmap; } else if (mode == BOTH_IMAGE) { //test byte[] thermal = new byte[9600]; Array.Copy(ImageBuffer, 0, thermal, 0, 9600); byte[] rgb = new byte[numBytes - 9600]; Array.Copy(ImageBuffer, 9600, rgb, 0, numBytes - 9600); if (!ImageProcessing.CheckThermalImage(thermal) || !ImageProcessing.CheckRGBImage(rgb, numBytes - 9600)) { txtMain.AppendText("Failed to load Image"); txtMain.AppendText("\n"); txtMain.ScrollToCaret(); } byte[] zoomImg = ImageProcessing.ZoomIn(); Bitmap tempbmp = ImageProcessing.CreateBitmapFromBytes(zoomImg, ImageProcessing.NEW_WIDTH, ImageProcessing.NEW_HEIGHT); pictureBox1.Image = tempbmp; //Mat tempMat = ImageProcessing.UndistortImage(); //pictureBox3.Image = tempMat.Bitmap; pictureBox3.Image = MixImage.MixBothImage(); lblTemperature.Text = CalTemperature().ToString("F2"); //btnNote.Text = ImageProcessing.MaxVal.ToString(); } }