3
3
import cv2
4
4
import numpy as np
5
5
import depthai as dai
6
+ import argparse
6
7
7
8
# Weights to use when blending depth/rgb image (should equal 1.0)
8
9
rgbWeight = 0.4
9
10
depthWeight = 0.6
10
11
12
+ parser = argparse .ArgumentParser ()
13
+ parser .add_argument ('-alpha' , type = float , default = None , help = "Alpha scaling parameter to increase float. [0,1] valid interval." )
14
+ args = parser .parse_args ()
15
+ alpha = args .alpha
11
16
12
17
def updateBlendWeights (percent_rgb ):
13
18
"""
@@ -21,9 +26,6 @@ def updateBlendWeights(percent_rgb):
21
26
depthWeight = 1.0 - rgbWeight
22
27
23
28
24
- # Optional. If set (True), the ColorCamera is downscaled from 1080p to 720p.
25
- # Otherwise (False), the aligned depth is automatically upscaled to 1080p
26
- downscaleColor = True
27
29
fps = 30
28
30
# The disparity is computed at this resolution, then upscaled to RGB resolution
29
31
monoResolution = dai .MonoCameraProperties .SensorResolution .THE_720_P
@@ -34,7 +36,7 @@ def updateBlendWeights(percent_rgb):
34
36
queueNames = []
35
37
36
38
# Define sources and outputs
37
- camRgb = pipeline .create (dai .node .ColorCamera )
39
+ camRgb = pipeline .create (dai .node .Camera )
38
40
left = pipeline .create (dai .node .MonoCamera )
39
41
right = pipeline .create (dai .node .MonoCamera )
40
42
stereo = pipeline .create (dai .node .StereoDepth )
@@ -48,15 +50,17 @@ def updateBlendWeights(percent_rgb):
48
50
queueNames .append ("disp" )
49
51
50
52
#Properties
51
- camRgb .setBoardSocket (dai .CameraBoardSocket .CAM_A )
52
- camRgb .setResolution (dai .ColorCameraProperties .SensorResolution .THE_1080_P )
53
+ rgbCamSocket = dai .CameraBoardSocket .CAM_A
54
+
55
+ camRgb .setBoardSocket (rgbCamSocket )
56
+ camRgb .setSize (1280 , 720 )
53
57
camRgb .setFps (fps )
54
- if downscaleColor : camRgb . setIspScale ( 2 , 3 )
58
+
55
59
# For now, RGB needs fixed focus to properly align with depth.
56
60
# This value was used during calibration
57
61
try :
58
62
calibData = device .readCalibration2 ()
59
- lensPosition = calibData .getLensPosition (dai . CameraBoardSocket . CAM_A )
63
+ lensPosition = calibData .getLensPosition (rgbCamSocket )
60
64
if lensPosition :
61
65
camRgb .initialControl .setManualFocus (lensPosition )
62
66
except :
@@ -71,14 +75,19 @@ def updateBlendWeights(percent_rgb):
71
75
stereo .setDefaultProfilePreset (dai .node .StereoDepth .PresetMode .HIGH_DENSITY )
72
76
# LR-check is required for depth alignment
73
77
stereo .setLeftRightCheck (True )
74
- stereo .setDepthAlign (dai . CameraBoardSocket . CAM_A )
78
+ stereo .setDepthAlign (rgbCamSocket )
75
79
76
80
# Linking
77
- camRgb .isp .link (rgbOut .input )
81
+ camRgb .video .link (rgbOut .input )
78
82
left .out .link (stereo .left )
79
83
right .out .link (stereo .right )
80
84
stereo .disparity .link (disparityOut .input )
81
85
86
+ camRgb .setMeshSource (dai .CameraProperties .WarpMeshSource .CALIBRATION )
87
+ if alpha is not None :
88
+ camRgb .setCalibrationAlpha (alpha )
89
+ stereo .setAlphaScaling (alpha )
90
+
82
91
# Connect to device and start pipeline
83
92
with device :
84
93
device .startPipeline (pipeline )
0 commit comments