class Tinkerforge::BrickletThermalImaging
80x60 pixel thermal imaging camera
Constants
- CALLBACK_HIGH_CONTRAST_IMAGE
This callback is triggered with every new high contrast image if the transfer image config is configured for high contrast callback (see
BrickletThermalImaging#set_image_transfer_config
).The data is organized as a 8-bit value 80x60 pixel matrix linearized in a one-dimensional array. The data is arranged line by line from top left to bottom right.
Each 8-bit value represents one gray-scale image pixel that can directly be shown to a user on a display.
- .. note
-
If reconstructing the value fails, the callback is triggered with nil for image.
- CALLBACK_HIGH_CONTRAST_IMAGE_LOW_LEVEL
- CALLBACK_TEMPERATURE_IMAGE
This callback is triggered with every new temperature image if the transfer image config is configured for temperature callback (see
BrickletThermalImaging#set_image_transfer_config
).The data is organized as a 16-bit value 80x60 pixel matrix linearized in a one-dimensional array. The data is arranged line by line from top left to bottom right.
Each 16-bit value represents one temperature measurement in either Kelvin/10 or Kelvin/100 (depending on the resolution set with
BrickletThermalImaging#set_resolution
).- .. note
-
If reconstructing the value fails, the callback is triggered with nil for image.
- CALLBACK_TEMPERATURE_IMAGE_LOW_LEVEL
Public Class Methods
Creates an object with the unique device ID uid
and adds it to the IP Connection ipcon
.
# File lib/tinkerforge/bricklet_thermal_imaging.rb, line 107 def initialize(uid, ipcon) super uid, ipcon, DEVICE_IDENTIFIER, DEVICE_DISPLAY_NAME @api_version = [2, 0, 1] @response_expected[FUNCTION_GET_HIGH_CONTRAST_IMAGE_LOW_LEVEL] = RESPONSE_EXPECTED_ALWAYS_TRUE @response_expected[FUNCTION_GET_TEMPERATURE_IMAGE_LOW_LEVEL] = RESPONSE_EXPECTED_ALWAYS_TRUE @response_expected[FUNCTION_GET_STATISTICS] = RESPONSE_EXPECTED_ALWAYS_TRUE @response_expected[FUNCTION_SET_RESOLUTION] = RESPONSE_EXPECTED_FALSE @response_expected[FUNCTION_GET_RESOLUTION] = RESPONSE_EXPECTED_ALWAYS_TRUE @response_expected[FUNCTION_SET_SPOTMETER_CONFIG] = RESPONSE_EXPECTED_FALSE @response_expected[FUNCTION_GET_SPOTMETER_CONFIG] = RESPONSE_EXPECTED_ALWAYS_TRUE @response_expected[FUNCTION_SET_HIGH_CONTRAST_CONFIG] = RESPONSE_EXPECTED_FALSE @response_expected[FUNCTION_GET_HIGH_CONTRAST_CONFIG] = RESPONSE_EXPECTED_ALWAYS_TRUE @response_expected[FUNCTION_SET_IMAGE_TRANSFER_CONFIG] = RESPONSE_EXPECTED_TRUE @response_expected[FUNCTION_GET_IMAGE_TRANSFER_CONFIG] = RESPONSE_EXPECTED_ALWAYS_TRUE @response_expected[FUNCTION_SET_FLUX_LINEAR_PARAMETERS] = RESPONSE_EXPECTED_FALSE @response_expected[FUNCTION_GET_FLUX_LINEAR_PARAMETERS] = RESPONSE_EXPECTED_ALWAYS_TRUE @response_expected[FUNCTION_GET_SPITFP_ERROR_COUNT] = RESPONSE_EXPECTED_ALWAYS_TRUE @response_expected[FUNCTION_SET_BOOTLOADER_MODE] = RESPONSE_EXPECTED_ALWAYS_TRUE @response_expected[FUNCTION_GET_BOOTLOADER_MODE] = RESPONSE_EXPECTED_ALWAYS_TRUE @response_expected[FUNCTION_SET_WRITE_FIRMWARE_POINTER] = RESPONSE_EXPECTED_FALSE @response_expected[FUNCTION_WRITE_FIRMWARE] = RESPONSE_EXPECTED_ALWAYS_TRUE @response_expected[FUNCTION_SET_STATUS_LED_CONFIG] = RESPONSE_EXPECTED_FALSE @response_expected[FUNCTION_GET_STATUS_LED_CONFIG] = RESPONSE_EXPECTED_ALWAYS_TRUE @response_expected[FUNCTION_GET_CHIP_TEMPERATURE] = RESPONSE_EXPECTED_ALWAYS_TRUE @response_expected[FUNCTION_RESET] = RESPONSE_EXPECTED_FALSE @response_expected[FUNCTION_WRITE_UID] = RESPONSE_EXPECTED_FALSE @response_expected[FUNCTION_READ_UID] = RESPONSE_EXPECTED_ALWAYS_TRUE @response_expected[FUNCTION_GET_IDENTITY] = RESPONSE_EXPECTED_ALWAYS_TRUE @callback_formats[CALLBACK_HIGH_CONTRAST_IMAGE_LOW_LEVEL] = [72, 'S C62'] @callback_formats[CALLBACK_TEMPERATURE_IMAGE_LOW_LEVEL] = [72, 'S S31'] @high_level_callbacks[CALLBACK_HIGH_CONTRAST_IMAGE] = [['stream_chunk_offset', 'stream_chunk_data'], {'fixed_length' => 4800, 'single_chunk' => false}, nil] @high_level_callbacks[CALLBACK_TEMPERATURE_IMAGE] = [['stream_chunk_offset', 'stream_chunk_data'], {'fixed_length' => 4800, 'single_chunk' => false}, nil] @ipcon.add_device self end
Public Instance Methods
Returns the current bootloader mode, see BrickletThermalImaging#set_bootloader_mode
.
# File lib/tinkerforge/bricklet_thermal_imaging.rb, line 389 def get_bootloader_mode check_validity send_request FUNCTION_GET_BOOTLOADER_MODE, [], '', 9, 'C' end
Returns the temperature as measured inside the microcontroller. The value returned is not the ambient temperature!
The temperature is only proportional to the real temperature and it has bad accuracy. Practically it is only useful as an indicator for temperature changes.
# File lib/tinkerforge/bricklet_thermal_imaging.rb, line 447 def get_chip_temperature check_validity send_request FUNCTION_GET_CHIP_TEMPERATURE, [], '', 10, 's' end
Returns the flux linear parameters, as set by BrickletThermalImaging#set_flux_linear_parameters
.
- .. versionadded
-
2.0.5$nbsp;(Plugin)
# File lib/tinkerforge/bricklet_thermal_imaging.rb, line 350 def get_flux_linear_parameters check_validity send_request FUNCTION_GET_FLUX_LINEAR_PARAMETERS, [], '', 24, 'S S S S S S S S' end
Returns the high contrast config as set by BrickletThermalImaging#set_high_contrast_config
.
# File lib/tinkerforge/bricklet_thermal_imaging.rb, line 307 def get_high_contrast_config check_validity send_request FUNCTION_GET_HIGH_CONTRAST_CONFIG, [], '', 20, 'C4 S S2 S' end
Returns the current high contrast image. See `here <BrickletThermalImaging#set_image_transfer_config
.
# File lib/tinkerforge/bricklet_thermal_imaging.rb, line 512 def get_high_contrast_image image_length = 4800 image_data = nil # assigned in block @stream_mutex.synchronize { ret = get_high_contrast_image_low_level image_chunk_offset = ret[0] if image_chunk_offset == (1 << 16) - 1 # maximum chunk offset -> stream has no data image_length = 0 image_chunk_offset = 0 image_out_of_sync = false image_data = [] else image_out_of_sync = image_chunk_offset != 0 image_data = ret[1] end while not image_out_of_sync and image_data.length < image_length ret = get_high_contrast_image_low_level image_chunk_offset = ret[0] image_out_of_sync = image_chunk_offset != image_data.length image_data += ret[1] end if image_out_of_sync # discard remaining stream to bring it back in-sync while image_chunk_offset + 62 < image_length ret = get_high_contrast_image_low_level image_chunk_offset = ret[0] end raise StreamOutOfSyncException, 'Image stream is out-of-sync' end } image_data[0, image_length] end
Returns the current high contrast image. See `here <BrickletThermalImaging#set_image_transfer_config
.
# File lib/tinkerforge/bricklet_thermal_imaging.rb, line 160 def get_high_contrast_image_low_level check_validity send_request FUNCTION_GET_HIGH_CONTRAST_IMAGE_LOW_LEVEL, [], '', 72, 'S C62' end
Returns the UID, the UID where the Bricklet is connected to, the position, the hardware and firmware version as well as the device identifier.
The position can be 'a', 'b', 'c', 'd', 'e', 'f', 'g' or 'h' (Bricklet Port). A Bricklet connected to an :ref:`Isolator Bricklet <isolator_bricklet>` is always at position 'z'.
The device identifier numbers can be found :ref:`here <device_identifier>`. |device_identifier_constant|
# File lib/tinkerforge/bricklet_thermal_imaging.rb, line 494 def get_identity send_request FUNCTION_GET_IDENTITY, [], '', 33, 'Z8 Z8 k C3 C3 S' end
Returns the image transfer config, as set by BrickletThermalImaging#set_image_transfer_config
.
# File lib/tinkerforge/bricklet_thermal_imaging.rb, line 330 def get_image_transfer_config check_validity send_request FUNCTION_GET_IMAGE_TRANSFER_CONFIG, [], '', 9, 'C' end
Returns the resolution as set by BrickletThermalImaging#set_resolution
.
# File lib/tinkerforge/bricklet_thermal_imaging.rb, line 235 def get_resolution check_validity send_request FUNCTION_GET_RESOLUTION, [], '', 9, 'C' end
Returns the error count for the communication between Brick and Bricklet.
The errors are divided into
-
ACK checksum errors,
-
message checksum errors,
-
framing errors and
-
overflow errors.
The errors counts are for errors that occur on the Bricklet side. All Bricks have a similar function that returns the errors on the Brick side.
# File lib/tinkerforge/bricklet_thermal_imaging.rb, line 367 def get_spitfp_error_count check_validity send_request FUNCTION_GET_SPITFP_ERROR_COUNT, [], '', 24, 'L L L L' end
Returns the spotmeter config as set by BrickletThermalImaging#set_spotmeter_config
.
# File lib/tinkerforge/bricklet_thermal_imaging.rb, line 256 def get_spotmeter_config check_validity send_request FUNCTION_GET_SPOTMETER_CONFIG, [], '', 12, 'C4' end
Returns the spotmeter statistics, various temperatures, current resolution and status bits.
The spotmeter statistics are:
-
Index 0: Mean Temperature.
-
Index 1: Maximum Temperature.
-
Index 2: Minimum Temperature.
-
Index 3: Pixel Count of spotmeter region of interest.
The temperatures are:
-
Index 0: Focal Plain Array temperature.
-
Index 1: Focal Plain Array temperature at last FFC (Flat Field Correction).
-
Index 2: Housing temperature.
-
Index 3: Housing temperature at last FFC.
The resolution is either `0 to 6553 Kelvin` or `0 to 655 Kelvin`. If the resolution is the former, the temperatures are in Kelvin/10, if it is the latter the temperatures are in Kelvin/100.
FFC (Flat Field Correction) Status:
-
FFC Never Commanded: Only seen on startup before first FFC.
-
FFC Imminent: This state is entered 2 seconds prior to initiating FFC.
-
FFC In Progress: Flat field correction is started (shutter moves in front of lens and back). Takes about 1 second.
-
FFC Complete: Shutter is in waiting position again, FFC done.
Temperature warning bits:
-
Index 0: Shutter lockout (if true shutter is locked out because temperature is outside -10°C to +65°C)
-
Index 1: Overtemperature shut down imminent (goes true 10 seconds before shutdown)
# File lib/tinkerforge/bricklet_thermal_imaging.rb, line 215 def get_statistics check_validity send_request FUNCTION_GET_STATISTICS, [], '', 27, 'S4 S4 C C ?2' end
Returns the configuration as set by BrickletThermalImaging#set_status_led_config
# File lib/tinkerforge/bricklet_thermal_imaging.rb, line 435 def get_status_led_config check_validity send_request FUNCTION_GET_STATUS_LED_CONFIG, [], '', 9, 'C' end
Returns the current temperature image. See `here <BrickletThermalImaging#set_resolution
).
Before you can use this function you have to enable it with BrickletThermalImaging#set_image_transfer_config
.
# File lib/tinkerforge/bricklet_thermal_imaging.rb, line 563 def get_temperature_image image_length = 4800 image_data = nil # assigned in block @stream_mutex.synchronize { ret = get_temperature_image_low_level image_chunk_offset = ret[0] if image_chunk_offset == (1 << 16) - 1 # maximum chunk offset -> stream has no data image_length = 0 image_chunk_offset = 0 image_out_of_sync = false image_data = [] else image_out_of_sync = image_chunk_offset != 0 image_data = ret[1] end while not image_out_of_sync and image_data.length < image_length ret = get_temperature_image_low_level image_chunk_offset = ret[0] image_out_of_sync = image_chunk_offset != image_data.length image_data += ret[1] end if image_out_of_sync # discard remaining stream to bring it back in-sync while image_chunk_offset + 31 < image_length ret = get_temperature_image_low_level image_chunk_offset = ret[0] end raise StreamOutOfSyncException, 'Image stream is out-of-sync' end } image_data[0, image_length] end
Returns the current temperature image. See `here <BrickletThermalImaging#set_resolution
).
Before you can use this function you have to enable it with BrickletThermalImaging#set_image_transfer_config
.
# File lib/tinkerforge/bricklet_thermal_imaging.rb, line 179 def get_temperature_image_low_level check_validity send_request FUNCTION_GET_TEMPERATURE_IMAGE_LOW_LEVEL, [], '', 72, 'S S31' end
Returns the current UID as an integer. Encode as Base58
to get the usual string version.
# File lib/tinkerforge/bricklet_thermal_imaging.rb, line 478 def read_uid check_validity send_request FUNCTION_READ_UID, [], '', 12, 'L' end
Registers a callback with ID id
to the block block
.
# File lib/tinkerforge/bricklet_thermal_imaging.rb, line 602 def register_callback(id, &block) callback = block @registered_callbacks[id] = callback end
Calling this function will reset the Bricklet. All configurations will be lost.
After a reset you have to create new device objects, calling functions on the existing ones will result in undefined behavior!
# File lib/tinkerforge/bricklet_thermal_imaging.rb, line 459 def reset check_validity send_request FUNCTION_RESET, [], '', 8, '' end
Sets the bootloader mode and returns the status after the requested mode change was instigated.
You can change from bootloader mode to firmware mode and vice versa. A change from bootloader mode to firmware mode will only take place if the entry function, device identifier and CRC are present and correct.
This function is used by Brick Viewer during flashing. It should not be necessary to call it in a normal user program.
# File lib/tinkerforge/bricklet_thermal_imaging.rb, line 382 def set_bootloader_mode(mode) check_validity send_request FUNCTION_SET_BOOTLOADER_MODE, [mode], 'C', 9, 'C' end
Sets the flux linear parameters that can be used for radiometry calibration.
See FLIR document 102-PS245-100-01 for more details.
- .. versionadded
-
2.0.5$nbsp;(Plugin)
# File lib/tinkerforge/bricklet_thermal_imaging.rb, line 341 def set_flux_linear_parameters(scene_emissivity, temperature_background, tau_window, temperatur_window, tau_atmosphere, temperature_atmosphere, reflection_window, temperature_reflection) check_validity send_request FUNCTION_SET_FLUX_LINEAR_PARAMETERS, [scene_emissivity, temperature_background, tau_window, temperatur_window, tau_atmosphere, temperature_atmosphere, reflection_window, temperature_reflection], 'S S S S S S S S', 8, '' end
Sets the high contrast region of interest, dampening factor, clip limit and empty counts. This config is only used in high contrast mode (see BrickletThermalImaging#set_image_transfer_config
).
The high contrast region of interest consists of four values:
-
Index 0: Column start (has to be smaller or equal then Column end).
-
Index 1: Row start (has to be smaller then Row end).
-
Index 2: Column end (has to be smaller then 80).
-
Index 3: Row end (has to be smaller then 60).
The algorithm to generate the high contrast image is applied to this region.
Dampening Factor: This parameter is the amount of temporal dampening applied to the HEQ
- (history equalization) transformation function. An IIR filter of the form
-
(N / 256) * previous + ((256 - N) / 256) * current
is applied, and the HEQ dampening factor represents the value N in the equation, i.e., a value that applies to the amount of influence the previous HEQ transformation function has on the current function. The lower the value of N the higher the influence of the current video frame whereas the higher the value of N the more influence the previous damped transfer function has.
Clip Limit Index 0 (AGC HEQ Clip Limit High): This parameter defines the maximum number of pixels allowed to accumulate in any given histogram bin. Any additional pixels in a given bin are clipped. The effect of this parameter is to limit the influence of highly-populated bins on the resulting HEQ transformation function.
Clip Limit Index 1 (AGC HEQ Clip Limit Low): This parameter defines an artificial population that is added to every non-empty histogram bin. In other words, if the Clip Limit Low is set to L, a bin with an actual population of X will have an effective population of L + X. Any empty bin that is nearby a populated bin will be given an artificial population of L. The effect of higher values is to provide a more linear transfer function; lower values provide a more non-linear (equalized) transfer function.
Empty Counts: This parameter specifies the maximum number of pixels in a bin that will be interpreted as an empty bin. Histogram bins with this number of pixels or less will be processed as an empty bin.
# File lib/tinkerforge/bricklet_thermal_imaging.rb, line 300 def set_high_contrast_config(region_of_interest, dampening_factor, clip_limit, empty_counts) check_validity send_request FUNCTION_SET_HIGH_CONTRAST_CONFIG, [region_of_interest, dampening_factor, clip_limit, empty_counts], 'C4 S S2 S', 8, '' end
The necessary bandwidth of this Bricklet is too high to use getter/callback or high contrast/temperature image at the same time. You have to configure the one you want to use, the Bricklet will optimize the internal configuration accordingly.
Corresponding functions:
-
Manual High Contrast Image:
BrickletThermalImaging#get_high_contrast_image
. -
Manual Temperature Image:
BrickletThermalImaging#get_temperature_image
. -
Callback High Contrast Image:
CALLBACK_HIGH_CONTRAST_IMAGE
callback. -
Callback Temperature Image:
CALLBACK_TEMPERATURE_IMAGE
callback.
# File lib/tinkerforge/bricklet_thermal_imaging.rb, line 323 def set_image_transfer_config(config) check_validity send_request FUNCTION_SET_IMAGE_TRANSFER_CONFIG, [config], 'C', 8, '' end
Sets the resolution. The Thermal Imaging Bricklet can either measure
-
from 0 to 6553 Kelvin (-273.15°C to +6279.85°C) with 0.1°C resolution or
-
from 0 to 655 Kelvin (-273.15°C to +381.85°C) with 0.01°C resolution.
The accuracy is specified for -10°C to 450°C in the first range and -10°C and 140°C in the second range.
# File lib/tinkerforge/bricklet_thermal_imaging.rb, line 228 def set_resolution(resolution) check_validity send_request FUNCTION_SET_RESOLUTION, [resolution], 'C', 8, '' end
Sets the spotmeter region of interest. The 4 values are
-
Index 0: Column start (has to be smaller then Column end).
-
Index 1: Row start (has to be smaller then Row end).
-
Index 2: Column end (has to be smaller then 80).
-
Index 3: Row end (has to be smaller then 60).
The spotmeter statistics can be read out with BrickletThermalImaging#get_statistics
.
# File lib/tinkerforge/bricklet_thermal_imaging.rb, line 249 def set_spotmeter_config(region_of_interest) check_validity send_request FUNCTION_SET_SPOTMETER_CONFIG, [region_of_interest], 'C4', 8, '' end
Sets the status LED configuration. By default the LED shows communication traffic between Brick and Bricklet, it flickers once for every 10 received data packets.
You can also turn the LED permanently on/off or show a heartbeat.
If the Bricklet is in bootloader mode, the LED is will show heartbeat by default.
# File lib/tinkerforge/bricklet_thermal_imaging.rb, line 428 def set_status_led_config(config) check_validity send_request FUNCTION_SET_STATUS_LED_CONFIG, [config], 'C', 8, '' end
Sets the firmware pointer for BrickletThermalImaging#write_firmware
. The pointer has to be increased by chunks of size 64. The data is written to flash every 4 chunks (which equals to one page of size 256).
This function is used by Brick Viewer during flashing. It should not be necessary to call it in a normal user program.
# File lib/tinkerforge/bricklet_thermal_imaging.rb, line 401 def set_write_firmware_pointer(pointer) check_validity send_request FUNCTION_SET_WRITE_FIRMWARE_POINTER, [pointer], 'L', 8, '' end
Writes 64 Bytes of firmware at the position as written by BrickletThermalImaging#set_write_firmware_pointer
before. The firmware is written to flash every 4 chunks.
You can only write firmware in bootloader mode.
This function is used by Brick Viewer during flashing. It should not be necessary to call it in a normal user program.
# File lib/tinkerforge/bricklet_thermal_imaging.rb, line 415 def write_firmware(data) check_validity send_request FUNCTION_WRITE_FIRMWARE, [data], 'C64', 9, 'C' end
Writes a new UID into flash. If you want to set a new UID you have to decode the Base58
encoded UID string into an integer first.
We recommend that you use Brick Viewer to change the UID.
# File lib/tinkerforge/bricklet_thermal_imaging.rb, line 470 def write_uid(uid) check_validity send_request FUNCTION_WRITE_UID, [uid], 'L', 8, '' end