Skip to content

Commit

Permalink
SIYI: added zoom/lens menus and temp on mouse movement
Browse files Browse the repository at this point in the history
  • Loading branch information
tridge committed Sep 14, 2023
1 parent 0cad2ec commit c7439be
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 23 deletions.
4 changes: 3 additions & 1 deletion MAVProxy/modules/lib/mp_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ def __init__(self,
can_zoom = False,
can_drag = False,
mouse_events = False,
mouse_movement_events = False,
key_events = False,
auto_size = False,
report_size_changes = False,
Expand All @@ -93,6 +94,7 @@ def __init__(self,
self.can_zoom = can_zoom
self.can_drag = can_drag
self.mouse_events = mouse_events
self.mouse_movement_events = mouse_movement_events
self.key_events = key_events
self.auto_size = auto_size
self.auto_fit = auto_fit
Expand Down Expand Up @@ -518,7 +520,7 @@ def on_event(self, event):
any_button_down = event.ButtonIsDown(wx.MOUSE_BTN_ANY)
else:
any_button_down = event.leftIsDown or event.rightIsDown
if not any_button_down and event.GetWheelRotation() == 0:
if not any_button_down and event.GetWheelRotation() == 0 and not self.state.mouse_movement_events:
# don't flood the queue with mouse movement
return
evt = mp_util.object_container(event)
Expand Down
59 changes: 37 additions & 22 deletions MAVProxy/modules/mavproxy_SIYI/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ def capture(self):
'''thermal capture thread'''
self.im = MPImage(title='Camera View',
mouse_events=True,
mouse_movement_events=self.thermal,
width=self.res[0],
height=self.res[1],
key_events=True,
Expand All @@ -169,6 +170,13 @@ def capture(self):
"DEEPGREEN"]
for c in colormaps:
popup.add_to_submenu(["ColorMap"], MPMenuItem(c, returnkey="COLORMAP_"+c))
else:
popup.add_to_submenu(["Lens"], MPMenuItem("WideAngle", returnkey="Lens:wide"))
popup.add_to_submenu(["Lens"], MPMenuItem("Zoom", returnkey="Lens:zoom"))
popup.add_to_submenu(["Lens"], MPMenuItem("SplitScreen", returnkey="Lens:split"))
for z in range(1,11):
popup.add_to_submenu(['Zoom'],
MPMenuItem('%ux'%z, returnkey="Zoom:%u" % z))

self.cap = cv2.VideoCapture('udp://@:%u' % self.port)
if not self.cap or not self.cap.isOpened():
Expand Down Expand Up @@ -232,38 +240,44 @@ def check_events(self):
elif event.returnkey.startswith("Mode:"):
self.mode = event.returnkey[5:]
print("ViewMode: %s" % self.mode)
elif event.returnkey.startswith("Lens:"):
self.siyi.cmd_imode([event.returnkey[5:]])
elif event.returnkey.startswith("Zoom:"):
self.siyi.cmd_zoom([event.returnkey[5:]])
elif event.returnkey == 'fitWindow':
self.im.fit_to_window()
elif event.returnkey == 'fullSize':
self.im.full_size()
continue
if event.ClassName == 'wxMouseEvent' and event.leftIsDown:
if event.ClassName == 'wxMouseEvent':
if self.raw_frame is not None:
(yres,xres,depth) = self.raw_frame.shape
if self.thermal and event.x < xres and event.y < yres and event.x >= 0 and event.y >= 0:
self.siyi.spot_temp = self.get_pixel_temp(event.x, event.y)
self.update_title()
x = (2*event.x/float(xres))-1.0
y = (2*event.y/float(yres))-1.0
aspect_ratio = float(xres)/yres
if self.thermal:
FOV = self.siyi.siyi_settings.thermal_fov
elif self.siyi.rgb_lens == "zoom":
FOV = self.siyi.siyi_settings.zoom_fov / self.siyi.last_zoom
else:
FOV = self.siyi.siyi_settings.wide_fov
slant_range = self.siyi.get_slantrange(x,y,FOV,aspect_ratio)
if slant_range is None:
return
latlonalt = self.siyi.get_latlonalt(slant_range, x, y, FOV, aspect_ratio)
if latlonalt is None:
return
latlon = (latlonalt[0],latlonalt[1])
if self.mode == "ClickTrack":
self.siyi.set_target(latlonalt[0], latlonalt[1], latlonalt[2])
else:
self.siyi.mpstate.map.add_object(mp_slipmap.SlipIcon('SIYIClick', latlon,
self.siyi.click_icon, layer='SIYI', rotation=0, follow=False))
if event.ClassName == 'wxMouseEvent' and event.leftIsDown:
x = (2*event.x/float(xres))-1.0
y = (2*event.y/float(yres))-1.0
aspect_ratio = float(xres)/yres
if self.thermal:
FOV = self.siyi.siyi_settings.thermal_fov
elif self.siyi.rgb_lens == "zoom":
FOV = self.siyi.siyi_settings.zoom_fov / self.siyi.last_zoom
else:
FOV = self.siyi.siyi_settings.wide_fov
slant_range = self.siyi.get_slantrange(x,y,FOV,aspect_ratio)
if slant_range is None:
return
latlonalt = self.siyi.get_latlonalt(slant_range, x, y, FOV, aspect_ratio)
if latlonalt is None:
return
latlon = (latlonalt[0],latlonalt[1])
if self.mode == "ClickTrack":
self.siyi.set_target(latlonalt[0], latlonalt[1], latlonalt[2])
else:
self.siyi.mpstate.map.add_object(mp_slipmap.SlipIcon('SIYIClick', latlon,
self.siyi.click_icon, layer='SIYI'))




Expand Down Expand Up @@ -492,6 +506,7 @@ def cmd_imode(self, args):
if mode is None:
mode = int(args[0])
self.send_packet_fmt(SET_IMAGE_TYPE, "<B", mode)
print("Lens: %s" % args[0])

def cmd_palette(self, args):
'''update thermal palette'''
Expand Down

0 comments on commit c7439be

Please sign in to comment.