Skip to content

Commit 7ff2ec6

Browse files
author
Matevz Morato
committed
Merge branch 'update/device_manager' into develop
2 parents 5470eb4 + 6361255 commit 7ff2ec6

File tree

2 files changed

+25
-88
lines changed

2 files changed

+25
-88
lines changed

utilities/device_manager.py

Lines changed: 20 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,7 @@ def search_devices(self):
197197
else:
198198
rows = []
199199
for info in self.infos:
200+
if "X_LINK_GATE" == info.state.name: continue # Skip RVC4 devices
200201
rows.append([info.getDeviceId(), info.name, deviceStateTxt(info.state)])
201202
self.window['table'].update(values=rows)
202203

@@ -287,74 +288,6 @@ def factoryReset(device: dai.DeviceInfo, type: dai.DeviceBootloader.Type):
287288
PrintException()
288289
sg.Popup(f'{ex}')
289290

290-
def connectAndStartStreaming(dev):
291-
292-
with dai.Device(dev) as d:
293-
# Create pipeline
294-
pipeline = dai.Pipeline()
295-
# OpenCV
296-
if USE_OPENCV:
297-
camRgb = pipeline.create(dai.node.ColorCamera)
298-
camRgb.setIspScale(1,3)
299-
videnc = pipeline.create(dai.node.VideoEncoder)
300-
videnc.setDefaultProfilePreset(camRgb.getFps(), videnc.Properties.Profile.MJPEG)
301-
xout = pipeline.create(dai.node.XLinkOut)
302-
xout.setStreamName("mjpeg")
303-
camRgb.video.link(videnc.input)
304-
videnc.bitstream.link(xout.input)
305-
306-
while not d.isClosed():
307-
mjpeg = d.getOutputQueue('mjpeg').get()
308-
frame = cv2.imdecode(mjpeg.getData(), cv2.IMREAD_UNCHANGED)
309-
cv2.imshow('Color Camera', frame)
310-
if cv2.waitKey(1) == ord('q'):
311-
cv2.destroyWindow('Color Camera')
312-
break
313-
else:
314-
camRgb = pipeline.create(dai.node.ColorCamera)
315-
camRgb.setIspScale(1,3)
316-
firstSensor = d.getConnectedCameraFeatures()[0]
317-
camRgb.setPreviewSize(firstSensor.width // 3, firstSensor.height // 3)
318-
camRgb.setColorOrder(camRgb.Properties.ColorOrder.RGB)
319-
320-
xout = pipeline.create(dai.node.XLinkOut)
321-
xout.input.setQueueSize(2)
322-
xout.input.setBlocking(False)
323-
xout.setStreamName("color")
324-
camRgb.preview.link(xout.input)
325-
326-
# Start pipeline
327-
d.startPipeline(pipeline)
328-
329-
frame = d.getOutputQueue('color', 2, False).get()
330-
width, height = frame.getWidth(), frame.getHeight()
331-
332-
layout = [[sg.Graph(
333-
canvas_size=(width, height),
334-
graph_bottom_left=(0, 0),
335-
graph_top_right=(width, height),
336-
key="-GRAPH-",
337-
change_submits=True, # mouse click events
338-
background_color='lightblue',
339-
drag_submits=True), ],]
340-
window = sg.Window("Color Camera Stream", layout, finalize=True)
341-
graph = window["-GRAPH-"]
342-
343-
while not d.isClosed():
344-
frame = d.getOutputQueue('color').get()
345-
with io.BytesIO() as output:
346-
rgb = frame.getFrame()
347-
image = Image.fromarray(rgb, "RGB")
348-
image.save(output, format="GIF")
349-
contents = output.getvalue()
350-
graph.draw_image(data=contents, location=(0, height))
351-
352-
event, values = window.read(timeout=1)
353-
if event == sg.WIN_CLOSED:
354-
break
355-
window.close()
356-
357-
358291
def flashFromFile(file, bl: dai.DeviceBootloader):
359292
try:
360293
if str(file)[-3:] == "dap":
@@ -418,6 +351,16 @@ def deviceStateTxt(state: dai.XLinkDeviceState) -> str:
418351
sg.Text("Device state:", size=(30, 1), font=('Arial', 10, 'bold'), text_color="black")
419352
],
420353
[sg.Text("-name-", key="devName", size=(30, 1)), sg.VSeparator(), sg.Text("-state-", key="devState", size=(30, 1))],
354+
[
355+
sg.Text("Bootloader type:", size=(30, 1), font=('Arial', 10, 'bold'), text_color="black"),
356+
sg.VSeparator(),
357+
sg.Text("IP Assignment:", size=(30, 1), font=('Arial', 10, 'bold'), text_color="black")
358+
],
359+
[
360+
sg.Text("-bootloader type-", key="bootloaderType", size=(30, 1)),
361+
sg.VSeparator(),
362+
sg.Text("-assignment-", key="ipassignment", size=(30, 1))
363+
],
421364
[
422365
sg.Text("Version of newest bootloader:", size=(30, 1), font=('Arial', 10, 'bold'), text_color="black"),
423366
sg.VSeparator(),
@@ -521,11 +464,6 @@ def deviceStateTxt(state: dai.XLinkDeviceState) -> str:
521464
sg.Button("Remove application", size=(15, 2), font=('Arial', 10, 'bold'), disabled=True,
522465
button_color='#FFA500'),
523466
],
524-
[sg.HSeparator()],
525-
[
526-
sg.Button("Open device streaming application", size=(15, 2), font=('Arial', 10, 'bold'), disabled=True,
527-
button_color='#FFA500', key="startStreamingApp"),
528-
],
529467
]
530468

