Skip to content

Commit

Permalink
SIYI: added inverted and gamma
Browse files Browse the repository at this point in the history
  • Loading branch information
tridge committed Oct 12, 2024
1 parent 52907d5 commit f373ea5
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
3 changes: 3 additions & 0 deletions MAVProxy/modules/lib/mp_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,7 @@ def __init__(self,
self.menu = None
self.popup_menu = None
self.fps = fps
self.inverted = False

self.in_queue = multiproc.Queue()
self.out_queue = multiproc.Queue()
Expand Down Expand Up @@ -427,6 +428,8 @@ def __init__(self, parent, state):
self.seek_percentage = None
self.seek_frame = None
self.osd_elements = None
self.inverted = False

state.brightness = 1.0

# dragpos is the top left position in image coordinates
Expand Down
3 changes: 3 additions & 0 deletions MAVProxy/modules/mavproxy_SIYI/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,9 @@ def __init__(self, mpstate):
('fps_rgb', int, 20),
('logfile', str, 'SIYI_log.bin'),
('thermal_fov', float, 24.2),
('thermal_gamma', float, 0.0),
('thermal_square', int, 50),

('zoom_fov', float, 62.0),
('wide_fov', float, 88.0),
('use_lidar', int, 0),
Expand Down
15 changes: 15 additions & 0 deletions MAVProxy/modules/mavproxy_SIYI/raw_thermal.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,14 @@ def display_image(self, fname, data):

# convert to 0 to 255
a = (a - minv) * 255 / (maxv - minv)
a = a.reshape(512, 640)

maxpt = np.unravel_index(a.argmax(), a.shape)

if self.siyi.siyi_settings.thermal_gamma:
a = a / 255.0
a = np.power(a, 1.0 / self.siyi.siyi_settings.thermal_gamma)
a = np.uint8(a * 255)

# convert to uint8 greyscale as 640x512 image
a = a.astype(np.uint8)
Expand All @@ -177,6 +185,13 @@ def display_image(self, fname, data):
a = cv2.cvtColor(a, cv2.COLOR_GRAY2RGB)
if self.im is None:
return

if self.siyi.siyi_settings.thermal_square > 0:
half_side = self.siyi.siyi_settings.thermal_square // 2
top_left = (maxpt[1] - half_side, maxpt[0] - half_side)
bottom_right = (maxpt[1] + half_side, maxpt[0] + half_side)
cv2.rectangle(a, top_left, bottom_right, (255,255,0), 2)

self.im.set_image(a)
self.image_count += 1
self.update_title()
Expand Down

0 comments on commit f373ea5

Please sign in to comment.