Skip to content

Commit 57b437f

Browse files
committed
fixes & bump sdk version
1 parent 4fb6936 commit 57b437f

File tree

5 files changed

+99
-59
lines changed

5 files changed

+99
-59
lines changed

depthai_demo.py

Lines changed: 23 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -307,17 +307,14 @@ def run(self):
307307
if dai.CameraBoardSocket.LEFT in cameras and dai.CameraBoardSocket.RIGHT in cameras:
308308
self._pv.collectCalibData(self._device)
309309

310-
self._cameraConfig = {
310+
self._updateCameraConfigs({
311311
"exposure": self._conf.args.cameraExposure,
312312
"sensitivity": self._conf.args.cameraSensitivity,
313313
"saturation": self._conf.args.cameraSaturation,
314314
"contrast": self._conf.args.cameraContrast,
315315
"brightness": self._conf.args.cameraBrightness,
316316
"sharpness": self._conf.args.cameraSharpness
317-
}
318-
319-
if any(self._cameraConfig.values()):
320-
self._updateCameraConfigs()
317+
})
321318

322319
self._pv.createQueues(self._device, self._createQueueCallback)
323320
if self._encManager is not None:
@@ -478,22 +475,22 @@ def loop(self):
478475
def _createQueueCallback(self, queueName):
479476
if self._displayFrames and queueName in [Previews.disparityColor.name, Previews.disparity.name, Previews.depth.name, Previews.depthRaw.name]:
480477
Trackbars.createTrackbar('Disparity confidence', queueName, self.DISP_CONF_MIN, self.DISP_CONF_MAX, self._conf.args.disparityConfidenceThreshold,
481-
lambda value: self._pm.updateDepthConfig(self._device, dct=value))
478+
lambda value: self._pm.updateDepthConfig(dct=value))
482479
if queueName in [Previews.depthRaw.name, Previews.depth.name]:
483480
Trackbars.createTrackbar('Bilateral sigma', queueName, self.SIGMA_MIN, self.SIGMA_MAX, self._conf.args.sigma,
484-
lambda value: self._pm.updateDepthConfig(self._device, sigma=value))
481+
lambda value: self._pm.updateDepthConfig(sigma=value))
485482
if self._conf.args.stereoLrCheck:
486483
Trackbars.createTrackbar('LR-check threshold', queueName, self.LRCT_MIN, self.LRCT_MAX, self._conf.args.lrcThreshold,
487-
lambda value: self._pm.updateDepthConfig(self._device, lrcThreshold=value))
484+
lambda value: self._pm.updateDepthConfig(lrcThreshold=value))
488485
if self._device.getIrDrivers():
489486
Trackbars.createTrackbar('IR Laser Dot Projector [mA]', queueName, 0, 1200, self._conf.args.irDotBrightness,
490487
lambda value: self._device.setIrLaserDotProjectorBrightness(value))
491488
Trackbars.createTrackbar('IR Flood Illuminator [mA]', queueName, 0, 1500, self._conf.args.irFloodBrightness,
492489
lambda value: self._device.setIrFloodLightBrightness(value))
493490

