@@ -69,6 +69,10 @@ def __init__(self, mpstate, title, rtsp_url, fps=30):
69
69
)
70
70
self .im .set_gstreamer (gst_pipeline )
71
71
72
+ def set_tracked_rectangle (self , top_left_x , top_left_y , bot_right_x , bot_right_y ):
73
+ """Set the tracked rectangle (normalised coords)"""
74
+ self .im .set_tracked_rectangle (top_left_x , top_left_y , bot_right_x , bot_right_y )
75
+
72
76
def close (self ):
73
77
"""Close the GUI"""
74
78
# TODO: MPImage does not have a close_event
@@ -96,13 +100,6 @@ def check_events(self):
96
100
if isinstance (event , MPImageFrameCounter ):
97
101
self .frame_counter = event .frame
98
102
continue
99
-
100
- # if isinstance(event, MPImageTrackPoint):
101
- # continue
102
-
103
- # if isinstance(event, MPImageTrackRectangle):
104
- # continue
105
-
106
103
if (
107
104
hasattr (event , "ClassName" )
108
105
and event .ClassName == "wxMouseEvent"
@@ -119,8 +116,8 @@ def check_events(self):
119
116
self .im .start_tracker (event .X , event .Y , twidth , twidth )
120
117
121
118
# TODO: move / encapsulate
122
- print (f"xres: { xres } , yres: { yres } " )
123
- print (f"event.X: { event .X } , event.Y: { event .X } , twidth: { twidth } " )
119
+ # print(f"xres: {xres}, yres: {yres}")
120
+ # print(f"event.X: {event.X}, event.Y: {event.X}, twidth: {twidth}")
124
121
top_left_x = event .X / xres
125
122
top_left_y = event .Y / yres
126
123
bot_right_x = (event .X + twidth ) / xres
@@ -135,8 +132,6 @@ def check_events(self):
135
132
else :
136
133
pass
137
134
138
- # Camera tracking commands. Communication is GCS -> FC
139
-
140
135
def send_camera_track_point (self , point_x , point_y , radius ):
141
136
"""
142
137
https://mavlink.io/en/messages/common.html#MAV_CMD_CAMERA_TRACK_POINT
@@ -147,11 +142,11 @@ def send_camera_track_point(self, point_x, point_y, radius):
147
142
src_cmp = self .mpstate .master ().source_component
148
143
tgt_sys = self .camera_sysid
149
144
tgt_cmp = self .camera_cmpid
150
- print (
151
- f"Send COMMAND_LONG: CAMERA_TRACK_POINT: "
152
- f"src_sys: { src_sys } , src_cmp: { src_cmp } "
153
- f"tgt_sys: { tgt_sys } , tgt_cmp: { tgt_cmp } "
154
- )
145
+ # print(
146
+ # f"Send COMMAND_LONG: CAMERA_TRACK_POINT: "
147
+ # f"src_sys: {src_sys}, src_cmp: {src_cmp} "
148
+ # f"tgt_sys: {tgt_sys}, tgt_cmp: {tgt_cmp}"
149
+ # )
155
150
target_camera = 0
156
151
self .mpstate .master ().mav .command_long_send (
157
152
tgt_sys , # target_system
@@ -179,11 +174,11 @@ def send_camera_track_rectangle(
179
174
src_cmp = self .mpstate .master ().source_component
180
175
tgt_sys = self .camera_sysid
181
176
tgt_cmp = self .camera_cmpid
182
- print (
183
- f"Send COMMAND_LONG: CAMERA_TRACK_RECTANGLE: "
184
- f"src_sys: { src_sys } , src_cmp: { src_cmp } "
185
- f"tgt_sys: { tgt_sys } , tgt_cmp: { tgt_cmp } "
186
- )
177
+ # print(
178
+ # f"Send COMMAND_LONG: CAMERA_TRACK_RECTANGLE: "
179
+ # f"src_sys: {src_sys}, src_cmp: {src_cmp} "
180
+ # f"tgt_sys: {tgt_sys}, tgt_cmp: {tgt_cmp}"
181
+ # )
187
182
target_camera = 0
188
183
self .mpstate .master ().mav .command_long_send (
189
184
tgt_sys , # target_system
@@ -207,11 +202,11 @@ def send_camera_stop_tracking(self):
207
202
src_cmp = self .mpstate .master ().source_component
208
203
tgt_sys = self .camera_sysid
209
204
tgt_cmp = self .camera_cmpid
210
- print (
211
- f"Send COMMAND_LONG: CAMERA_STOP_TRACKING: "
212
- f"src_sys: { src_sys } , src_cmp: { src_cmp } "
213
- f"tgt_sys: { tgt_sys } , tgt_cmp: { tgt_cmp } "
214
- )
205
+ # print(
206
+ # f"Send COMMAND_LONG: CAMERA_STOP_TRACKING: "
207
+ # f"src_sys: {src_sys}, src_cmp: {src_cmp} "
208
+ # f"tgt_sys: {tgt_sys}, tgt_cmp: {tgt_cmp}"
209
+ # )
215
210
target_camera = 0
216
211
self .mpstate .master ().mav .command_long_send (
217
212
tgt_sys , # target_system
@@ -227,34 +222,6 @@ def send_camera_stop_tracking(self):
227
222
0 , # param7
228
223
)
229
224
230
- def set_message_interval_image_status (self ):
231
- """
232
- https://mavlink.io/en/messages/common.html#CAMERA_TRACKING_IMAGE_STATUS
233
- https://mavlink.io/en/messages/common.html#MAV_CMD_SET_MESSAGE_INTERVAL
234
- """
235
- tgt_sys = self .camera_sysid
236
- tgt_comp = self .camera_cmpid
237
- print (
238
- f"Send COMMAND_LONG: SET_MESSAGE_INTERVAL: CAMERA_TRACKING_IMAGE_STATUS: "
239
- f"tgt_sys: { tgt_sys } , tgt_comp: { tgt_comp } "
240
- )
241
- message_id = mavutil .mavlink .CAMERA_TRACKING_IMAGE_STATUS
242
- interval = 0 # default rate
243
- response_target = 1 # address of requestor
244
- self .mpstate .master ().mav .command_long_send (
245
- tgt_sys , # target_system
246
- tgt_comp , # target_component
247
- mavutil .mavlink .MAV_CMD_SET_MESSAGE_INTERVAL , # command
248
- 0 , # confirmation
249
- message_id , # param1
250
- interval , # param2
251
- 0 , # param3
252
- 0 , # param4
253
- 0 , # param5
254
- 0 , # param6
255
- response_target , # param7
256
- )
257
-
258
225
259
226
if __name__ == "__main__" :
260
227
from optparse import OptionParser
0 commit comments