Skip to content
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
File renamed without changes.
File renamed without changes.
File renamed without changes.
16 changes: 5 additions & 11 deletions examples/ImageAlign/image_align.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

RGB_SOCKET = dai.CameraBoardSocket.CAM_A
LEFT_SOCKET = dai.CameraBoardSocket.CAM_B
RIGHT_SOCKET = dai.CameraBoardSocket.CAM_C
ALIGN_SOCKET = LEFT_SOCKET

COLOR_RESOLUTION = dai.ColorCameraProperties.SensorResolution.THE_1080_P
Expand All @@ -19,7 +18,6 @@
# Define sources and outputs
camRgb = pipeline.create(dai.node.ColorCamera)
left = pipeline.create(dai.node.MonoCamera)
right = pipeline.create(dai.node.MonoCamera)
sync = pipeline.create(dai.node.Sync)
out = pipeline.create(dai.node.XLinkOut)
align = pipeline.create(dai.node.ImageAlign)
Expand All @@ -29,10 +27,6 @@
left.setBoardSocket(LEFT_SOCKET)
left.setFps(FPS)

right.setResolution(LEFT_RIGHT_RESOLUTION)
right.setBoardSocket(RIGHT_SOCKET)
right.setFps(FPS)

camRgb.setBoardSocket(RGB_SOCKET)
camRgb.setResolution(COLOR_RESOLUTION)
camRgb.setFps(FPS)
Expand All @@ -57,19 +51,19 @@


rgbWeight = 0.4
depthWeight = 0.6
leftWeight = 0.6


def updateBlendWeights(percentRgb):
"""
Update the rgb and depth weights used to blend depth/rgb image
Update the rgb and left weights used to blend rgb/left image

@param[in] percent_rgb The rgb weight expressed as a percentage (0..100)
"""
global depthWeight
global leftWeight
global rgbWeight
rgbWeight = float(percentRgb) / 100.0
depthWeight = 1.0 - rgbWeight
leftWeight = 1.0 - rgbWeight

def updateDepthPlane(depth):
global staticDepthPlane
Expand Down Expand Up @@ -118,7 +112,7 @@ def updateDepthPlane(depth):
if leftCv.shape != frameRgbCv.shape:
leftCv = cv2.resize(leftCv, (frameRgbCv.shape[1], frameRgbCv.shape[0]))

blended = cv2.addWeighted(frameRgbCv, rgbWeight, leftCv, depthWeight, 0)
blended = cv2.addWeighted(frameRgbCv, rgbWeight, leftCv, leftWeight, 0)
cv2.imshow(windowName, blended)

key = cv2.waitKey(1)
Expand Down