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

Enhance stereo depth develop merge #190

Merged
merged 62 commits into from
Sep 15, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
62 commits
Select commit Hold shift + click to select a range
79db9fe
Add depth options: median_kernel_size and lr_check
alex-luxonis Aug 14, 2020
d1a6e11
Update FW and Linux x64 lib
alex-luxonis Aug 14, 2020
a57ae71
Add frame metadata for disparity, disparity_color, depth_raw
alex-luxonis Aug 19, 2020
7b24161
Merge branch 'metadata_disparity_depth' into enhance_stereo_depth
alex-luxonis Aug 19, 2020
683094f
Update firmware and Linux_x64 python lib
alex-luxonis Aug 19, 2020
c400a6d
Add `-vv / --verbose` option, will print some metadata fields
alex-luxonis Aug 19, 2020
ab32271
added mesh files
saching13 Aug 31, 2020
8bf72d2
Add rectified_left and rectified_right stream choices
alex-luxonis Aug 31, 2020
0a50da4
Add config options for Stereo Rectification / Warp:
alex-luxonis Aug 31, 2020
35ad5bc
updated with pcl
saching13 Aug 31, 2020
68bbcf7
Update FW and Linux64 lib
alex-luxonis Aug 31, 2020
aa7bf7d
calibration_utils: save new format to out_filepath var (not string)
alex-luxonis Sep 1, 2020
9721111
Save new format (H1,H2,M1,M2,R,T) as fp32 (was double)
alex-luxonis Sep 1, 2020
17634ab
Allow using the new calib with two homographies
alex-luxonis Sep 1, 2020
ac10502
Update FW and Linux64 lib
alex-luxonis Sep 1, 2020
8f307a4
Create bw1092.json
Luxonis-Brian Sep 4, 2020
36205df
added mesh and point cloud argument
saching13 Sep 4, 2020
1de7911
order of calibration binary updated
saching13 Sep 4, 2020
e4c9837
saving right camera intrinsics on the host
saching13 Sep 4, 2020
ac48b4d
Rename bw1092.json to BW1092.json
Luxonis-Brian Sep 4, 2020
aaa06c4
Merge pull request #188 from luxonis/add-1092-brd-file
Luxonis-Brian Sep 4, 2020
b1f5274
Store the homography in 'H1,H2' order, and remove the swap done on de…
alex-luxonis Sep 4, 2020
2874e5c
updated pcl with rectified image
saching13 Sep 5, 2020
bf1f78e
New calib data stored in EEPROM and reported back to host.
alex-luxonis Sep 8, 2020
ac4b0e7
updated pcl to get intrinisc from api
saching13 Sep 8, 2020
85d055f
updated submodule
saching13 Sep 8, 2020
ed66f7f
Rebuild Linux64 lib
alex-luxonis Sep 8, 2020
952bc80
removing local file
saching13 Sep 10, 2020
1622d8e
removing local file
saching13 Sep 10, 2020
cbff62f
Update FW: -fix a crash when both RGB and Mono are enabled,
alex-luxonis Sep 10, 2020
f9c29ea
fixed H1_f32 bug in calibration
saching13 Sep 10, 2020
8063dba
Merge remote-tracking branch 'origin/develop' into HEAD
SzabolcsGergely Sep 10, 2020
29800ba
Merge remote-tracking branch 'origin/enhance_stereo_depth' into enhan…
SzabolcsGergely Sep 10, 2020
0729413
Updated depthai library
themarpe Sep 10, 2020
634c5ca
Merge remote-tracking branch 'origin/main' into HEAD
SzabolcsGergely Sep 10, 2020
4bc8019
Add package from artifactory to requirements
SzabolcsGergely Sep 10, 2020
57e24b7
Disable temporarily left-right check option for SGBM
SzabolcsGergely Sep 10, 2020
5c2466f
Add back missing config fields after merge
SzabolcsGergely Sep 10, 2020
e8ba09e
Disable left-right check SGBM option (WIP)
SzabolcsGergely Sep 10, 2020
662fa66
fixed point cloud visualization
saching13 Sep 11, 2020
5ed9b43
removed local intrinsic.json save
saching13 Sep 11, 2020
86d1c11
updated calibration storage in EEPROM
saching13 Sep 11, 2020
6aee211
Update requirements.txt with updated backend
SzabolcsGergely Sep 13, 2020
7e58cc4
Fix runtime error of get_translation
SzabolcsGergely Sep 13, 2020
2e8271c
recreated cv map creation.
saching13 Sep 14, 2020
9f66aa6
modified calibration_utils
saching13 Sep 14, 2020
009c371
Change mono cam resolution for calibration to 1280x800
alex-luxonis Sep 14, 2020
6d04536
Save R1/R2 in calib file (instead of inv H1/H2)
alex-luxonis Sep 14, 2020
66efb9d
RGB calib is just a placeholder for now, store M3 intrinsic as zero
alex-luxonis Sep 14, 2020
b3b5eb6
Store RGB distortion too in calib file
alex-luxonis Sep 14, 2020
4e63648
calibration_utils: debug code, disabled for now
alex-luxonis Sep 14, 2020
7b63aa4
Update depthai wheel in requirements.txt
alex-luxonis Sep 14, 2020
ea96b20
some extra modifications in calibrate_utils and local mesh creation
saching13 Sep 15, 2020
1199486
fixed merge conflicts
saching13 Sep 15, 2020
87334ad
Fix paths to depthai_demo.py in integration_test/repeat_test
alex-luxonis Sep 15, 2020
fd26e51
Fix also the depthai_demo.py file name in depthai_supervisor
alex-luxonis Sep 15, 2020
95b1285
added new whl built commit to requirements
saching13 Sep 15, 2020
6c9ec15
Fix more references to the now renamed depthai.py
alex-luxonis Sep 15, 2020
a43b3ba
Fix the mirrored_rectified command line option.
alex-luxonis Sep 15, 2020
79a010d
Merge remote-tracking branch 'origin/develop' into HEAD
SzabolcsGergely Sep 15, 2020
ee88aff
Update depthai wheel: rectified L/R swapping corrected
alex-luxonis Sep 15, 2020
f608901
Remove no longer needed file
alex-luxonis Sep 15, 2020
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
8 changes: 7 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,22 @@ share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
*darwin.so
MANIFEST

