Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
pointcloud = PointCloud()
i = 0
try:
while True:
time_start = time.time()
pointcloud.clear()
frames = pipeline.wait_for_frames()
aligned_frames = align.process(frames)
color_frame = aligned_frames.get_color_frame()
color_image = np.asanyarray(color_frame.get_data())
depth_frame = aligned_frames.get_depth_frame()
depth_frame = rs.decimation_filter(1).process(depth_frame)
depth_frame = rs.disparity_transform(True).process(depth_frame)
depth_frame = rs.spatial_filter().process(depth_frame)
depth_frame = rs.temporal_filter().process(depth_frame)
depth_frame = rs.disparity_transform(False).process(depth_frame)
# depth_frame = rs.hole_filling_filter().process(depth_frame)
depth_image = np.asanyarray(depth_frame.get_data())
color_image1 = cv2.cvtColor(color_image, cv2.COLOR_RGB2BGR)
cv2.namedWindow('color image', cv2.WINDOW_AUTOSIZE)
cv2.imshow('color image', cv2.cvtColor(color_image, cv2.COLOR_RGB2BGR))
cv2.namedWindow('depth image', cv2.WINDOW_AUTOSIZE)
cv2.imshow('depth image', depth_image )
depth = Image(depth_image)
z_min = None
z_max = None
x_min = None
x_max = None
while True:
dt0 = datetime.now()
frames = pipeline.wait_for_frames()
aligned_frames = align.process(frames)
color_frame = aligned_frames.get_color_frame()
color_image = np.asanyarray(color_frame.get_data())
depth_frame = aligned_frames.get_depth_frame()
depth_frame = rs.decimation_filter(1).process(depth_frame)
depth_frame = rs.disparity_transform(True).process(depth_frame)
depth_frame = rs.spatial_filter().process(depth_frame)
depth_frame = rs.temporal_filter().process(depth_frame)
depth_frame = rs.disparity_transform(False).process(depth_frame)
# depth_frame = rs.hole_filling_filter().process(depth_frame)
depth_image = np.asanyarray(depth_frame.get_data())
color_image1 = cv2.cvtColor(color_image, cv2.COLOR_RGB2BGR)
if plane_flag == 0:
chessboard_found1, corners1 = cv2.findChessboardCorners(color_image1, (9, 6))
corners = np.asanyarray(corners1).squeeze()
if chessboard_found1:
# cv2.drawChessboardCorners(color_image1,(9,6),corners1,chessboard_found1)
geometrie_added = False
vis = Visualizer()
#vis.create_window("Pointcloud",640,480)
vis.create_window("Pointcloud")
pointcloud = PointCloud()
i = 0
try:
while True:
dt0 = datetime.now()
frames = pipeline.wait_for_frames()
aligned_frames = align.process(frames)
color_frame = aligned_frames.get_color_frame()
color_image = np.asanyarray(color_frame.get_data())
depth_frame = aligned_frames.get_depth_frame()
depth_frame = rs.decimation_filter(1).process(depth_frame)
depth_frame = rs.disparity_transform(True).process(depth_frame)
depth_frame = rs.spatial_filter().process(depth_frame)
depth_frame = rs.temporal_filter().process(depth_frame)
depth_frame = rs.disparity_transform(False).process(depth_frame)
# depth_frame = rs.hole_filling_filter().process(depth_frame)
depth_image = np.asanyarray(depth_frame.get_data())
color_image1 = cv2.cvtColor(color_image, cv2.COLOR_RGB2BGR)
depth_color_frame = rs.colorizer().colorize(depth_frame)
depth_color_image = np.asanyarray(depth_color_frame.get_data())
cv2.imshow('Color Stream', color_image1)
cv2.imshow('Depth Stream', depth_color_image )
depth = Image(depth_image)
color = Image(color_image)
vis.register_key_callback(ord("Q"), breakLoop)
vis.register_key_callback(ord("K"), change_background_color)
try:
while True:
# time_start = time.time()
pointcloud.clear()
frames = pipeline.wait_for_frames()
aligned_frames = align.process(frames)
color_frame = aligned_frames.get_color_frame()
color_image = np.asanyarray(color_frame.get_data())
depth_frame = aligned_frames.get_depth_frame()
depth_frame = rs.decimation_filter(1).process(depth_frame)
depth_frame = rs.disparity_transform(True).process(depth_frame)
depth_frame = rs.spatial_filter().process(depth_frame)
depth_frame = rs.temporal_filter().process(depth_frame)
depth_frame = rs.disparity_transform(False).process(depth_frame)
# depth_frame = rs.hole_filling_filter().process(depth_frame)
depth_color_frame = rs.colorizer().colorize(depth_frame)
depth_color_image = np.asanyarray(depth_color_frame.get_data())
depth_image = np.asanyarray(depth_frame.get_data())
color_image1 = cv2.cvtColor(color_image, cv2.COLOR_RGB2BGR)
cv2.namedWindow('color image', cv2.WINDOW_AUTOSIZE)
cv2.imshow('color image', cv2.cvtColor(color_image, cv2.COLOR_RGB2BGR))
cv2.namedWindow('depth image', cv2.WINDOW_AUTOSIZE)
cv2.imshow('depth image', depth_color_image )
vis.create_window("Pointcloud",640,480)
pointcloud = PointCloud()
i = 0
while True:
dt0 = datetime.now()
pointcloud.clear()
frames = pipeline.wait_for_frames()
aligned_frames = align.process(frames)
color_frame = aligned_frames.get_color_frame()
color_image = np.asanyarray(color_frame.get_data())
depth_frame = aligned_frames.get_depth_frame()
depth_frame = rs.decimation_filter(1).process(depth_frame)
depth_frame = rs.disparity_transform(True).process(depth_frame)
depth_frame = rs.spatial_filter().process(depth_frame)
depth_frame = rs.temporal_filter().process(depth_frame)
depth_frame = rs.disparity_transform(False).process(depth_frame)
# depth_frame = rs.hole_filling_filter().process(depth_frame)
depth_image = np.asanyarray(depth_frame.get_data())
color_image1 = cv2.cvtColor(color_image, cv2.COLOR_RGB2BGR)
cv2.namedWindow('color image', cv2.WINDOW_AUTOSIZE)
cv2.imshow('color image', cv2.cvtColor(color_image, cv2.COLOR_RGB2BGR))
cv2.namedWindow('depth image', cv2.WINDOW_AUTOSIZE)
cv2.imshow('depth image', depth_image )
depth = Image(depth_image)
# temFeatureList,tem_new_xyr = registration.extractFeatures(temPoint2,tem_old_xyr,n = 3)
while True:
# Pt2 = []
Point2 = o3d.geometry.PointCloud()
frames = pipeline.wait_for_frames()
aligned_frames = align.process(frames)
color_frame = aligned_frames.get_color_frame()
color_image = np.asanyarray(color_frame.get_data())
depth_frame = aligned_frames.get_depth_frame()
depth_frame = rs.decimation_filter(1).process(depth_frame)
depth_frame = rs.disparity_transform(True).process(depth_frame)
depth_frame = rs.spatial_filter().process(depth_frame)
depth_frame = rs.temporal_filter().process(depth_frame)
depth_frame = rs.disparity_transform(False).process(depth_frame)
depth_image = np.asanyarray(depth_frame.get_data())
color_image1 = cv2.cvtColor(color_image, cv2.COLOR_RGB2BGR)
xl,yl,rl = keyPoints.getCircles(color_image1)
old_xyr = []
currentImage = color_image1.copy()
if i == 0:
for ind,x in enumerate(xl):
cv2.circle(currentImage, (xl[ind],yl[ind]), rl[ind], (0, 255, 0), -1)
vis.create_window("Pointcloud")
pointcloud = o3d.geometry.PointCloud()
vis.register_key_callback(ord(" "), saveCurrentRGBD)
vis.register_key_callback(ord("Q"), breakLoop)
vis.register_key_callback(ord("K"), change_background_color)
try:
while True:
dt0 = time.time()
frames = pipeline.wait_for_frames()
aligned_frames = align.process(frames)
color_frame = aligned_frames.get_color_frame()
color_image = np.asanyarray(color_frame.get_data())
depth_frame = aligned_frames.get_depth_frame()
depth_frame = rs.decimation_filter(1).process(depth_frame)
depth_frame = rs.disparity_transform(True).process(depth_frame)
depth_frame = rs.spatial_filter().process(depth_frame)
depth_frame = rs.temporal_filter().process(depth_frame)
depth_frame = rs.disparity_transform(False).process(depth_frame)
# depth_frame = rs.hole_filling_filter().process(depth_frame)
depth_image = np.asanyarray(depth_frame.get_data())
color_image1 = cv2.cvtColor(color_image, cv2.COLOR_RGB2BGR)
depth_color_frame = rs.colorizer().colorize(depth_frame)
depth_color_image = np.asanyarray(depth_color_frame.get_data())
cv2.imshow('Color Stream', color_image1)
cv2.imshow('Depth Stream', depth_color_image )
depth = o3d.geometry.Image(depth_image)
color = o3d.geometry.Image(color_image)
The alpha value for temporal filter based smoothening
temporal_smooth_delta : double
The delta value for temporal filter based smoothening
Return:
----------
filtered_frame : rs.frame()
The post-processed depth frame
"""
# Post processing possible only on the depth_frame
assert (depth_frame.is_depth_frame())
# Available filters and control options for the filters
decimation_filter = rs.decimation_filter()
spatial_filter = rs.spatial_filter()
temporal_filter = rs.temporal_filter()
filter_magnitude = rs.option.filter_magnitude
filter_smooth_alpha = rs.option.filter_smooth_alpha
filter_smooth_delta = rs.option.filter_smooth_delta
# Apply the control parameters for the filter
decimation_filter.set_option(filter_magnitude, decimation_magnitude)
spatial_filter.set_option(filter_magnitude, spatial_magnitude)
spatial_filter.set_option(filter_smooth_alpha, spatial_smooth_alpha)
spatial_filter.set_option(filter_smooth_delta, spatial_smooth_delta)
temporal_filter.set_option(filter_smooth_alpha, temporal_smooth_alpha)
temporal_filter.set_option(filter_smooth_delta, temporal_smooth_delta)
# Apply the filters