static void Main() { IPConnection ipcon = new IPConnection(); // Create IP connection BrickletThermalImaging ti = new BrickletThermalImaging(UID, ipcon); // Create device object ipcon.Connect(HOST, PORT); // Connect to brickd // Don't use device before ipcon is connected // Register high contrast image callback to function HighContrastImageCB ti.HighContrastImageCallback += HighContrastImageCB; // Enable high contrast image transfer for callback ti.SetImageTransferConfig(BrickletThermalImaging.IMAGE_TRANSFER_CALLBACK_HIGH_CONTRAST_IMAGE); Console.WriteLine("Press enter to exit"); Console.ReadLine(); ipcon.Disconnect(); }
public Example() { IPConnection ipcon = new IPConnection(); // Create IP connection BrickletThermalImaging ti = new BrickletThermalImaging(UID, ipcon); // Create device object ipcon.Connect(HOST, PORT); // Connect to brickd // Don't use device before ipcon is connected CreateThermalImageColorPalette(); // Register high contrast callback to function cb_high_contrast_image ti.HighContrastImageCallback += HighContrastImageCB; // Enable high contrast image transfer for callback ti.SetImageTransferConfig(BrickletThermalImaging.IMAGE_TRANSFER_CALLBACK_HIGH_CONTRAST_IMAGE); // Use correct size for window and add paint event handler this.ClientSize = new System.Drawing.Size(WIDTH * SCALE, HEIGHT * SCALE); this.Paint += new System.Windows.Forms.PaintEventHandler(this.ThermalImagePaint); }
static void Main() { IPConnection ipcon = new IPConnection(); // Create IP connection BrickletThermalImaging ti = new BrickletThermalImaging(UID, ipcon); // Create device object ipcon.Connect(HOST, PORT); // Connect to brickd // Don't use device before ipcon is connected CreateThermalImageColorPalette(); // Enable high contrast image transfer for callback ti.SetImageTransferConfig(BrickletThermalImaging.IMAGE_TRANSFER_MANUAL_HIGH_CONTRAST_IMAGE); // If we change between transfer modes we have to wait until one more // image is taken after the mode is set and the first image is saved // we can call GetHighContrastImage any time. Thread.Sleep(250); byte[] imageData = ti.GetHighContrastImage(); // Create PNG with Bitmap from System.Drawing Bitmap bitmap = new Bitmap(80, 60); for (int row = 0; row < 80; row++) { for (int col = 0; col < 60; col++) { int color = imageData[row + col * 80]; bitmap.SetPixel(row, col, Color.FromArgb(paletteR[color], paletteG[color], paletteB[color])); } } // Scale to 800x600 and save thermal image! bitmap = new Bitmap(bitmap, new Size(80 * 10, 60 * 10)); bitmap.Save("thermal_image.png", ImageFormat.Png); System.Console.WriteLine("Press enter to exit"); System.Console.ReadLine(); ipcon.Disconnect(); }
private static string UID = "XYZ"; // Change XYZ to the UID of your Thermal Imaging Bricklet // Callback function for high contrast image callback static void HighContrastImageCB(BrickletThermalImaging sender, byte[] image) { // image is an array of size 80*60 with a 8 bit grey value for each element }
// Callback function for the high contrast image void HighContrastImageCB(BrickletThermalImaging sender, byte[] image) { // Save image and trigger paint event handler imageData = image; this.Refresh(); }