*.idea
# DepthAI-Specific
dataset/
depthai.calib
mesh_left.calib
mesh_right.calib
intrinsic.json
intrinsic_calib_m2

*.h264
*.h265
*.mkv
*.mp4
*.blob.sh*cmx*
*.cmd
*.mvcmd
*.so
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ python3 -m pip install -r requirements.txt
Optional:
For command line autocomplete when pressing TAB, only bash interpreter supported now:
Add to .bashrc:
`echo 'eval "$(register-python-argcomplete depthai.py)"' >> ~/.bashrc`
`echo 'eval "$(register-python-argcomplete depthai_demo.py)"' >> ~/.bashrc`

If you use any other interpreter: https://kislyuk.github.io/argcomplete/

Expand Down
2 changes: 1 addition & 1 deletion calibrate.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ def __init__(self):
'mono':
{
# 1280x720, 1280x800, 640x400 (binning enabled)
'resolution_h': 720,
'resolution_h': 800,
'fps': 30.0,
},
},
Expand Down
2 changes: 1 addition & 1 deletion calibrate_and_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def cleanup():
args+="'"+arg+"' "

calibrate_cmd = "python3 calibrate.py " + args
test_cmd = """python3 depthai-demo.py -co '{"streams": [{"name": "depth_raw", "max_fps": 12.0}]}'"""
test_cmd = """python3 depthai_demo.py -co '{"streams": [{"name": "depth_raw", "max_fps": 12.0}]}'"""


