Giter VIP home page Giter VIP logo

kinect_smoothing's Introduction

Kinect Depth Image Smoothing

  • "Kinect Smoothing" helps you to smooth and filter the Kinect depth image and trajectory data.

How to Use it

  • Installation
git clone https://github.com/intelligent-control-lab/Kinect_Smoothing.git
pip install -r requirements.txt
  • Running

    Please check example.ipynb and kinect_preprocess_example.py.

  • Data preparation
    We saved many frames of depth images in data/sample_img.pkl and saved corresponding frames of position coordinates in data/sample_pose.pkl
    e.g. sample_img = [ [ image_1 ] , [ image_2 ], ... , [ image_t ] ]. each image_i has a shape of (width, height).
    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("/*.bmp")  # image path
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')

Features

1 . Depth Image Smoothing

2 . Trajectory Smoothing

  • Crop Filter:

    The x, y coordinates of the trajectory were captured by some object detection algorithms (e.g. Openpose). Sometimes the object will be positioned on the background, and the depth coordinates might register as invalid values on the Kinect. The Crop-Filter crops the invalid value and run some interpolation methods to replace it. The methods for invalid value replacement are as follows:

  • Gradient Crop Filter:

    Similar to Crop-Filter, the GradientCrop_Filter crops the large gradient values between near pixels maybe miss-labeled as background. The methods for invalid value replacement are as follows:

    • conventional interpolation methods: such as "zero","linear","slinear","quadratic","cubic","previous","next","nearest".
    • "pchip": PCHIP 1-d monotonic cubic interpolation.
    • "akima": Akima 1D Interpolator.
  • Smooth Filter:

    Smooth the data with a specific filter, which is effectively reducing the anomaly in the trajectory series. The methods for smoothing filter are as follows:

    • "kalman": smooth the signal with Kalman filter, refer to Fundamentals of Kalman Filtering
    • "wiener": smooth the signal with Wiener filter
    • "median": smooth the signal with median filter
    • "moving_average": smooth the signal with moving average filter
    • "exponential_moving_average": smooth the signal with exponential moving average filter
  • Motion Sampler:

    Motion detection and filtering out the stationary part of the trajectory. (Significant movements are preserved.)

3 . Real World Coordinate Calculation

  • Coordinate Calculator

    Transforming the pixel level coordinate of Kinect image to the real world coordinate.

kinect_smoothing's People

Contributors

walleclipse avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

kinect_smoothing's Issues

Comparison of results

Neither of these two methods seems to have obvious results. Is this reasonable?
Top: original vs Bottom: Denoising_Filter(flag="modeling", theta=60)
Kazam_screenshot_00000

Kazam_screenshot_00001

Running speed

Hi,

I am currently using this approach for real-time Kinect camera depth image smoothing. I collected 45 frames and send them into smoothing algorithm and then the algorithm got stuck at there forever. I changed to use just 2 frames but it didn't help at all. I wonder if I made any mistakes anywhere. Thanks for any hints.

not enough values to unpack

After installing the requirements, I ran the kinect_preprocess_example.py and got error:

multiprocessing.pool.RemoteTraceback:
"""
Traceback (most recent call last):
File "C:\Anaconda3\lib\multiprocessing\pool.py", line 121, in worker
result = (True, func(*args, **kwds))
File "C:\Anaconda3\lib\multiprocessing\pool.py", line 44, in mapstar
return list(map(*args))
File "G:\My Drive\research\Sarah Ostadabbas\codePool\Kinect_Smoothing\kinect_preprocess_example.py", line 50, in kinect_preprocess
action, file_name = pose_path.split('/')[:-2]
ValueError: not enough values to unpack (expected 2, got 0)
"""

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "G:/My Drive/research/Sarah Ostadabbas/codePool/Kinect_Smoothing/kinect_preprocess_example.py", line 70, in
kicet_preprocess_multi(data_dir, pose_save_dir, num_thread=8)
File "G:/My Drive/research/Sarah Ostadabbas/codePool/Kinect_Smoothing/kinect_preprocess_example.py", line 62, in kicet_preprocess_multi
pool.map(partial(kinect_preprocess,pose_save_dir=pose_save_dir),img_files)
File "C:\Anaconda3\lib\multiprocessing\pool.py", line 268, in map
return self._map_async(func, iterable, mapstar, chunksize).get()
File "C:\Anaconda3\lib\multiprocessing\pool.py", line 657, in get
raise self._value
ValueError: not enough values to unpack (expected 2, got 0)

Process finished with exit code 1

OS: windows 10
python: 3.7

It's too expancive

Hello, I have tried some methods in this project ,and I find this project using so much 'for loop' ,it is too expensive ,to deal with an image may cost serveral seconds.

Value Error : too many values to unpack

When I converted my depth images to .pkl file and ran the code, it gives me this error.

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-13-4693c0abb786> in <module>
      1 hole_filter = HoleFilling_Filter(flag='min')
----> 2 hf_image_frame = hole_filter.smooth_image_frames(image_frame)
      3 print('hole filled image frames (filled invalid values)')
      4 plot_image_frame(hf_image_frame)

~/Desktop/Research Project/Matlab Code/Kinect_Smoothing-master/kinect_smoothing/depth_image_smoothing.py in smooth_image_frames(self, image_frames)
    167                                 imgs=[imgs]
    168                         for img in imgs:
--> 169                                 res_img = self.smooth_image(img)
    170                                 smoothed_frames.append(res_img)
    171                 return smoothed_frames

~/Desktop/Research Project/Matlab Code/Kinect_Smoothing-master/kinect_smoothing/depth_image_smoothing.py in smooth_image(self, image)
    149                 image = image.copy()
    150                 if self.flag in ['min','max','mean','mode']:
--> 151                         smoothed_image = self.statistical_smoothing(image)
    152                 elif self.flag in ['fmi','ns']:
    153                         smoothed_image = self.inpainting_smoothing(image)

~/Desktop/Research Project/Matlab Code/Kinect_Smoothing-master/kinect_smoothing/depth_image_smoothing.py in statistical_smoothing(self, image)
    110 		"""
    111                 smoothed = image.copy()
--> 112                 h, w = image.shape
    113                 image[image <= self.valid_depth_min] = 0
    114                 image[image >= self.valid_depth_max] = 0

ValueError: too many values to unpack (expected 2)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.