intelligent-control-lab/Kinect_Smoothing

What is .pkl format? What all it contains?

Ankitjaiswal1201 opened this issue ยท 3 comments

Hi,
I have depth images in .bmp format.

Is that I have to convert my images to .pkl format? or is there any way to use the images directly?

Hi,
We saved frames of depth images in data/sample_img.pkl and saved frames of position coordinates in data/sample_pose.pkl
sample_img.pkl is a list of image frames .
e.g. sample_img <- [ [ image_1 ] , [ image_2 ], ... , [ image_t ] ].
each image_i has a shape of (width, height)
Please see detailed information in example.ipynb

You can use images directly in any format, but you need to stack them to create a list of image frames. For example:

import joblib 
import matplotlib.pyplot as plt  
img1 =  plt.imread('image1.bmp')  
img2 =  plt.imread('image2.bmp')  
img_frames = [[img1], [img2]]   
joblib.dump(img_frames, 'image_frames.pkl')  

Hi,

Thank you for the prompt reply. This worked.
In case if anyone wants to use it for multiple files, then the code below should work.

import joblib 
import cv2
import glob 

X_data = []
file_lists = glob.glob("/home/ankit/Home_Cloud/Proband/Proband20/Fg_depth/*.bmp")
for files in sorted(file_lists):
    if files.endswith(".bmp"):
        image = cv2.imread(files)
        X_data.append(image)
        joblib.dump(X_data, 'image_frames.pkl')

It would be nice to add this info to the readme file.