atexit.register(cleanup)
Expand Down
8 changes: 8 additions & 0 deletions consts/resource_paths.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,14 @@ def relative_to_abs_path(relative_path):
device_usb2_cmd_fpath = relative_to_abs_path('../depthai_usb2.cmd')
boards_dir_path = relative_to_abs_path('../resources/boards') + "/"
custom_calib_fpath = relative_to_abs_path('../resources/depthai.calib')
left_mesh_fpath = relative_to_abs_path('../resources/mesh_left.calib')
right_mesh_fpath = relative_to_abs_path('../resources/mesh_right.calib')

right_map_x_fpath = relative_to_abs_path('../resources/map_x_right.calib')
right_map_y_fpath = relative_to_abs_path('../resources/map_y_right.calib')
left_map_x_fpath = relative_to_abs_path('../resources/map_x_left.calib')
left_map_y_fpath = relative_to_abs_path('../resources/map_y_left.calib')

nn_resource_path = relative_to_abs_path('../resources/nn')+"/"
blob_fpath = relative_to_abs_path('../resources/nn/mobilenet-ssd/mobilenet-ssd.blob')
blob_config_fpath = relative_to_abs_path('../resources/nn/mobilenet-ssd/mobilenet-ssd.json')
Expand Down
32 changes: 31 additions & 1 deletion depthai_demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

from depthai_helpers.config_manager import DepthConfigManager
from depthai_helpers.arg_manager import CliArgs
from depthai_helpers.projector_3d import PointCloudVisualizer

from depthai_helpers.object_tracker_handler import show_tracklets

Expand Down Expand Up @@ -126,6 +127,18 @@ def startLoop(self):

self.reset_process_wd()

time_start = time()
def print_packet_info(packet):
meta = packet.getMetadata()
print("[{:.6f} {:15s}]".format(time()-time_start, packet.stream_name), end='')
if meta is not None:
print(" {:.6f}".format(meta.getTimestamp()), meta.getSequenceNum(), end='')
if not (packet.stream_name.startswith('disparity')
or packet.stream_name.startswith('depth')):
print('', meta.getCameraName(), end='')
print()
return

for stream in stream_names:
if stream in ["disparity", "disparity_color", "depth_raw"]:
cv2.namedWindow(stream)
Expand All @@ -134,6 +147,10 @@ def startLoop(self):
conf_thr_slider_max = 255
cv2.createTrackbar(trackbar_name, stream, conf_thr_slider_min, conf_thr_slider_max, self.on_trackbar_change)
cv2.setTrackbarPos(trackbar_name, stream, args['disparity_confidence_threshold'])

right_rectified = None
pcl_not_set = True

ops = 0
prevTime = time()
while self.runThread:
Expand All @@ -158,6 +175,8 @@ def startLoop(self):
os._exit(10)

for _, nnet_packet in enumerate(self.nnet_packets):
if args['verbose']: print_packet_info(nnet_packet)

meta = nnet_packet.getMetadata()
camera = 'rgb'
if meta != None:
Expand All @@ -171,6 +190,7 @@ def startLoop(self):
window_name = packet.stream_name
if packet.stream_name not in stream_names:
continue # skip streams that were automatically added
if args['verbose']: print_packet_info(packet)
packetData = packet.getData()
if packetData is None:
print('Invalid packet data!')
Expand All @@ -195,8 +215,10 @@ def startLoop(self):
cv2.putText(nn_frame, "fps: " + str(frame_count_prev[window_name]), (25, 50), cv2.FONT_HERSHEY_SIMPLEX, 1.0, (0, 0, 0))
cv2.putText(nn_frame, "NN fps: " + str(frame_count_prev['nn'][camera]), (2, frame.shape[0]-4), cv2.FONT_HERSHEY_SIMPLEX, 0.4, (0, 255, 0))
cv2.imshow(window_name, nn_frame)
elif packet.stream_name == 'left' or packet.stream_name == 'right' or packet.stream_name == 'disparity':
elif packet.stream_name in ['left', 'right', 'disparity', 'rectified_left', 'rectified_right']:
frame_bgr = packetData
if args['pointcloud'] and packet.stream_name == 'rectified_right':
right_rectified = packetData
cv2.putText(frame_bgr, packet.stream_name, (25, 25), cv2.FONT_HERSHEY_SIMPLEX, 1.0, (0, 0, 0))
cv2.putText(frame_bgr, "fps: " + str(frame_count_prev[window_name]), (25, 50), cv2.FONT_HERSHEY_SIMPLEX, 1.0, (0, 0, 0))
if args['draw_bb_depth']:
Expand All @@ -216,6 +238,14 @@ def startLoop(self):
cv2.putText(frame, packet.stream_name, (25, 25), cv2.FONT_HERSHEY_SIMPLEX, 1.0, (0, 0, 255))
cv2.putText(frame, "fps: " + str(frame_count_prev[window_name]), (25, 50), cv2.FONT_HERSHEY_SIMPLEX, 1.0, (0, 0, 255))
else: # uint16
if args['pointcloud'] and "depth_raw" in stream_names and "rectified_right" in stream_names and right_rectified is not None:
if pcl_not_set:
pcl_converter = PointCloudVisualizer(self.device.get_right_intrinsic(), 1280, 720)
pcl_not_set = False
right_rectified = cv2.flip(right_rectified, 1)
pcd = pcl_converter.rgbd_to_projection(frame, right_rectified)
pcl_converter.visualize_pcd()