531469

@@ -756,12 +694,6 @@ def run(self) -> None:
756694
self.window.Element('mask').update('')
757695
self.window.Element('gateway').update('')
758696

759-
elif event == "startStreamingApp":
760-
# We will reconnect, as we need to set allowFlashingBootloader to True
761-
self.closeDevice()
762-
connectAndStartStreaming(self.device)
763-
self.resetGui()
764-
self.getDevices()
765697

766698
self.window.close()
767699

@@ -837,7 +769,14 @@ def getConfigs(self):
837769
self.window.Element('currBoot').update('Not Flashed')
838770
else:
839771
self.window.Element('currBoot').update(self.bl.getVersion())
840-
772+
if deviceStateTxt(device.state) == "UNBOOTED":
773+
self.window.Element('bootloaderType').update('N/A')
774+
else:
775+
self.window.Element('bootloaderType').update(str(self.bl.getType()).split('.')[1])
776+
if self.isPoE():
777+
self.window.Element('ipassignment').update("Static" if conf.isStaticIPV4() else "Dynamic")
778+
else:
779+
self.window.Element('ipassignment').update("N/A")
841780
self.window.Element('version').update(dai.__version__)
842781
self.window.Element('commit').update(dai.__commit__)
843782
self.window.Element('devState').update(deviceStateTxt(self.device.state))
@@ -868,7 +807,6 @@ def unlockConfig(self):
868807

869808
self.window['Flash application'].update(disabled=False)
870809
self.window['Remove application'].update(disabled=False)
871-
self.window['startStreamingApp'].update(disabled=False)
872810

873811
self.window['recoveryMode'].update(disabled=False)
874812

@@ -892,7 +830,6 @@ def resetGui(self):
892830
self.window['Factory reset'].update(disabled=True)
893831
self.window['Flash application'].update(disabled=True)
894832
self.window['Remove application'].update(disabled=True)
895-
self.window['startStreamingApp'].update(disabled=True)
896833

897834
self.window['recoveryMode'].update(disabled=True)
898835

@@ -927,6 +864,7 @@ def getDevices(self):
927864
else:
928865
for deviceInfo in deviceInfos:
929866
deviceTxt = deviceInfo.getDeviceId()
867+
if "X_LINK_GATE" == deviceInfo.state.name: continue # Skip RVC4 devices
930868
listedDevices.append(deviceTxt)
931869
self.devices[deviceTxt] = deviceInfo
932870

utilities/requirements.txt

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
PySimpleGUI==4.60.3
2-
Pillow==9.3.0
1+
Pillow==10.4.0
32
psutil==5.9.3
4-
jinja2==3.0.3
5-
numpy>=1.21.4 # For RPi Buster (last successful build) and macOS M1 (first build). But allow for higher versions, to support Python3.11 (not available in 1.21.4 yet)
6-
opencv-contrib-python==4.5.5.62 # Last successful RPi build, also covers M1 with above pinned numpy (otherwise 4.6.0.62 would be required, but that has a bug with charuco boards). Python version not important, abi3 wheels
3+
numpy>=2 # For RPi Buster (last successful build) and macOS M1 (first build). But allow for higher versions, to support Python3.11 (not available in 1.21.4 yet). Likely won't work with numpy 3.x when it comes out.
4+
opencv-contrib-python==4.12.0.88 # Last successful RPi build, also covers M1 with above pinned numpy (otherwise 4.6.0.62 would be required, but that has a bug with charuco boards). Python version not important, abi3 wheels
75
pyqt5>5,<5.15.6 ; platform_machine != "armv6l" and platform_machine != "armv7l" and platform_machine != "aarch64" and platform_machine != "arm64"
8-
--extra-index-url https://artifacts.luxonis.com/artifactory/luxonis-python-snapshot-local/
6+
# Latest version (note - it's yanked)
7+
PySimpleGUI-4-foss==4.60.4.1 # Mirror of final open-source release.

0 commit comments

Comments
 (0)