494-
def _updateCameraConfigs(self):
491+
def _updateCameraConfigs(self, config):
495492
parsedConfig = {}
496-
for configOption, values in self._cameraConfig.items():
493+
for configOption, values in config.items():
497494
if values is not None:
498495
for cameraName, value in values:
499496
newConfig = {
@@ -507,13 +504,12 @@ def _updateCameraConfigs(self):
507504
else:
508505
parsedConfig[cameraName] = newConfig
509506

510-
if hasattr(self, "_device"):
511-
if self._conf.leftCameraEnabled and Previews.left.name in parsedConfig:
512-
self._pm.updateLeftCamConfig(self._device, **parsedConfig[Previews.left.name])
513-
if self._conf.rightCameraEnabled and Previews.right.name in parsedConfig:
514-
self._pm.updateRightCamConfig(self._device, **parsedConfig[Previews.right.name])
515-
if self._conf.rgbCameraEnabled and Previews.color.name in parsedConfig:
516-
self._pm.updateColorCamConfig(self._device, **parsedConfig[Previews.color.name])
507+
if self._conf.leftCameraEnabled and Previews.left.name in parsedConfig:
508+
self._pm.updateLeftCamConfig(**parsedConfig[Previews.left.name])
509+
if self._conf.rightCameraEnabled and Previews.right.name in parsedConfig:
510+
self._pm.updateRightCamConfig(**parsedConfig[Previews.right.name])
511+
if self._conf.rgbCameraEnabled and Previews.color.name in parsedConfig:
512+
self._pm.updateColorCamConfig(**parsedConfig[Previews.color.name])
517513

518514
def _showFramesCallback(self, frame, name):
519515
returnFrame = self.onShowFrame(frame, name)
@@ -795,7 +791,7 @@ def stopGui(self, *args, **kwargs):
795791
self.app.quit()
796792

797793
def guiOnDepthConfigUpdate(self, median=None, dct=None, sigma=None, lrcThreshold=None, irLaser=None, irFlood=None):
798-
self._demoInstance._pm.updateDepthConfig(self._demoInstance._device, median=median, dct=dct, sigma=sigma, lrcThreshold=lrcThreshold)
794+
self._demoInstance._pm.updateDepthConfig(median=median, dct=dct, sigma=sigma, lrcThreshold=lrcThreshold)
799795
if median is not None:
800796
if median == dai.MedianFilter.MEDIAN_OFF:
801797
self.updateArg("stereoMedianSize", 0, False)
@@ -819,32 +815,34 @@ def guiOnDepthConfigUpdate(self, median=None, dct=None, sigma=None, lrcThreshold
819815
self.updateArg("irFloodBrightness", irFlood, False)
820816

821817
def guiOnCameraConfigUpdate(self, name, exposure=None, sensitivity=None, saturation=None, contrast=None, brightness=None, sharpness=None):
818+
print(name)
819+
config = {}
822820
if exposure is not None:
823821
newValue = list(filter(lambda item: item[0] == name, (self.confManager.args.cameraExposure or []))) + [(name, exposure)]
824-
self._demoInstance._cameraConfig["exposure"] = newValue
822+
config["exposure"] = newValue
825823
self.updateArg("cameraExposure", newValue, False)
826824
if sensitivity is not None:
827825
newValue = list(filter(lambda item: item[0] == name, (self.confManager.args.cameraSensitivity or []))) + [(name, sensitivity)]
828-
self._demoInstance._cameraConfig["sensitivity"] = newValue
826+
config["sensitivity"] = newValue
829827
self.updateArg("cameraSensitivity", newValue, False)
830828
if saturation is not None:
831829
newValue = list(filter(lambda item: item[0] == name, (self.confManager.args.cameraSaturation or []))) + [(name, saturation)]
832-
self._demoInstance._cameraConfig["saturation"] = newValue
830+
config["saturation"] = newValue
833831
self.updateArg("cameraSaturation", newValue, False)
834832
if contrast is not None:
835833
newValue = list(filter(lambda item: item[0] == name, (self.confManager.args.cameraContrast or []))) + [(name, contrast)]
836-
self._demoInstance._cameraConfig["contrast"] = newValue
834+
config["contrast"] = newValue
837835
self.updateArg("cameraContrast", newValue, False)
838836
if brightness is not None:
839837
newValue = list(filter(lambda item: item[0] == name, (self.confManager.args.cameraBrightness or []))) + [(name, brightness)]
840-
self._demoInstance._cameraConfig["brightness"] = newValue
838+
config["brightness"] = newValue
841839
self.updateArg("cameraBrightness", newValue, False)
842840
if sharpness is not None:
843841
newValue = list(filter(lambda item: item[0] == name, (self.confManager.args.cameraSharpness or []))) + [(name, sharpness)]
844-
self._demoInstance._cameraConfig["sharpness"] = newValue
842+
config["sharpness"] = newValue
845843
self.updateArg("cameraSharpness", newValue, False)
846844

847-
self._demoInstance._updateCameraConfigs()
845+
self._demoInstance._updateCameraConfigs(config)
848846

849847
def guiOnDepthSetupUpdate(self, depthFrom=None, depthTo=None, subpixel=None, extended=None, lrc=None):
850848
if depthFrom is not None:

depthai_helpers/config_manager.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,11 @@ def getModelSource(self):
7171
return "color"
7272

7373
def irEnabled(self, device):
74-
drivers = device.getIrDrivers()
75-
return len(drivers) > 0
74+
try:
75+
drivers = device.getIrDrivers()
76+
return len(drivers) > 0
77+
except RuntimeError:
78+
return False
7679

7780
def getModelName(self):
7881
if self.args.cnnModel:

depthai_sdk/setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
setup(
99
name='depthai-sdk',
10-
version='1.1.6',
10+
version='1.1.7',
1111
description='This package contains convenience classes and functions that help in most common tasks while using DepthAI API',
1212
long_description=io.open("README.md", encoding="utf-8").read(),
1313
long_description_content_type="text/markdown",

0 commit comments

Comments
 (0)