From ef0a08994884ffd4645fffe95ae1667b693557ba Mon Sep 17 00:00:00 2001 From: "Kwabena W. Agyeman" Date: Mon, 9 Dec 2024 00:02:13 -0800 Subject: [PATCH] scripts/examples: Add FLIR Boson examples. --- .../02-FLIR-Boson/grayscale_color_tracking.py | 33 +++++++++++++++++ .../02-FLIR-Boson/grayscale_streaming.py | 21 +++++++++++ .../02-FLIR-Boson/ironbow_color_tracking.py | 35 +++++++++++++++++++ .../02-FLIR-Boson/ironbow_streaming.py | 23 ++++++++++++ scripts/examples/index.csv | 1 + 5 files changed, 113 insertions(+) create mode 100644 scripts/examples/01-Camera/05-Thermal-Cameras/02-FLIR-Boson/grayscale_color_tracking.py create mode 100644 scripts/examples/01-Camera/05-Thermal-Cameras/02-FLIR-Boson/grayscale_streaming.py create mode 100644 scripts/examples/01-Camera/05-Thermal-Cameras/02-FLIR-Boson/ironbow_color_tracking.py create mode 100644 scripts/examples/01-Camera/05-Thermal-Cameras/02-FLIR-Boson/ironbow_streaming.py diff --git a/scripts/examples/01-Camera/05-Thermal-Cameras/02-FLIR-Boson/grayscale_color_tracking.py b/scripts/examples/01-Camera/05-Thermal-Cameras/02-FLIR-Boson/grayscale_color_tracking.py new file mode 100644 index 000000000..049b1b2f9 --- /dev/null +++ b/scripts/examples/01-Camera/05-Thermal-Cameras/02-FLIR-Boson/grayscale_color_tracking.py @@ -0,0 +1,33 @@ +# This work is licensed under the MIT license. +# Copyright (c) 2013-2024 OpenMV LLC. All rights reserved. +# https://github.com/openmv/openmv/blob/master/LICENSE +# +# Single Color Grayscale Blob Tracking Example +# +# This example shows off single color grayscale tracking using the OpenMV Cam using the FLIR Boson. + +import sensor +import time + +# Color Tracking Thresholds (Grayscale Min, Grayscale Max) +threshold_list = [(220, 255)] + +sensor.reset() +sensor.set_pixformat(sensor.GRAYSCALE) +sensor.set_framesize(sensor.VGA) +sensor.skip_frames(time=5000) +clock = time.clock() + +# Only blobs that with more pixels than "pixel_threshold" and more area than "area_threshold" are +# returned by "find_blobs" below. Change "pixels_threshold" and "area_threshold" if you change the +# camera resolution. "merge=True" merges all overlapping blobs in the image. + +while True: + clock.tick() + img = sensor.snapshot() + for blob in img.find_blobs( + threshold_list, pixels_threshold=200, area_threshold=200, merge=True + ): + img.draw_rectangle(blob.rect(), color=127) + img.draw_cross(blob.cx(), blob.cy(), color=127) + print(clock.fps()) diff --git a/scripts/examples/01-Camera/05-Thermal-Cameras/02-FLIR-Boson/grayscale_streaming.py b/scripts/examples/01-Camera/05-Thermal-Cameras/02-FLIR-Boson/grayscale_streaming.py new file mode 100644 index 000000000..ea3617f13 --- /dev/null +++ b/scripts/examples/01-Camera/05-Thermal-Cameras/02-FLIR-Boson/grayscale_streaming.py @@ -0,0 +1,21 @@ +# This work is licensed under the MIT license. +# Copyright (c) 2013-2024 OpenMV LLC. All rights reserved. +# https://github.com/openmv/openmv/blob/master/LICENSE +# +# This example shows off streaming the default grayscale 8-bit AGC image from the FLIR Boson. + +import sensor +import time + +sensor.reset() +sensor.set_pixformat(sensor.GRAYSCALE) # Must always be grayscale. +sensor.set_framesize(sensor.VGA) # Must always be VGA or QVGA. + +clock = time.clock() + +while True: + clock.tick() + + img = sensor.snapshot() + + print(clock.fps()) diff --git a/scripts/examples/01-Camera/05-Thermal-Cameras/02-FLIR-Boson/ironbow_color_tracking.py b/scripts/examples/01-Camera/05-Thermal-Cameras/02-FLIR-Boson/ironbow_color_tracking.py new file mode 100644 index 000000000..0a90bb73b --- /dev/null +++ b/scripts/examples/01-Camera/05-Thermal-Cameras/02-FLIR-Boson/ironbow_color_tracking.py @@ -0,0 +1,35 @@ +# This work is licensed under the MIT license. +# Copyright (c) 2013-2024 OpenMV LLC. All rights reserved. +# https://github.com/openmv/openmv/blob/master/LICENSE +# +# Single Color RGB565 Blob Tracking Example +# +# This example shows off single color RGB565 tracking using the OpenMV Cam using the FLIR BOSON. + +import sensor +import time +import image + +# Color Tracking Thresholds (L Min, L Max, A Min, A Max, B Min, B Max) +threshold_list = [(70, 100, -30, 40, 20, 100)] + +sensor.reset() +sensor.set_pixformat(sensor.GRAYSCALE) +sensor.set_framesize(sensor.VGA) +sensor.set_color_palette(image.PALETTE_IRONBOW) +sensor.skip_frames(time=5000) +clock = time.clock() + +# Only blobs that with more pixels than "pixel_threshold" and more area than "area_threshold" are +# returned by "find_blobs" below. Change "pixels_threshold" and "area_threshold" if you change the +# camera resolution. "merge=True" merges all overlapping blobs in the image. + +while True: + clock.tick() + img = sensor.snapshot() + for blob in img.find_blobs( + threshold_list, pixels_threshold=200, area_threshold=200, merge=True + ): + img.draw_rectangle(blob.rect()) + img.draw_cross(blob.cx(), blob.cy()) + print(clock.fps()) diff --git a/scripts/examples/01-Camera/05-Thermal-Cameras/02-FLIR-Boson/ironbow_streaming.py b/scripts/examples/01-Camera/05-Thermal-Cameras/02-FLIR-Boson/ironbow_streaming.py new file mode 100644 index 000000000..2db230d15 --- /dev/null +++ b/scripts/examples/01-Camera/05-Thermal-Cameras/02-FLIR-Boson/ironbow_streaming.py @@ -0,0 +1,23 @@ +# This work is licensed under the MIT license. +# Copyright (c) 2013-2024 OpenMV LLC. All rights reserved. +# https://github.com/openmv/openmv/blob/master/LICENSE +# +# This example shows off streaming an ironbow image from the FLIR Boson. + +import sensor +import time +import image + +sensor.reset() +sensor.set_pixformat(sensor.GRAYSCALE) # Must always be grayscale. +sensor.set_framesize(sensor.VGA) # Must always be VGA or QVGA. +sensor.set_color_palette(image.PALETTE_IRONBOW) + +clock = time.clock() + +while True: + clock.tick() + + img = sensor.snapshot() + + print(clock.fps()) diff --git a/scripts/examples/index.csv b/scripts/examples/index.csv index f22b7b6de..a51557150 100644 --- a/scripts/examples/index.csv +++ b/scripts/examples/index.csv @@ -8,6 +8,7 @@ "examples/01-Camera/03-Event-Cameras/02-Genx320", ".+", "(GENX320)", "" "examples/01-Camera/04-Global-Shutter", ".+", "(MT9V0X2|MT9V0X2-C|MT9V0X4|MT9V0X4-C)", "" "examples/01-Camera/05-Thermal-Cameras/01-FLIR-Lepton", ".+", "(LEPTON|LEPTON-1.5|LEPTON-1.6|LEPTON-2.0|LEPTON-2.5|LEPTON-3.0|LEPTON-3.5)", "" +"examples/01-Camera/05-Thermal-Cameras/02-FLIR-Boson", ".+", "(BOSON|BOSON-320|BOSON-640)", "" "examples/01-Camera/06-Time-of-Flight", ".+", "^(?!None).*$", "" "examples/01-Camera/07-Sensor-Control", ".+", "^(?!None).*$", "" "examples/01-Camera/08-Readout-Control", ".+", "^(?!None).*$", ""