frame = (65535 // frame).astype(np.uint8)
#colorize depth map, comment out code below to obtain grayscale
frame = cv2.applyColorMap(frame, cv2.COLORMAP_HOT)
Expand Down
19 changes: 18 additions & 1 deletion depthai_helpers/arg_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ def _get_immediate_subdirectories(a_dir):
return [name for name in os.listdir(a_dir)
if os.path.isdir(os.path.join(a_dir, name))]

_stream_choices = ("metaout", "previewout", "jpegout", "left", "right", "depth_raw", "disparity", "disparity_color", "meta_d2h", "object_tracker", "color")
_stream_choices = ("metaout", "previewout", "jpegout", "left", "right", "depth_raw", "disparity", "disparity_color",
"meta_d2h", "object_tracker", "rectified_left", "rectified_right", "color")
_CNN_choices = _get_immediate_subdirectories(consts.resource_paths.nn_resource_path)

def _stream_type(option):
Expand Down Expand Up @@ -104,6 +105,11 @@ def parse_args(self):
choices=range(0,256), metavar="[0-255]",
help="Disparity_confidence_threshold.")

parser.add_argument("-med", "--stereo_median_size", default=7, type=int, choices=[0, 3, 5, 7],
help="Disparity / depth median filter kernel size (N x N) . 0 = filtering disabled. Default: %(default)s")

parser.add_argument("-lrc", "--stereo_lr_check", default=False, action="store_true",
help="Enable stereo 'Left-Right check' feature.")
parser.add_argument("-fv", "--field-of-view", default=None, type=float,
help="Horizontal field of view (HFOV) for the stereo cameras in [deg]. Default: 71.86deg.")

Expand Down Expand Up @@ -157,6 +163,8 @@ def parse_args(self):
parser.add_argument("-sync", "--sync-video-meta", default=False, action="store_true",
help="Synchronize 'previewout' and 'metaout' streams")

parser.add_argument("-vv", "--verbose", default=False, action="store_true",
help="Verbose, print info about received packets.")
parser.add_argument("-s", "--streams",
nargs="+",
type=_stream_type,
Expand All @@ -171,6 +179,15 @@ def parse_args(self):
parser.add_argument("-v", "--video", default=None, type=str, required=False,
help="Path where to save video stream (existing file will be overwritten)")

parser.add_argument("-pcl", "--pointcloud", default=False, action="store_true",
help="Convert Depth map image to point clouds")

parser.add_argument("-mesh", "--use_mesh", default=False, action="store_true",
help="use mesh for rectification of the stereo images")

parser.add_argument("-mirror_rectified", "--mirror_rectified", default='true', choices=['true', 'false'],
help="Normally, rectified_left/_right are mirrored for Stereo engine constraints. "
"If false, disparity/depth will be mirrored instead. Default: true")
argcomplete.autocomplete(parser)

options = parser.parse_args()
Expand Down
Loading