Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set lens position from calibration data #599

Merged
merged 2 commits into from
Jun 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion examples/Script/script_forward_frames.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
pipeline = dai.Pipeline()

cam = pipeline.create(dai.node.ColorCamera)
cam.initialControl.setManualFocus(130)
# Not needed, you can display 1080P frames as well
cam.setIspScale(1,2)

Expand Down
2 changes: 1 addition & 1 deletion examples/SpatialDetection/spatial_tiny_yolo.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@

stereo.depth.link(spatialDetectionNetwork.inputDepth)
spatialDetectionNetwork.passthroughDepth.link(xoutDepth.input)
spatialDetectionNetwork.outNetwork.link(nnNetworkOut.input);
spatialDetectionNetwork.outNetwork.link(nnNetworkOut.input)

# Connect to device and start pipeline
with dai.Device(pipeline) as device:
Expand Down
13 changes: 10 additions & 3 deletions examples/StereoDepth/rgb_depth_aligned.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ def updateBlendWeights(percent_rgb):

# Create pipeline
pipeline = dai.Pipeline()
device = dai.Device()
queueNames = []

# Define sources and outputs
Expand All @@ -53,8 +54,13 @@ def updateBlendWeights(percent_rgb):
if downscaleColor: camRgb.setIspScale(2, 3)
# For now, RGB needs fixed focus to properly align with depth.
# This value was used during calibration
camRgb.initialControl.setManualFocus(130)

try:
calibData = device.readCalibration()
lensPosition = calibData.getLensPosition(dai.CameraBoardSocket.RGB)
if lensPosition:
camRgb.initialControl.setManualFocus(lensPosition)
except:
raise
left.setResolution(monoResolution)
left.setBoardSocket(dai.CameraBoardSocket.LEFT)
left.setFps(fps)
Expand All @@ -74,7 +80,8 @@ def updateBlendWeights(percent_rgb):
stereo.disparity.link(disparityOut.input)

# Connect to device and start pipeline
with dai.Device(pipeline) as device:
with device:
device.startPipeline(pipeline)

frameRgb = None
frameDisp = None
Expand Down
12 changes: 10 additions & 2 deletions examples/StereoDepth/rgb_depth_confidence_aligned.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ def updateConfBlendWeights(percent):

# Create pipeline
pipeline = dai.Pipeline()
device = dai.Device()
queueNames = []

# Define sources and outputs
Expand All @@ -73,7 +74,13 @@ def updateConfBlendWeights(percent):
if downscaleColor: camRgb.setIspScale(2, 3)
# For now, RGB needs fixed focus to properly align with depth.
# This value was used during calibration
camRgb.initialControl.setManualFocus(130)
try:
calibData = device.readCalibration()
lensPosition = calibData.getLensPosition(dai.CameraBoardSocket.RGB)
if lensPosition:
camRgb.initialControl.setManualFocus(lensPosition)
except:
raise

left.setResolution(monoResolution)
left.setBoardSocket(dai.CameraBoardSocket.LEFT)
Expand All @@ -99,7 +106,8 @@ def updateConfBlendWeights(percent):
stereo.confidenceMap.link(xoutConfMap.input)

# Connect to device and start pipeline
with dai.Device(pipeline) as device:
with device:
device.startPipeline(pipeline)

frameRgb = None
frameDisp = None
Expand Down
7 changes: 5 additions & 2 deletions examples/StereoDepth/stereo_depth_video.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,8 @@ def getDisparityFrame(frame):
if depth:
streams.append("depth")

calibData = dai.Device().readCalibration()
device = dai.Device()
calibData = device.readCalibration()
leftMesh, rightMesh = getMesh(calibData)
if generateMesh:
meshLeft = list(leftMesh.tobytes())
Expand All @@ -245,7 +246,9 @@ def getDisparityFrame(frame):


print("Creating DepthAI device")
with dai.Device(pipeline) as device:
with device:
device.startPipeline(pipeline)

# Create a receive queue for each stream
qList = [device.getOutputQueue(stream, 8, blocking=False) for stream in streams]

Expand Down