Per your suggestion, we added pipeline.getDefaultDevice().setIrLaserDotProjectorIntensity(1)
and pipeline.getDefaultDevice().setIrFloodLightIntensity(1)
to our script, but the results are the same. We also piped out the left mono image, and we could not see any dots. The following is our script if it helps:
#!/usr/bin/env python3
import cv2
import depthai as dai
import numpy as np
color = (125, 73, 219)
# Create pipeline
pipeline = dai.Pipeline()
# Config
topLeft = dai.Point2f(0.4, 0.4)
bottomRight = dai.Point2f(0.41, 0.42)
# Define sources and outputs
monoLeft = pipeline.create(dai.node.Camera).build(dai.CameraBoardSocket.CAM_B)
monoRight = pipeline.create(dai.node.Camera).build(dai.CameraBoardSocket.CAM_C)
stereo = pipeline.create(dai.node.StereoDepth)
spatialLocationCalculator = pipeline.create(dai.node.SpatialLocationCalculator)
# Linking
monoLeftOut = monoLeft.requestOutput((640, 400))
monoRightOut = monoRight.requestOutput((640, 400))
monoLeftOut.link(stereo.left)
monoRightOut.link(stereo.right)
mono_left_q = monoLeftOut.createOutputQueue()
stereo.setRectification(True)
stereo.setExtendedDisparity(True)
stepSize = 0.02
config = dai.SpatialLocationCalculatorConfigData()
config.depthThresholds.lowerThreshold = 10
config.depthThresholds.upperThreshold = 20000
calculationAlgorithm = dai.SpatialLocationCalculatorAlgorithm.MEDIAN
config.roi = dai.Rect(topLeft, bottomRight)
spatialLocationCalculator.inputConfig.setWaitForMessage(False)
spatialLocationCalculator.initialConfig.addROI(config)
xoutSpatialQueue = spatialLocationCalculator.out.createOutputQueue()
outputDepthQueue = spatialLocationCalculator.passthroughDepth.createOutputQueue()
stereo.depth.link(spatialLocationCalculator.inputDepth)
inputConfigQueue = spatialLocationCalculator.inputConfig.createInputQueue()
pipeline.getDefaultDevice().setIrLaserDotProjectorIntensity(1)
pipeline.getDefaultDevice().setIrFloodLightIntensity(1)
with pipeline:
pipeline.start()
while pipeline.isRunning():
spatialData = xoutSpatialQueue.get().getSpatialLocations()
mono_left_frame = mono_left_q.get().getCvFrame()
#print("Use WASD keys to move ROI!")
outputDepthIMage : dai.ImgFrame = outputDepthQueue.get()
frameDepth = outputDepthIMage.getCvFrame()
frameDepth = outputDepthIMage.getFrame()
print("Median depth value: ", np.median(frameDepth))
depthFrameColor = cv2.normalize(frameDepth, None, 255, 0, cv2.NORM_INF, cv2.CV_8UC1)
depthFrameColor = cv2.equalizeHist(depthFrameColor)
# depthFrameColor = cv2.applyColorMap(depthFrameColor, cv2.COLORMAP_HOT)
for depthData in spatialData:
roi = depthData.config.roi
roi = roi.denormalize(width=depthFrameColor.shape[1], height=depthFrameColor.shape[0])
xmin = int(roi.topLeft().x)
ymin = int(roi.topLeft().y)
xmax = int(roi.bottomRight().x)
ymax = int(roi.bottomRight().y)
depthMin = depthData.depthMin
depthMax = depthData.depthMax
fontType = cv2.FONT_HERSHEY_TRIPLEX
xminw = xmin - 20
if xminw >= depthFrameColor.shape[1]:
xminw -= 30
cv2.rectangle(depthFrameColor, (xmin, ymin), (xmax, ymax), color, cv2.FONT_HERSHEY_SCRIPT_SIMPLEX)
cv2.putText(depthFrameColor, f"X: {int(depthData.spatialCoordinates.x)} mm", (xminw, ymin + 20), fontType, 0.5, color)
cv2.putText(depthFrameColor, f"Y: {int(depthData.spatialCoordinates.y)} mm", (xminw, ymin + 35), fontType, 0.5, color)
cv2.putText(depthFrameColor, f"Z: {int(depthData.spatialCoordinates.z)} mm", (xminw, ymin + 50), fontType, 0.5, color)
# Show the frame
cv2.imshow("depth", depthFrameColor)
cv2.imshow("monoleft", mono_left_frame)
key = cv2.waitKey(1)
if key == ord('q'):
pipeline.stop()
break
stepSize = 0.01
newConfig = False
if key == ord('q'):
break
elif key == ord('w'):
if topLeft.y - stepSize >= 0:
topLeft.y -= stepSize
bottomRight.y -= stepSize
newConfig = True
elif key == ord('a'):
if topLeft.x - stepSize >= 0:
topLeft.x -= stepSize
bottomRight.x -= stepSize
newConfig = True
elif key == ord('s'):
if bottomRight.y + stepSize <= 1:
topLeft.y += stepSize
bottomRight.y += stepSize
newConfig = True
elif key == ord('d'):
if bottomRight.x + stepSize <= 1:
topLeft.x += stepSize
bottomRight.x += stepSize
newConfig = True
elif key == ord('1'):
calculationAlgorithm = dai.SpatialLocationCalculatorAlgorithm.MEAN
print('Switching calculation algorithm to MEAN!')
newConfig = True
elif key == ord('2'):
calculationAlgorithm = dai.SpatialLocationCalculatorAlgorithm.MIN
print('Switching calculation algorithm to MIN!')
newConfig = True
elif key == ord('3'):
calculationAlgorithm = dai.SpatialLocationCalculatorAlgorithm.MAX
print('Switching calculation algorithm to MAX!')
newConfig = True
elif key == ord('4'):
calculationAlgorithm = dai.SpatialLocationCalculatorAlgorithm.MODE
print('Switching calculation algorithm to MODE!')
newConfig = True
elif key == ord('5'):
calculationAlgorithm = dai.SpatialLocationCalculatorAlgorithm.MEDIAN
print('Switching calculation algorithm to MEDIAN!')
newConfig = True
if newConfig:
config.roi = dai.Rect(topLeft, bottomRight)
config.calculationAlgorithm = calculationAlgorithm
cfg = dai.SpatialLocationCalculatorConfig()
cfg.addROI(config)
inputConfigQueue.send(cfg)
newConfig = False