You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi, I have run your code, and it can extract color images and depth images from .klg file and can also write a new .klg file from the original .klg file.
def write_klg(target_klg):
with open(timestamp_path, 'r') as f:
timestamps = f.readlines()
all_rgb_images = os.listdir(rgb_path)
all_rgb_images.sort()
all_depth_images = os.listdir(depth_path)
all_depth_images.sort()
n_frames = len(all_rgb_images)
print('total frames: ', n_frames)
klg = open(target_klg, 'wb')
# <number of frames encoded as 32 bit int>
klg.write(np.uint32(n_frames))
curr_frame = 0
for rgb, depth, t in tqdm(zip(all_rgb_images, all_depth_images, timestamps)):
curr_frame += 1
# <timestamp encoded as 64 bit int>
timestamp = np.uint64(t)
depth_image = cv2.imread(depth_path + '/' + depth, cv2.IMREAD_UNCHANGED).byteswap()
# <depth buffer zlib compressed in the following depth_size number of bytes>
depth_image = zlib.compress(depth_image, 9)
# <depth_size encoded as 32 bit int>
depth_size = np.uint32(len(depth_image))
rgb_image = cv2.imread(rgb_path + '/' + rgb)
# <rgb buffer jpeg compressed in the following image_size number of bytes>
rgb_image = cv2.imencode('.jpeg', rgb_image)[1].tostring()
# <image_size (rgb) encoded as 32 bit int>
rgb_size = np.uint32(len(rgb_image))
klg.write(timestamp)
klg.write(depth_size)
klg.write(rgb_size)
klg.write(depth_image)
klg.write(rgb_image)
klg.close()
When I use the klg2png function to extract images from original .klg file and then make a new .klg file using this function(up above), it works well. As is shown below(I only process 300 frames):
However, when I use the images captured by realsense camera. It doesn't work.
It seems that the depth image has some problems?
And this is the depth image extracted from the dyson_lab.klg file provided by the author of elasticfusion.
This is the depth image captured and saved by realsense camera.
It seems that the depth image isn't in the same format? I don't know... I save and read all depth image in 16bit and .png format.
I think the depth images captured by L515 camera seem more normal, but it doesn't work.
Or there is something i've missed...?
The text was updated successfully, but these errors were encountered:
Hi, I have run your code, and it can extract color images and depth images from .klg file and can also write a new .klg file from the original .klg file.
Now i'm trying to make my own .klg file using synchronized and aligned color images and depth images captured by intel realsense L515 camera. The data collect script can be found at https://github.com/IntelRealSense/librealsense/blob/master/wrappers/python/examples/align-depth2color.py
This is my implementation of png2klg function according your code and the .klg file protocol:
When I use the klg2png function to extract images from original .klg file and then make a new .klg file using this function(up above), it works well. As is shown below(I only process 300 frames):
However, when I use the images captured by realsense camera. It doesn't work.
It seems that the depth image has some problems?
And this is the depth image extracted from the dyson_lab.klg file provided by the author of elasticfusion.
This is the depth image captured and saved by realsense camera.
It seems that the depth image isn't in the same format? I don't know... I save and read all depth image in 16bit and .png format.
I think the depth images captured by L515 camera seem more normal, but it doesn't work.
Or there is something i've missed...?
The text was updated successfully, but these errors were encountered: